Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "use strict"
- let core = {
- _field: [
- [0,0,0,0,1,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0],
- ],
- _counterX: 4,
- _counterY: 0,
- get field(){
- console.log(this._field);
- console.log("X: " + this._counterX);
- console.log("Y: " + this._counterY);
- },
- goRight() {
- let interval = setInterval(function(){
- if (this._counterX == this._field[this._counterY].length - 1) {
- return false;
- } else {
- this._field[this._counterY][this._counterX] = 0;
- this._field[this._counterY][this._counterX + 1] = 1;
- this._counterX++;
- }
- this.field;
- }, 500);
- },
- goLeft() {
- if (this._counterX <= 0) {
- return false;
- } else {
- this._field[this._counterY][this._counterX] = 0;
- this._field[this._counterY][this._counterX - 1] = 1;
- this._counterX--;
- }
- this.field;
- },
- goDown() {
- if (this._counterY == this._field.length - 1) {
- return false;
- } else {
- if ( this._field[this._counterY].length > this._field[this._counterY + 1].length) {
- this._field[this._counterY][this._counterX] = 0;
- this._field[this._counterY + 1][this._counterX -1] = 1;
- this._counterY++;
- this._counterX--;
- } else {
- this._field[this._counterY][this._counterX] = 0;
- this._field[this._counterY + 1][this._counterX] = 1;
- this._counterY++;
- }
- }
- this.field;
- }
- }
- core.field;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement