User prompt
The difficulty doesn't increase fast enough. Make it go up quicker.
User prompt
Slowly add more and more obstacles over time, so the game becomes harder the longer I stay alive.
User prompt
I should also be able to move in the X axis.
User prompt
Fix Bug: 'TypeError: reindeer.move is not a function' in this line: 'reindeer.move();' Line Number: 37
User prompt
Fix Bug: 'TypeError: reindeer.move is not a function' in this line: 'reindeer.move();' Line Number: 37
User prompt
The reindeer doesn't move when I click somewhere. It just stands still.
User prompt
Right now, the reindeer moves upwards all the time. It should stand still by default. When I click and hold the mouse somewhere, it should move towards that position.
User prompt
Add a score counter. I should get 1 point for each second I stay alive.
User prompt
Make it so that if the reindeer hits an obstacle, it's game over.
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'move')' in this line: 'obstacles[a].move();' Line Number: 33
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'move')' in this line: 'obstacles[a].move();' Line Number: 33
Initial prompt
Reindeer Rockets
var Reindeer = Container.expand(function () { var self = Container.call(this); if (self.y < self.targetY) { self.y += Math.min(self.speed, self.targetY - self.y); } else if (self.y > self.targetY) { self.y -= Math.min(self.speed, self.y - self.targetY); } var reindeerGraphics = self.createAsset('reindeer', 'Reindeer on a rocket', .5, .5); self.targetX = self.x; self.targetY = self.y; self.speed = 5; Reindeer.prototype.move = function () { if (this.x < this.targetX) { this.x += Math.min(this.speed, this.targetX - this.x); } else if (this.x > this.targetX) { this.x -= Math.min(this.speed, this.x - this.targetX); } if (this.y < this.targetY) { this.y += Math.min(this.speed, this.targetY - this.y); } else if (this.y > this.targetY) { this.y -= Math.min(this.speed, this.y - this.targetY); } }; }); var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.createAsset('obstacle', 'Obstacle', .5, .5); self.speed = -5; self.move = function () { self.x += self.speed; }; }); var Game = Container.expand(function () { var self = Container.call(this); LK.stageContainer.setBackgroundColor(0x008080); var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(.5, 0); LK.gui.topCenter.addChild(scoreTxt); var reindeer = self.addChild(new Reindeer()); reindeer.x = 2048 / 2; reindeer.y = 2732 - 200; var obstacles = []; var isGameOver = false; var tickOffset = 0; var score = 0; LK.on('tick', function () { reindeer.move(); if (isGameOver) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } else { if (LK.ticks % 60 === 0) { score++; } } for (var a = obstacles.length - 1; a >= 0; a--) { if (!obstacles[a]) continue; obstacles[a].move(); if (obstacles[a].x < -50) { obstacles[a].destroy(); obstacles.splice(a, 1); } } var difficultyFactor = 1 + Math.floor(LK.ticks / 900); if (tickOffset++ % (30 / difficultyFactor) == 0) { var newObstacle = new Obstacle(); newObstacle.x = 2048; newObstacle.y = Math.random() * 2732; obstacles.push(newObstacle); self.addChild(newObstacle); } scoreTxt.setText(score.toString()); for (var i = 0; i < obstacles.length; i++) { if (reindeer.intersects(obstacles[i])) { isGameOver = true; break; } } }); stage.on('down', function (obj) { var event = obj.event; var pos = event.getLocalPosition(self); reindeer.targetX = pos.x; reindeer.targetY = pos.y; }); });
===================================================================
--- original.js
+++ change.js
@@ -63,9 +63,9 @@
obstacles[a].destroy();
obstacles.splice(a, 1);
}
}
- var difficultyFactor = 1 + Math.floor(LK.ticks / 1800);
+ var difficultyFactor = 1 + Math.floor(LK.ticks / 900);
if (tickOffset++ % (30 / difficultyFactor) == 0) {
var newObstacle = new Obstacle();
newObstacle.x = 2048;
newObstacle.y = Math.random() * 2732;