Skip to content

Commit

Permalink
Use getter for queue length
Browse files Browse the repository at this point in the history
  • Loading branch information
mhluska committed Jun 24, 2016
1 parent 62668b4 commit acc3091
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions source/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ class Game {
}
}

// TODO(maros): Don't update per frame but per time delta. Use
// `window.performance.now`.
_update() {
const now = window.performance.now();
const timeDelta = now - this._lastTime;
Expand All @@ -211,6 +209,7 @@ class Game {
this._updateSnakeEnemy(this._snakeEnemy, timeDelta);

// Add food to the game every 100 frames.
// TODO(maros): Don't update per frame but per time delta.
if (this._steps % 100 === 0) {
this._updateWorld();
this._updateDebugInfo();
Expand Down
10 changes: 5 additions & 5 deletions source/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ class Queue {
this._maxSize = maxSize;
}

toArray() {
return this._data;
get length() {
return this._data.length;
}

size() {
return this._data.length;
toArray() {
return this._data;
}

empty() {
return this.size() === 0;
return this.length === 0;
}

peek() {
Expand Down

0 comments on commit acc3091

Please sign in to comment.