Code edit (2 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
adjust the score text position at the right top of the screen
User prompt
change the timer text color to blue
User prompt
play the background music in a loop
User prompt
create a background music and assign it to the game entirely
User prompt
add sound effects whenever player bullet hits the enemy
User prompt
replace background and create a new asset and assign that asset to background
User prompt
change backgroundColor to new asset
Code edit (2 edits merged)
Please save this source code
User prompt
show the timer on the center on the screen
User prompt
show the game time on the screen
Code edit (2 edits merged)
Please save this source code
User prompt
show the timer on the bottom center of the screen
User prompt
show the timer on the center of the screen
User prompt
show the timer on the bottom center of the screen
User prompt
show the game time on the screen
User prompt
give a timer 2 min for the game after 2 min the game will end and show the score
User prompt
assing a score board for this game
User prompt
add 2 min timer and give score how many enemies i fired
Code edit (1 edits merged)
Please save this source code
/**** * Classes ****/ // Define a class for bullets var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -15; self.update = function () { self.y += self.speed; if (self.y < 0) { self.destroy(); } }; }); // Define a class for enemies var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.y = 0; self.x = Math.random() * 2048; } }; }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Define a class for the player character var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, // scale player bigger scaleY: 2 // scale player bigger }); self.speed = 10; self.update = function () { // Player update logic }; }); /**** * Initialize Game ****/ // Initialize a score text object var game = new LK.Game(); /**** * Game Code ****/ LK.playMusic('bgmusic', { loop: true }); var background = game.attachAsset('background', { anchorX: 0, anchorY: 0 }); // Initialize a score text object // Initialize player var scoreTxt = new Text2('0', { size: 150, fill: 0xFFFFFF }); // Add the score text to the game GUI LK.gui.top.addChild(scoreTxt); // Initialize a timer text object var timerTxt = new Text2('120', { size: 150, fill: 0x0000FF }); // Add the timer text to the game GUI LK.gui.center.addChild(timerTxt); var player = game.addChild(new Player()); player.x = 1024; player.y = 2500; // Initialize enemies var enemies = []; for (var i = 0; i < 5; i++) { var enemy = new Enemy(); enemy.x = Math.random() * 2048; enemy.y = Math.random() * 1000; enemies.push(enemy); game.addChild(enemy); } // Initialize bullets var bullets = []; // Initialize a timer variable to keep track of the game time var timer = 120 * 60; // Convert minutes to ticks // Handle player movement game.move = function (x, y, obj) { player.x = x; player.y = y; }; // Handle shooting game.down = function (x, y, obj) { var bullet = new Bullet(); bullet.x = player.x; bullet.y = player.y; bullets.push(bullet); game.addChild(bullet); }; // Update game state game.update = function () { // Update enemies for (var i = 0; i < enemies.length; i++) { enemies[i].update(); } // Increase the enemies spawn count every 5 seconds if (LK.ticks % 50 == 0) { var enemy = new Enemy(); enemy.x = Math.random() * 2048; enemy.y = Math.random() * 1000; enemies.push(enemy); game.addChild(enemy); } // Update bullets for (var j = bullets.length - 1; j >= 0; j--) { bullets[j].update(); if (bullets[j].y < 0) { bullets.splice(j, 1); } } // Check for collisions for (var k = bullets.length - 1; k >= 0; k--) { for (var l = enemies.length - 1; l >= 0; l--) { if (bullets[k].intersects(enemies[l])) { bullets[k].destroy(); enemies[l].destroy(); bullets.splice(k, 1); enemies.splice(l, 1); // Increase the score when an enemy is destroyed LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); // Play sound effect when player bullet hits the enemy LK.getSound('hit').play(); break; } } } // Decrease the timer every tick timer--; // Update the timer text timerTxt.setText(Math.ceil(timer / 60)); // Convert ticks to seconds // If the time is up, show the game over screen if (timer <= 0) { LK.showGameOver(); } };
===================================================================
--- original.js
+++ change.js
i have character wearing suit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
balloon. Single Game Texture. In-Game asset. Blank background. High contrast. No shadows. 2d
laser fire. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
theme park. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. 2d