User prompt
please add a backdrop
User prompt
make the score increase by 1 everytime the player sucsesfully jumps over the enemy
User prompt
make the score text pastel pink
User prompt
add a score system everytime the player jumps over a enemy the score increases by 1
User prompt
make the enemys at the beginning slowly spawn as the game progress es the enemys spawn more often
User prompt
make the jump a little higher
User prompt
make the jump a litle bit higher
Initial prompt
kawaii parkour
/**** * Classes ****/ // Define the Player class var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.createAsset('player', 'Player character', 0.5, 1); self.speed = 5; self.jumpPower = -22; self.gravity = 0.5; self.velocityY = 0; self.isJumping = false; self.isFlipping = false; self.flipRotation = 0; self.incrementScore = function (obstacle) { if (!obstacle.hasScored) { score++; obstacle.hasScored = true; scoreTxt.setText(score.toString()); } }; self.moveRight = function () { self.x += self.speed; }; self.jump = function () { if (!self.isJumping) { self.isJumping = true; self.velocityY = self.jumpPower; } }; self.update = function () { self.y += self.velocityY; self.velocityY += self.gravity; if (self.isFlipping) { playerGraphics.rotation += self.flipRotation; } // Check for ground collision if (self.y > game.height - playerGraphics.height) { self.y = game.height - playerGraphics.height; self.isJumping = false; self.isFlipping = false; playerGraphics.rotation = 0; } }; self.flip = function () { if (!self.isFlipping && self.isJumping) { self.isFlipping = true; self.flipRotation = Math.PI / 16; // 22.5 degrees per frame } }; }); // Define the Obstacle class var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.createAsset('obstacle', 'Obstacle', 0.5, 1); self.speed = -5; self.hasScored = false; self.move = function () { self.x += self.speed; }; self.update = function () { self.move(); }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Initialize important asset arrays and score var obstacles = []; var score = 0; var scoreTxt = new Text2(score.toString(), { size: 150, fill: "#ffaec9" // Pastel pink color }); scoreTxt.anchor.set(.5, 0); LK.gui.top.addChild(scoreTxt); var player = game.addChild(new Player()); // Set the player's starting position player.x = 2048 / 4; player.y = game.height - player.height; // Game tick event LK.on('tick', function () { // Update player player.update(); // Update obstacles for (var i = obstacles.length - 1; i >= 0; i--) { obstacles[i].update(); // Check for collision with player and if the player has jumped over an obstacle if (player.intersects(obstacles[i])) { // End game if collision occurs LK.showGameOver(); } else if (player.y < obstacles[i].y && player.x > obstacles[i].x && !obstacles[i].hasScored) { // Increment score if player jumps over the obstacle player.incrementScore(obstacles[i]); } // Remove off-screen obstacles if (obstacles[i].x + obstacles[i].width < 0) { obstacles[i].destroy(); obstacles.splice(i, 1); } // Remove off-screen obstacles if (obstacles[i].x + obstacles[i].width < 0) { obstacles[i].destroy(); obstacles.splice(i, 1); } } // Spawn obstacles with variable rate var spawnRate = 120 - Math.floor(LK.ticks / 1800); // Decrease spawn rate every 30 seconds if (spawnRate < 30) { spawnRate = 30; } // Set a minimum spawn rate if (LK.ticks % spawnRate === 0) { var obstacle = new Obstacle(); obstacle.x = game.width; obstacle.y = game.height - obstacle.height; obstacles.push(obstacle); game.addChild(obstacle); } }); // Touch event listeners game.on('down', function (obj) { var touchPos = obj.event.getLocalPosition(game); if (touchPos.x > game.width / 2) { player.moveRight(); } else { player.jump(); } }); game.on('up', function (obj) { player.flip(); });
===================================================================
--- original.js
+++ change.js
@@ -11,10 +11,14 @@
self.velocityY = 0;
self.isJumping = false;
self.isFlipping = false;
self.flipRotation = 0;
- self.incrementScore = function () {
- score++;
+ self.incrementScore = function (obstacle) {
+ if (!obstacle.hasScored) {
+ score++;
+ obstacle.hasScored = true;
+ scoreTxt.setText(score.toString());
+ }
};
self.moveRight = function () {
self.x += self.speed;
};
@@ -92,13 +96,11 @@
// Check for collision with player and if the player has jumped over an obstacle
if (player.intersects(obstacles[i])) {
// End game if collision occurs
LK.showGameOver();
- } else if (player.y < obstacles[i].y && player.x > obstacles[i].x) {
+ } else if (player.y < obstacles[i].y && player.x > obstacles[i].x && !obstacles[i].hasScored) {
// Increment score if player jumps over the obstacle
- player.incrementScore();
- // Ensure score is only incremented once per obstacle
- obstacles[i].hasScored = true;
+ player.incrementScore(obstacles[i]);
}
// Remove off-screen obstacles
if (obstacles[i].x + obstacles[i].width < 0) {
obstacles[i].destroy();
kawaii style kitten. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Kawaii style monster. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
kawaii style grass feild backdrop. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.