User prompt
Could you replace the snow mound with snow pillar on the welcome message
User prompt
And replace snow mounds with snow pillars
User prompt
Could you replace the duck with hide on the sta rt screen
User prompt
I can't see any difference on the trees
User prompt
Could you make the trees better aswell as immuntity when i'm ducking
User prompt
Es funktioniert nicht
User prompt
Mit den zwei buttons die auch Felder bekommen sollten sollte man sich links und rechts bewegen sollen.
User prompt
Bitte zwei buttons zum draufklicken
User prompt
Bitte den Hintergrund noch detaillierter machen.
User prompt
Perfekt ich kann aber manchmal noch getroffen werden obwohl ich am ducken bin
User prompt
Bitte mehr ducking Zeit
User prompt
Bitte ein bisschen mehr ''duck'' Zeit
User prompt
Bitte ein minibisschen mehr
User prompt
Bitte mach die Zeit wie lange man es herunterhalten kann kürzer außerdem bitte 3 Leben
User prompt
Man sollte es nicht gedrückt halten können außerdem ist die Zeit über dem Score schau es dir mal an und mach die Verbesserungen.
Code edit (1 edits merged)
Please save this source code
User prompt
Snowball Dodge
Initial prompt
Bitte mache ein Spiel wo man sich vor Schneebällen mit Shift oder tippen (gedrückt halten) sich hinter Schnee wegduckt damit man nicht getroffen wird bitte in einer Winterlandschaft
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Player = Container.expand(function () { var self = Container.call(this); self.standing = self.attachAsset('player', { anchorX: 0.5, anchorY: 1.0, visible: true }); self.ducking = self.attachAsset('playerDucking', { anchorX: 0.5, anchorY: 1.0, visible: false }); self.isDucking = false; self.duckDuration = 30; // Shorter duck duration self.lives = 3; // Initialize player with 3 lives self.isHit = false; self.hitCooldown = 0; self.duck = function () { if (!self.isDucking && !self.isHit) { self.isDucking = true; self.standing.visible = false; self.ducking.visible = true; self.duckDuration = 30; // Reset duck duration LK.getSound('duck').play(); } }; self.stand = function () { if (self.isDucking && !self.isHit) { self.isDucking = false; self.standing.visible = true; self.ducking.visible = false; } }; self.hit = function () { if (!self.isHit && !self.isDucking) { self.isHit = true; self.hitCooldown = 30; // Half a second at 60fps LK.getSound('hit').play(); LK.effects.flashObject(self, 0xff0000, 500); self.lives--; if (self.lives <= 0) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } }; self.update = function () { if (self.isDucking) { self.duckDuration--; if (self.duckDuration <= 0) { self.stand(); } } if (self.isHit) { self.hitCooldown--; if (self.hitCooldown <= 0) { self.isHit = false; } } }; return self; }); var SnowMound = Container.expand(function () { var self = Container.call(this); var moundGraphics = self.attachAsset('snowMound', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var Snowball = Container.expand(function () { var self = Container.call(this); var snowballGraphics = self.attachAsset('snowball', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = 0; self.speedY = 0; self.gravity = 0.2; self.active = true; self.reset = function (startX, startY, targetX, targetY) { self.x = startX; self.y = startY; // Calculate angle to target var dx = targetX - startX; var dy = targetY - startY; var distance = Math.sqrt(dx * dx + dy * dy); // Normalize speed based on distance var speed = 10 + Math.random() * 5; self.speedX = dx / distance * speed; // Launch with upward arc var arcHeight = -10 - Math.random() * 5; self.speedY = dy / distance * speed + arcHeight; self.active = true; self.alpha = 1; }; self.update = function () { if (self.active) { self.x += self.speedX; self.y += self.speedY; self.speedY += self.gravity; // Check if out of bounds if (self.y > 2732 || self.x < -200 || self.x > 2248) { self.active = false; } } }; return self; }); var Tree = Container.expand(function () { var self = Container.call(this); var trunk = self.attachAsset('treeTrunk', { anchorX: 0.5, anchorY: 1.0, y: 0 }); var foliage = self.attachAsset('tree', { anchorX: 0.5, anchorY: 1.0, y: -trunk.height }); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb }); /**** * Game Code ****/ // Create background elements var background = game.addChild(LK.getAsset('background', { anchorX: 0, anchorY: 0, x: 0, y: 0 })); var ground = game.addChild(LK.getAsset('ground', { anchorX: 0.5, anchorY: 0, x: 1024, y: 2332 })); // Add trees in the background var trees = []; for (var i = 0; i < 5; i++) { var tree = new Tree(); tree.x = 200 + i * 400 + Math.random() * 100; tree.y = 2332; trees.push(tree); game.addChild(tree); } // Add snow mounds for cover var mounds = []; for (var i = 0; i < 3; i++) { var mound = new SnowMound(); mound.x = 500 + i * 500; mound.y = 2232; mounds.push(mound); game.addChild(mound); } // Create player var player = new Player(); player.x = 1024; player.y = 2332; game.addChild(player); // Create pool of snowballs var snowballs = []; var maxSnowballs = 20; for (var i = 0; i < maxSnowballs; i++) { var snowball = new Snowball(); snowball.active = false; snowball.visible = false; snowballs.push(snowball); game.addChild(snowball); } // Create score text var scoreTxt = new Text2('Score: 0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(1, 0); LK.gui.topRight.addChild(scoreTxt); // Create survival time text var timeTxt = new Text2('Time: 0s', { size: 80, fill: 0xFFFFFF }); timeTxt.anchor.set(1, 0); // Position above the score timeTxt.y = -scoreTxt.height - 20; LK.gui.topRight.addChild(timeTxt); // Game state variables var gameStarted = false; var gameTime = 0; var nextSnowballTime = 0; var snowballFrequency = 60; // Frames between snowballs var difficultyIncreaseTime = 600; // 10 seconds at 60fps // Touch input handling game.down = function (x, y, obj) { if (!gameStarted) { gameStarted = true; LK.playMusic('winterMusic'); } if (!player.isDucking) { player.duck(); } }; game.up = function (x, y, obj) { player.stand(); }; // Spawn a snowball function spawnSnowball() { // Find an inactive snowball for (var i = 0; i < snowballs.length; i++) { if (!snowballs[i].active) { // Spawn from the left or right side var side = Math.random() < 0.5 ? -100 : 2148; var startX = side; var startY = 1500 + Math.random() * 500; // Target the player with some random offset var targetX = player.x + (Math.random() * 200 - 100); var targetY = player.y - player.standing.height / 2; snowballs[i].reset(startX, startY, targetX, targetY); snowballs[i].visible = true; LK.getSound('throw').play(); return; } } } // Check if player is protected by a snow mound function isPlayerProtected() { if (!player.isDucking) { return false; } for (var i = 0; i < mounds.length; i++) { var mound = mounds[i]; var distance = Math.abs(player.x - mound.x); if (distance < 250) { return true; } } return false; } // Update game game.update = function () { if (!gameStarted) { return; } // Update game time gameTime++; if (gameTime % 60 === 0) { // Update time display every second var seconds = Math.floor(gameTime / 60); timeTxt.setText('Time: ' + seconds + 's'); // Add points for surviving LK.setScore(LK.getScore() + 1); scoreTxt.setText('Score: ' + LK.getScore()); } // Increase difficulty over time if (gameTime % difficultyIncreaseTime === 0 && snowballFrequency > 15) { snowballFrequency = Math.max(15, snowballFrequency - 5); } // Spawn snowballs if (gameTime >= nextSnowballTime) { spawnSnowball(); nextSnowballTime = gameTime + snowballFrequency - Math.random() * 10; } // Update player player.update(); // Update snowballs and check collisions for (var i = 0; i < snowballs.length; i++) { var snowball = snowballs[i]; if (snowball.active) { snowball.update(); // Check collision with player if (snowball.intersects(player) && !isPlayerProtected() && !player.isHit) { player.hit(); snowball.active = false; snowball.visible = false; // Removed game over check from here } // Make snowball invisible if not active if (!snowball.active) { snowball.visible = false; } } } }; // Start game with welcome message var welcomeTxt = new Text2('Tap and hold to duck\nbehind snow mounds\nand avoid snowballs!', { size: 100, fill: 0xFFFFFF, align: 'center' }); welcomeTxt.anchor.set(0.5, 0.5); LK.gui.center.addChild(welcomeTxt); // Remove welcome message after first touch game.down = function (x, y, obj) { if (!gameStarted) { gameStarted = true; LK.gui.center.removeChild(welcomeTxt); LK.playMusic('winterMusic'); } player.duck(); };
===================================================================
--- original.js
+++ change.js
@@ -19,15 +19,18 @@
anchorY: 1.0,
visible: false
});
self.isDucking = false;
+ self.duckDuration = 30; // Shorter duck duration
+ self.lives = 3; // Initialize player with 3 lives
self.isHit = false;
self.hitCooldown = 0;
self.duck = function () {
if (!self.isDucking && !self.isHit) {
self.isDucking = true;
self.standing.visible = false;
self.ducking.visible = true;
+ self.duckDuration = 30; // Reset duck duration
LK.getSound('duck').play();
}
};
self.stand = function () {
@@ -42,12 +45,22 @@
self.isHit = true;
self.hitCooldown = 30; // Half a second at 60fps
LK.getSound('hit').play();
LK.effects.flashObject(self, 0xff0000, 500);
- LK.setScore(Math.max(0, LK.getScore() - 1));
+ self.lives--;
+ if (self.lives <= 0) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
}
};
self.update = function () {
+ if (self.isDucking) {
+ self.duckDuration--;
+ if (self.duckDuration <= 0) {
+ self.stand();
+ }
+ }
if (self.isHit) {
self.hitCooldown--;
if (self.hitCooldown <= 0) {
self.isHit = false;
@@ -277,13 +290,9 @@
if (snowball.intersects(player) && !isPlayerProtected() && !player.isHit) {
player.hit();
snowball.active = false;
snowball.visible = false;
- // Check for game over
- if (LK.getScore() <= 0) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- }
+ // Removed game over check from here
}
// Make snowball invisible if not active
if (!snowball.active) {
snowball.visible = false;