Code edit (1 edits merged)
Please save this source code
User prompt
their is a moon ithe corner of the screen in the gameplay can you remove that
User prompt
i cant hear the sounds
User prompt
very good, can you add more decor to the game in general (not the same assets new ones)
User prompt
add a pixelated moon picture at the bottom
User prompt
spot on but add more decore on the start screen
User prompt
make a screen before the game with a start button when yoh press it it starts the game
User prompt
scrap the idea
User prompt
its good just can you add a start butten so when you hit it ,it statrts the game
User prompt
make a title screen
User prompt
make that a asset
User prompt
- **Slow Motion:** Temporarily slows down all asteroids when picked up power up
User prompt
do dynamic difficulty
User prompt
Please fix the bug: 'TypeError: LK.effects.shakeScreen is not a function' in or related to this line: 'LK.effects.shakeScreen(0xff0000, 800, 20); // Strong shake on collision' Line Number: 88
User prompt
Please fix the bug: 'TypeError: LK.effects.shake is not a function' in or related to this line: 'LK.effects.shake({' Line Number: 88
User prompt
Please fix the bug: 'TypeError: LK.effects.shakeScreen is not a function' in or related to this line: 'LK.effects.shakeScreen(800, 20); // Strong shake on collision' Line Number: 88
User prompt
yes do thatt
User prompt
Make the score on top.
User prompt
Make every astro that the spaceship dodges, make that count as a point.
User prompt
No, just make them come down in your direction.
User prompt
Yes, but make the asteroids come for you.
User prompt
Make it go left to right. It can't move up or down.
Initial prompt
asteroid dodger
/**** * Classes ****/ // Asteroid class var Asteroid = Container.expand(function () { var self = Container.call(this); var asteroidGraphics = self.attachAsset('asteroid', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; }; }); //<Assets used in the game will automatically appear here> // Slow Motion Power-Up class var SlowMotionPowerUp = Container.expand(function () { var self = Container.call(this); var powerupGraphics = self.attachAsset('slowmo', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 6; self.update = function () { self.y += self.speed; }; return self; }); // Spaceship class var Spaceship = Container.expand(function () { var self = Container.call(this); var spaceshipGraphics = self.attachAsset('spaceship', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { // Spaceship update logic if needed }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // No title screen or start button; game starts immediately // Dedicated slow motion power-up asset // Initialize spaceship var spaceship = game.addChild(new Spaceship()); spaceship.x = 2048 / 2; spaceship.y = 2732 - 200; // Array to hold asteroids var asteroids = []; // Slow motion power-up variables var slowMotionActive = false; var slowMotionTimer = 0; var SLOW_MOTION_DURATION = 180; // 3 seconds at 60fps var SLOW_MOTION_FACTOR = 0.3; // Asteroids move at 30% speed // Function to handle spaceship movement function handleMove(x, y, obj) { if (gameState !== "playing") return; spaceship.x = x; // spaceship.y = y; // Commented out to restrict vertical movement } // Game move event game.move = function (x, y, obj) { handleMove(x, y, obj); }; // Game update function game.update = function () { // No title UI or gameState logic; always run gameplay // Dynamic difficulty variables if (typeof asteroidSpawnInterval === "undefined") { var asteroidSpawnInterval = 60; // Initial spawn interval (frames) var asteroidBaseSpeed = 5; // Initial asteroid speed var asteroidMaxSpeed = 30; // Cap asteroid speed var asteroidMinInterval = 15; // Minimum interval between spawns var asteroidDifficultyStep = 10; // Score step for difficulty increase var asteroidLastDifficultyScore = 0; } // Increase difficulty based on score var currentScore = LK.getScore(); if (currentScore - asteroidLastDifficultyScore >= asteroidDifficultyStep) { asteroidLastDifficultyScore = currentScore; // Increase speed, decrease interval asteroidBaseSpeed = Math.min(asteroidBaseSpeed + 1, asteroidMaxSpeed); asteroidSpawnInterval = Math.max(asteroidSpawnInterval - 5, asteroidMinInterval); } // Create new asteroids if (LK.ticks % asteroidSpawnInterval == 0) { var newAsteroid = new Asteroid(); newAsteroid.x = Math.random() * 2048; newAsteroid.y = -50; newAsteroid.speed = asteroidBaseSpeed; asteroids.push(newAsteroid); game.addChild(newAsteroid); // 1 in 10 chance to spawn a slow motion power-up (but not if one is already active or present) if (!slowMotionActive && Math.random() < 0.1 && typeof slowMotionPowerUp === "undefined") { slowMotionPowerUp = new SlowMotionPowerUp(); slowMotionPowerUp.x = Math.random() * 2048; slowMotionPowerUp.y = -100; game.addChild(slowMotionPowerUp); } } // Initialize score display var scoreTxt = new Text2('0', { size: 150, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Update asteroids for (var i = asteroids.length - 1; i >= 0; i--) { var asteroid = asteroids[i]; // Apply slow motion if active if (slowMotionActive) { asteroid.y += asteroid.speed * SLOW_MOTION_FACTOR; } else { asteroid.update(); } // Check for collision with spaceship if (spaceship.intersects(asteroid)) { LK.effects.flashScreen(0xff0000, 1000); // Play collision sound if available if (LK.getSound && LK.getSound('crash')) { LK.getSound('crash').play(); } // Show game over LK.showGameOver(); return; } // Remove off-screen asteroids and increment score if (asteroid.y > 2732 + 50) { // Near miss visual/audio effect if asteroid was close to spaceship horizontally var dx = Math.abs(asteroid.x - spaceship.x); if (dx < 200) { LK.effects.flashScreen(0xffff00, 200); // Quick yellow flash for near miss // Play near miss sound if available if (LK.getSound && LK.getSound('nearMiss')) { LK.getSound('nearMiss').play(); } } asteroid.destroy(); asteroids.splice(i, 1); LK.setScore(LK.getScore() + 1); // Increment score for each asteroid dodged scoreTxt.setText(LK.getScore()); // Update score display // Play score up sound if available if (LK.getSound && LK.getSound('scoreUp')) { LK.getSound('scoreUp').play(); } // Play asteroid whoosh sound if available if (LK.getSound && LK.getSound('whoosh')) { LK.getSound('whoosh').play(); } } } // Handle slow motion power-up logic if (typeof slowMotionPowerUp !== "undefined" && slowMotionPowerUp) { // Move power-up slowMotionPowerUp.y += slowMotionPowerUp.speed; // Check for collision with spaceship if (spaceship.intersects(slowMotionPowerUp)) { slowMotionActive = true; slowMotionTimer = SLOW_MOTION_DURATION; // Visual feedback for slow motion activation LK.effects.flashScreen(0x3399ff, 400); slowMotionPowerUp.destroy(); slowMotionPowerUp = undefined; } else if (slowMotionPowerUp.y > 2732 + 100) { // Remove if off screen slowMotionPowerUp.destroy(); slowMotionPowerUp = undefined; } } // Handle slow motion timer if (slowMotionActive) { slowMotionTimer--; if (slowMotionTimer <= 0) { slowMotionActive = false; } } };
===================================================================
--- original.js
+++ change.js
@@ -49,84 +49,9 @@
/****
* Game Code
****/
-// Title screen state
-var gameState = "title"; // "title" | "playing"
-// Title screen UI elements
-var titleText = new Text2("ASTEROID DODGE", {
- size: 180,
- fill: 0xFFFFFF
-});
-titleText.anchor.set(0.5, 0.5);
-titleText.x = 2048 / 2;
-titleText.y = 900;
-var subtitleText = new Text2(" ", {
- size: 100,
- fill: 0xCCCCCC
-});
-subtitleText.anchor.set(0.5, 0.5);
-subtitleText.x = 2048 / 2;
-subtitleText.y = 1200;
-var howToText = new Text2("Drag to move your ship\nDodge asteroids, grab power-ups!", {
- size: 70,
- fill: 0xAAFFFF
-});
-howToText.anchor.set(0.5, 0.5);
-howToText.x = 2048 / 2;
-howToText.y = 1450;
-// Start button
-var startButton = new Text2("START", {
- size: 120,
- fill: 0x00FF99,
- font: "Impact, Arial Black, Tahoma"
-});
-startButton.anchor.set(0.5, 0.5);
-startButton.x = 2048 / 2;
-startButton.y = 1200;
-startButton.interactive = true;
-startButton.buttonMode = true;
-// Add to GUI overlay so always visible
-LK.gui.center.addChild(titleText);
-LK.gui.center.addChild(subtitleText);
-LK.gui.center.addChild(howToText);
-LK.gui.center.addChild(startButton);
-// Hide title UI function
-function hideTitleUI() {
- titleText.visible = false;
- subtitleText.visible = false;
- howToText.visible = false;
- startButton.visible = false;
-}
-// Show title UI function
-function showTitleUI() {
- titleText.visible = true;
- subtitleText.visible = true;
- howToText.visible = true;
- startButton.visible = true;
-}
-// Start button tap handler
-startButton.down = function (x, y, obj) {
- if (gameState === "title") {
- gameState = "playing";
- hideTitleUI();
- // Reset score and asteroids
- LK.setScore(0);
- scoreTxt.setText(0);
- for (var i = asteroids.length - 1; i >= 0; i--) {
- asteroids[i].destroy();
- asteroids.splice(i, 1);
- }
- if (typeof slowMotionPowerUp !== "undefined" && slowMotionPowerUp) {
- slowMotionPowerUp.destroy();
- slowMotionPowerUp = undefined;
- }
- slowMotionActive = false;
- slowMotionTimer = 0;
- spaceship.x = 2048 / 2;
- spaceship.y = 2732 - 200;
- }
-};
+// No title screen or start button; game starts immediately
// Dedicated slow motion power-up asset
// Initialize spaceship
var spaceship = game.addChild(new Spaceship());
spaceship.x = 2048 / 2;
@@ -145,21 +70,13 @@
// spaceship.y = y; // Commented out to restrict vertical movement
}
// Game move event
game.move = function (x, y, obj) {
- if (gameState === "title") {
- // Do not start game on tap anywhere; only start button starts the game
- return;
- }
handleMove(x, y, obj);
};
// Game update function
game.update = function () {
- // Show title UI if in title state, and do not run gameplay logic
- if (gameState === "title") {
- showTitleUI();
- return;
- }
+ // No title UI or gameState logic; always run gameplay
// Dynamic difficulty variables
if (typeof asteroidSpawnInterval === "undefined") {
var asteroidSpawnInterval = 60; // Initial spawn interval (frames)
var asteroidBaseSpeed = 5; // Initial asteroid speed
@@ -214,13 +131,10 @@
// Play collision sound if available
if (LK.getSound && LK.getSound('crash')) {
LK.getSound('crash').play();
}
- // Show game over and return to title after
+ // Show game over
LK.showGameOver();
- // After game over, return to title screen
- gameState = "title";
- showTitleUI();
return;
}
// Remove off-screen asteroids and increment score
if (asteroid.y > 2732 + 50) {