diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/engine.js | 11 | ||||
| -rw-r--r-- | src/objecttypes.js | 3 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/engine.js b/src/engine.js index b75886a..4ae653a 100644 --- a/src/engine.js +++ b/src/engine.js @@ -133,7 +133,7 @@ Engine.prototype.testForGameover = function() { var xdist = obj.position.x - p.position.x; - if (xdist > -0.3 * obj.width && xdist < 0.2 * obj.width) { + if (xdist > -obj.width * 0.8 && xdist < obj.width * 0.1) { var ydist = obj.position.y - p.position.y; if (ydist > -obj.height / 2 && ydist < obj.height / 2) { @@ -166,16 +166,21 @@ Engine.prototype.update = function() { if (this.state == GAME || this.state == MENU) { this.testForGameover(); + var toBeRemoved = -1; for (var i = 0; i < this.gameObjectList.length; i++) { var obj = this.gameObjectList[i]; obj.update(); // check if integral object has left the screen if (obj.objectType == "integral") { - if (obj.sprite.x < -obj.sprite.width) - this.removeIntegral(obj); + if (obj.sprite.x < -obj.sprite.width) { + toBeRemoved = i; + } } } + if (toBeRemoved != -1) { + this.removeIntegral(this.gameObjectList[toBeRemoved]); + } } if (this.state == GAMEOVER) { diff --git a/src/objecttypes.js b/src/objecttypes.js index e9f69f0..4dab85c 100644 --- a/src/objecttypes.js +++ b/src/objecttypes.js @@ -6,8 +6,7 @@ function Background(x_offset) { this.x_speed = 10 this.objectType = "background"; -} - +} Background.prototype = Object.create(GameObject.prototype); Background.prototype.constructor = Background; |
