diff --git a/js/Player.js b/js/Player.js index c8f184f..5601fae 100644 --- a/js/Player.js +++ b/js/Player.js @@ -39,12 +39,12 @@ export class Player extends Movable { } break case 'up': - if (this.y > Game.row(0)) { + if (Game.withinTopBoundary(this.y)) { this.move(0, -Game.CELL_HEIGHT) } break case 'down': - if (this.y < Game.row(5)) { + if (Game.withinBottomBoundary(this.y)) { this.move(0, Game.CELL_HEIGHT) } break diff --git a/js/constants/game.js b/js/constants/game.js index 6bbee50..31c8e0d 100644 --- a/js/constants/game.js +++ b/js/constants/game.js @@ -24,5 +24,13 @@ export class Game { static withinRightBoundary(x) { return x < Game.col(Game.HORIZON_CELLS) } + + static withinTopBoundary(y) { + return y > Game.TOP_BOUNDARY + } + + static withinBottomBoundary(y) { + return y < Game.row(5) + } }