Skip to content

Commit

Permalink
[Linesh][#22] Refactor: use game.board_width to replace game.col(6)
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanLin-TWer committed Mar 19, 2017
1 parent cad5fb1 commit 059c4e2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions js/Enemy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export class Enemy {

update(dt) {
this.x += dt * this.speed
if (this.x > Game.col(6)) {
this.x -= Game.col(6)
if (this.x > Game.BOARD_WIDTH) {
this.x -= Game.BOARD_WIDTH
}
}

Expand Down
2 changes: 2 additions & 0 deletions js/constants/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export class Game {
static CELL_WIDTH = 101
static CELL_HEIGHT = 83
static COLLISION_RADIUS = 12
static HORIZON_CELLS = 5
static BOARD_WIDTH = Game.CELL_WIDTH * Game.HORIZON_CELLS

static row(y) {
return this.CELL_HEIGHT * (y - 1) + 55
Expand Down

0 comments on commit 059c4e2

Please sign in to comment.