Added body cell functionality
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
const Hyperparams = require("../Hyperparameters");
|
||||
const Modes = require("./ControlModes");
|
||||
const CellTypes = require("../Organism/Cell/CellTypes");
|
||||
|
||||
class ControlPanel {
|
||||
constructor(engine) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const CanvasController = require("./CanvasController");
|
||||
const Modes = require("./ControlModes");
|
||||
const CellTypes = require("../Organism/Cell/CellTypes");
|
||||
const CellStates = require("../Organism/Cell/CellStates");
|
||||
const Directions = require("../Organism/Directions");
|
||||
|
||||
class EditorController extends CanvasController{
|
||||
@@ -25,7 +25,6 @@ class EditorController extends CanvasController{
|
||||
mouseUp(){}
|
||||
|
||||
getCurLocalCell(){
|
||||
console.log(this.env.organism.getLocalCell(this.mouse_c-this.env.organism.c, this.mouse_r-this.env.organism.r))
|
||||
return this.env.organism.getLocalCell(this.mouse_c-this.env.organism.c, this.mouse_r-this.env.organism.r);
|
||||
}
|
||||
|
||||
@@ -37,25 +36,13 @@ class EditorController extends CanvasController{
|
||||
if (this.edit_cell_type == null || this.mode != Modes.Edit)
|
||||
return;
|
||||
if (this.left_click){
|
||||
if(this.edit_cell_type == CellTypes.eye) {
|
||||
if (this.cur_cell.type == CellTypes.eye){
|
||||
var loc_cell = this.getCurLocalCell();
|
||||
var dir = loc_cell.eye.direction;
|
||||
dir = Directions.rotateRight(dir);
|
||||
loc_cell.eye.direction = dir;
|
||||
this.cur_cell.direction = dir;
|
||||
this.env.addCellToOrg(this.mouse_c, this.mouse_r, this.edit_cell_type);
|
||||
}
|
||||
else {
|
||||
this.env.addCellToOrg(this.mouse_c, this.mouse_r, this.edit_cell_type);
|
||||
var loc_cell = this.getCurLocalCell();
|
||||
loc_cell.eye.direction = Directions.up;
|
||||
this.env.addCellToOrg(this.mouse_c, this.mouse_r, this.edit_cell_type);
|
||||
}
|
||||
if(this.edit_cell_type == CellStates.eye && this.cur_cell.state == CellStates.eye) {
|
||||
var loc_cell = this.getCurLocalCell();
|
||||
loc_cell.direction = Directions.rotateRight(loc_cell.direction);
|
||||
this.env.renderFull();
|
||||
}
|
||||
else{
|
||||
else
|
||||
this.env.addCellToOrg(this.mouse_c, this.mouse_r, this.edit_cell_type);
|
||||
}
|
||||
}
|
||||
if (this.right_click)
|
||||
this.env.removeCellFromOrg(this.mouse_c, this.mouse_r);
|
||||
@@ -70,22 +57,22 @@ class EditorController extends CanvasController{
|
||||
$('.cell-type').click( function() {
|
||||
switch(this.id){
|
||||
case "mouth":
|
||||
self.edit_cell_type = CellTypes.mouth;
|
||||
self.edit_cell_type = CellStates.mouth;
|
||||
break;
|
||||
case "producer":
|
||||
self.edit_cell_type = CellTypes.producer;
|
||||
self.edit_cell_type = CellStates.producer;
|
||||
break;
|
||||
case "mover":
|
||||
self.edit_cell_type = CellTypes.mover;
|
||||
self.edit_cell_type = CellStates.mover;
|
||||
break;
|
||||
case "killer":
|
||||
self.edit_cell_type = CellTypes.killer;
|
||||
self.edit_cell_type = CellStates.killer;
|
||||
break;
|
||||
case "armor":
|
||||
self.edit_cell_type = CellTypes.armor;
|
||||
self.edit_cell_type = CellStates.armor;
|
||||
break;
|
||||
case "eye":
|
||||
self.edit_cell_type = CellTypes.eye;
|
||||
self.edit_cell_type = CellStates.eye;
|
||||
break;
|
||||
}
|
||||
$(".cell-type" ).css( "border-color", "black" );
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const CanvasController = require("./CanvasController");
|
||||
const Organism = require('../Organism/Organism');
|
||||
const Modes = require("./ControlModes");
|
||||
const CellTypes = require("../Organism/Cell/CellTypes");
|
||||
const CellStates = require("../Organism/Cell/CellStates");
|
||||
const Neighbors = require("../Grid/Neighbors");
|
||||
const Cell = require("../Organism/Cell/Cell");
|
||||
const Cell = require("../Organism/Cell/GridCell");
|
||||
|
||||
class EnvironmentController extends CanvasController{
|
||||
constructor(env, canvas) {
|
||||
@@ -69,19 +69,19 @@ class EnvironmentController extends CanvasController{
|
||||
switch(mode) {
|
||||
case Modes.FoodDrop:
|
||||
if (left_click){
|
||||
this.dropCellType(cell.col, cell.row, CellTypes.food, false);
|
||||
this.dropCellType(cell.col, cell.row, CellStates.food, false);
|
||||
}
|
||||
else if (right_click){
|
||||
this.dropCellType(cell.col, cell.row, CellTypes.empty, false);
|
||||
this.dropCellType(cell.col, cell.row, CellStates.empty, false);
|
||||
}
|
||||
break;
|
||||
case Modes.WallDrop:
|
||||
if (left_click){
|
||||
this.dropCellType(cell.col, cell.row, CellTypes.wall, true);
|
||||
this.dropCellType(cell.col, cell.row, CellStates.wall, true);
|
||||
|
||||
}
|
||||
else if (right_click){
|
||||
this.dropCellType(cell.col, cell.row, CellTypes.empty, false);
|
||||
this.dropCellType(cell.col, cell.row, CellStates.empty, false);
|
||||
}
|
||||
break;
|
||||
case Modes.ClickKill:
|
||||
@@ -118,7 +118,7 @@ class EnvironmentController extends CanvasController{
|
||||
}
|
||||
}
|
||||
|
||||
dropCellType(col, row, type, killBlocking=false) {
|
||||
dropCellType(col, row, state, killBlocking=false) {
|
||||
for (var loc of Neighbors.allSelf){
|
||||
var c=col + loc[0];
|
||||
var r=row + loc[1];
|
||||
@@ -131,7 +131,7 @@ class EnvironmentController extends CanvasController{
|
||||
else if (cell.owner != null) {
|
||||
continue;
|
||||
}
|
||||
this.env.changeCell(c, r, type, null);
|
||||
this.env.changeCell(c, r, state, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user