User prompt
reduce obstacle
User prompt
long jump
User prompt
voice respon fix βͺπ‘ Consider importing and using the following plugins: @upit/facekit.v1
User prompt
make voice gameplay βͺπ‘ Consider importing and using the following plugins: @upit/facekit.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Bunny Hop Rush
Initial prompt
rabit jumping run tap game
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var facekit = LK.import("@upit/facekit.v1"); /**** * Classes ****/ var Carrot = Container.expand(function () { var self = Container.call(this); var carrotGraphics = self.attachAsset('carrot', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -8; self.collected = false; self.update = function () { self.x += self.speed * gameSpeed; self.rotation += 0.1; }; return self; }); var Ground = Container.expand(function () { var self = Container.call(this); var groundGraphics = self.attachAsset('ground', { anchorX: 0, anchorY: 0 }); self.speed = -8; self.update = function () { self.x += self.speed * gameSpeed; }; return self; }); var Hole = Container.expand(function () { var self = Container.call(this); var holeGraphics = self.attachAsset('hole', { anchorX: 0.5, anchorY: 1.0 }); self.speed = -8; self.passed = false; self.update = function () { self.x += self.speed * gameSpeed; }; return self; }); var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 1.0 }); self.speed = -8; self.passed = false; self.update = function () { self.x += self.speed * gameSpeed; }; return self; }); var Rabbit = Container.expand(function () { var self = Container.call(this); var rabbitGraphics = self.attachAsset('rabbit', { anchorX: 0.5, anchorY: 1.0 }); self.velocityY = 0; self.isJumping = false; self.isOnGround = true; self.jumpPower = -25; self.gravity = 1.2; self.groundY = 0; self.jump = function () { if (self.isOnGround) { self.velocityY = self.jumpPower; self.isJumping = true; self.isOnGround = false; LK.getSound('jump').play(); } }; self.update = function () { if (!self.isOnGround) { self.velocityY += self.gravity; self.y += self.velocityY; if (self.y >= self.groundY) { self.y = self.groundY; self.velocityY = 0; self.isJumping = false; self.isOnGround = true; } } }; return self; }); var Spike = Container.expand(function () { var self = Container.call(this); var spikeGraphics = self.attachAsset('spike', { anchorX: 0.5, anchorY: 1.0 }); self.speed = -8; self.passed = false; self.update = function () { self.x += self.speed * gameSpeed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb }); /**** * Game Code ****/ var gameSpeed = 1.0; var distanceTraveled = 0; var carrotsCollected = 0; var gameRunning = true; var lastVoiceJump = false; var voiceJumpCooldown = 0; // Ground setup var groundY = 2732 - 200; var groundSegments = []; for (var i = 0; i < 10; i++) { var groundSegment = game.addChild(new Ground()); groundSegment.x = i * 300; groundSegment.y = groundY; groundSegments.push(groundSegment); } // Rabbit setup var rabbit = game.addChild(new Rabbit()); rabbit.x = 400; rabbit.y = groundY; rabbit.groundY = groundY; // Game elements arrays var obstacles = []; var holes = []; var carrots = []; var spikes = []; // Obstacle spawn timer var obstacleTimer = 0; var obstacleSpawnRate = 90; // Distance and score display var distanceText = new Text2('Distance: 0m', { size: 80, fill: 0xFFFFFF }); distanceText.anchor.set(0, 0); LK.gui.topLeft.addChild(distanceText); distanceText.x = 120; distanceText.y = 20; var carrotText = new Text2('Carrots: 0', { size: 80, fill: 0xFFFFFF }); carrotText.anchor.set(1, 0); LK.gui.topRight.addChild(carrotText); carrotText.x = -20; carrotText.y = 20; function spawnObstacle() { var obstacleType = Math.floor(Math.random() * 4); var spawnX = 2048 + 200; if (obstacleType === 0) { var obstacle = game.addChild(new Obstacle()); obstacle.x = spawnX; obstacle.y = groundY; obstacles.push(obstacle); } else if (obstacleType === 1) { var hole = game.addChild(new Hole()); hole.x = spawnX; hole.y = groundY; holes.push(hole); } else if (obstacleType === 2) { var spike = game.addChild(new Spike()); spike.x = spawnX; spike.y = groundY; spikes.push(spike); } else { var carrot = game.addChild(new Carrot()); carrot.x = spawnX; carrot.y = groundY - 200; carrots.push(carrot); } } function checkCollisions() { // Check obstacle collisions for (var i = obstacles.length - 1; i >= 0; i--) { var obstacle = obstacles[i]; if (rabbit.intersects(obstacle)) { LK.getSound('hit').play(); LK.effects.flashScreen(0xff0000, 1000); gameRunning = false; LK.showGameOver(); return; } if (obstacle.x < -200) { obstacle.destroy(); obstacles.splice(i, 1); } } // Check hole collisions for (var i = holes.length - 1; i >= 0; i--) { var hole = holes[i]; if (rabbit.intersects(hole) && rabbit.isOnGround) { LK.getSound('hit').play(); LK.effects.flashScreen(0xff0000, 1000); gameRunning = false; LK.showGameOver(); return; } if (hole.x < -200) { hole.destroy(); holes.splice(i, 1); } } // Check spike collisions for (var i = spikes.length - 1; i >= 0; i--) { var spike = spikes[i]; if (rabbit.intersects(spike)) { LK.getSound('hit').play(); LK.effects.flashScreen(0xff0000, 1000); gameRunning = false; LK.showGameOver(); return; } if (spike.x < -200) { spike.destroy(); spikes.splice(i, 1); } } // Check carrot collection for (var i = carrots.length - 1; i >= 0; i--) { var carrot = carrots[i]; if (rabbit.intersects(carrot) && !carrot.collected) { carrot.collected = true; carrotsCollected++; LK.setScore(LK.getScore() + 10); LK.getSound('collect').play(); carrot.destroy(); carrots.splice(i, 1); } else if (carrot.x < -200) { carrot.destroy(); carrots.splice(i, 1); } } } function updateGround() { for (var i = groundSegments.length - 1; i >= 0; i--) { var segment = groundSegments[i]; if (segment.x < -300) { segment.x = (groundSegments.length - 1) * 300; } } } game.down = function (x, y, obj) { if (gameRunning) { rabbit.jump(); } }; function handleVoiceControl() { // Reduce cooldown timer if (voiceJumpCooldown > 0) { voiceJumpCooldown--; } // Check for voice input to trigger jump var currentVoiceLevel = facekit.volume > 0.3; // Moderate sound level to jump if (!lastVoiceJump && currentVoiceLevel && voiceJumpCooldown <= 0) { // Voice jump triggered if (gameRunning) { rabbit.jump(); voiceJumpCooldown = 15; // Prevent multiple jumps from same sound } } // Update last voice state lastVoiceJump = currentVoiceLevel; } game.update = function () { if (!gameRunning) return; // Handle voice control handleVoiceControl(); // Update distance and speed distanceTraveled += 0.5; gameSpeed = 1.0 + distanceTraveled / 1000; // Update ground updateGround(); // Spawn obstacles obstacleTimer++; if (obstacleTimer >= obstacleSpawnRate) { spawnObstacle(); obstacleTimer = 0; obstacleSpawnRate = Math.max(40, obstacleSpawnRate - 1); } // Check collisions checkCollisions(); // Update UI distanceText.setText('Distance: ' + Math.floor(distanceTraveled) + 'm'); carrotText.setText('Carrots: ' + carrotsCollected); // Update score based on distance LK.setScore(Math.floor(distanceTraveled) + carrotsCollected * 10); };
===================================================================
--- original.js
+++ change.js
@@ -1,8 +1,9 @@
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
+var facekit = LK.import("@upit/facekit.v1");
/****
* Classes
****/
@@ -119,8 +120,10 @@
var gameSpeed = 1.0;
var distanceTraveled = 0;
var carrotsCollected = 0;
var gameRunning = true;
+var lastVoiceJump = false;
+var voiceJumpCooldown = 0;
// Ground setup
var groundY = 2732 - 200;
var groundSegments = [];
for (var i = 0; i < 10; i++) {
@@ -258,10 +261,29 @@
if (gameRunning) {
rabbit.jump();
}
};
+function handleVoiceControl() {
+ // Reduce cooldown timer
+ if (voiceJumpCooldown > 0) {
+ voiceJumpCooldown--;
+ }
+ // Check for voice input to trigger jump
+ var currentVoiceLevel = facekit.volume > 0.3; // Moderate sound level to jump
+ if (!lastVoiceJump && currentVoiceLevel && voiceJumpCooldown <= 0) {
+ // Voice jump triggered
+ if (gameRunning) {
+ rabbit.jump();
+ voiceJumpCooldown = 15; // Prevent multiple jumps from same sound
+ }
+ }
+ // Update last voice state
+ lastVoiceJump = currentVoiceLevel;
+}
game.update = function () {
if (!gameRunning) return;
+ // Handle voice control
+ handleVoiceControl();
// Update distance and speed
distanceTraveled += 0.5;
gameSpeed = 1.0 + distanceTraveled / 1000;
// Update ground
Fullscreen modern App Store landscape banner, 16:9, high definition, for a game titled "Bunny Hop Rush" and with the description "An endless runner where you tap to make a rabbit jump over obstacles while automatically running forward. Collect carrots and see how far you can go!". No text on banner!
meadow. In-Game asset. 2d. High contrast. No shadows
big stone. In-Game asset. 2d. High contrast. No shadows
carrot. In-Game asset. 2d. High contrast. No shadows
bush. In-Game asset. 2d. High contrast. No shadows