Skip to content

Commit

Permalink
Changed corners to work based on declared margin
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Faraday committed Oct 12, 2016
1 parent 5074149 commit 5cd8fba
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
4 changes: 2 additions & 2 deletions lib/data/players.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
GridGame.data.players = [
{
name: 'green',
start: GridGame.positions.north_west_corner,
start: GridGame.positions.north_west_corner(2),
direction: 'east',
playable: true
},
{
name: 'red',
start: GridGame.positions.south_east_corner,
start: GridGame.positions.south_east_corner(2),
direction: 'west',
playable: true
}
Expand Down
40 changes: 25 additions & 15 deletions lib/positions.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
GridGame.positions = {
north_west_corner: {
x: 2,
y: 2
north_west_corner: function (margin) {
return {
x: margin,
y: margin
}
},
north_east_corner: {
x: (GridGame.data.game.width - 3),
y: 2
north_east_corner: function (margin) {
return {
x: (GridGame.data.game.width - margin - 1),
y: margin
}
},
south_west_corner: {
x: 2,
y: (GridGame.data.game.height - 3)
south_west_corner: function (margin) {
return {
x: margin,
y: (GridGame.data.game.height - margin - 1)
}
},
south_east_corner: {
x: (GridGame.data.game.width - 3),
y: (GridGame.data.game.height - 3)
south_east_corner: function (margin) {
return {
x: (GridGame.data.game.width - margin - 1),
y: (GridGame.data.game.height - margin - 1)
}
},
center: {
x: Math.floor(GridGame.data.game.width / 2),
y: Math.floor(GridGame.data.game.height / 2)
center: function () {
return {
x: Math.floor(GridGame.data.game.width / 2),
y: Math.floor(GridGame.data.game.height / 2)
}
}
};

0 comments on commit 5cd8fba

Please sign in to comment.