Skip to content

Commit

Permalink
[Linesh][#23] Refactor: use game global constants in engine.js
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanLin-TWer committed Mar 19, 2017
1 parent ab77194 commit f981b04
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions js/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import Resources from './resources'
import { Game } from './constants'
import { allEnemies } from './Enemy'
import { Player } from './Player'

Expand All @@ -30,7 +31,7 @@ var Engine = (function () {
lastTime
let player

canvas.width = 505
canvas.width = Game.BOARD_WIDTH
canvas.height = 606
doc.body.appendChild(canvas)

Expand Down Expand Up @@ -127,8 +128,8 @@ var Engine = (function () {
'images/grass-block.png', // Row 1 of 2 of grass
'images/grass-block.png' // Row 2 of 2 of grass
],
numRows = 6,
numCols = 5,
numRows = Game.VERTICAL_CELLS,
numCols = Game.HORIZON_CELLS,
row, col

/* Loop through the number of rows and columns we've defined above
Expand All @@ -144,7 +145,7 @@ var Engine = (function () {
* so that we get the benefits of caching these images, since
* we're using them over and over.
*/
ctx.drawImage(Resources.get(rowImages[row]), col * 101, row * 83)
ctx.drawImage(Resources.get(rowImages[row]), col * Game.CELL_WIDTH, row * Game.CELL_HEIGHT)
}
}

Expand Down

0 comments on commit f981b04

Please sign in to comment.