Skip to content

Instantly share code, notes, and snippets.

@captainpete
Created May 14, 2018 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save captainpete/eb5e4fda057e55561403d4f946713e3f to your computer and use it in GitHub Desktop.
Save captainpete/eb5e4fda057e55561403d4f946713e3f to your computer and use it in GitHub Desktop.
2048 game simulation snippet
// Add the initial tiles
this.grid.insertTile(new Tile({x:3,y:0}, 2**1));
this.grid.insertTile(new Tile({x:2,y:0}, 2**1));
this.grid.insertTile(new Tile({x:1,y:0}, 2**2));
this.grid.insertTile(new Tile({x:0,y:0}, 2**3));
this.grid.insertTile(new Tile({x:0,y:1}, 2**4));
this.grid.insertTile(new Tile({x:1,y:1}, 2**5));
this.grid.insertTile(new Tile({x:2,y:1}, 2**6));
this.grid.insertTile(new Tile({x:3,y:1}, 2**7));
this.grid.insertTile(new Tile({x:3,y:2}, 2**8));
this.grid.insertTile(new Tile({x:2,y:2}, 2**9));
this.grid.insertTile(new Tile({x:1,y:2}, 2**10));
this.grid.insertTile(new Tile({x:0,y:2}, 2**11));
this.grid.insertTile(new Tile({x:0,y:3}, 2**12));
this.grid.insertTile(new Tile({x:1,y:3}, 2**13));
this.grid.insertTile(new Tile({x:2,y:3}, 2**14));
this.grid.insertTile(new Tile({x:3,y:3}, 2**15));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment