User prompt
also add blocks they hurt you but if you jump on them they do nothing
User prompt
when you lose reset speed to normal
User prompt
every 25 secounds make obsticle get 10 times faster
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'addEventListener')' in this line: 'document.addEventListener('keydown', function (event) {' Line Number: 106
User prompt
if you press any hotkey make the player jump
User prompt
after you get 8 secounds into the game make the obsticles get faster everyeight seccounds
User prompt
make player jump a little farther
User prompt
spread obsitcles apart
User prompt
make hero jump a little higher
User prompt
make obsticle a little smaller
Initial prompt
geometry dash Z
===================================================================
--- original.js
+++ change.js
@@ -56,8 +56,27 @@
self.destroy();
}
};
});
+// Block class
+var Block = Container.expand(function () {
+ var self = Container.call(this);
+ var blockGraphics = self.createAsset('block', 'Harmful block', 0.5, 1);
+ blockGraphics.scale.set(0.8);
+ self.speed = Obstacle.baseSpeed;
+ self.move = function () {
+ self.x -= self.speed;
+ if (self.x < -blockGraphics.width) {
+ self.destroy();
+ }
+ };
+ self.isHarmful = function () {
+ // Check if the player's bottom is above the top of the block, which means the player is jumping on it
+ var playerBottom = player.y + player.height;
+ var blockTop = self.y - blockGraphics.height / 2;
+ return playerBottom < blockTop;
+ };
+});
/****
* Initialize Game
****/
@@ -83,20 +102,21 @@
player.update();
// Move each obstacle and check for collisions
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].move();
- if (player.intersects(obstacles[i])) {
+ if (player.intersects(obstacles[i]) && !(obstacles[i] instanceof Block && !obstacles[i].isHarmful())) {
LK.effects.flashScreen(0xff0000, 500);
LK.showGameOver();
}
}
// Increase obstacle speed every 25 seconds and make it 10 times faster
if (LK.ticks % 1500 === 0) {
Obstacle.baseSpeed = 3;
}
- // Spawn obstacles
+ // Spawn obstacles and blocks
if (LK.ticks % 180 === 0) {
- var obstacle = new Obstacle();
+ var obstacleType = Math.random() < 0.5 ? Obstacle : Block;
+ var obstacle = new obstacleType();
obstacle.x = game.width;
obstacle.y = game.height - 100;
obstacles.push(obstacle);
game.addChild(obstacle);