User prompt
Give the monsters a kill box and give the character a hit box
User prompt
Move the code button under coins, counter bar thing
User prompt
Makes a code thing I meant to say button that you can click, and you can use codes to get more money and guns you can choose what the codes are and tell mm
User prompt
Make this a online game with friendly fire
User prompt
When going to shop make a gun selection menu or buy menu to select or buy a weapon and instead of having enough money not going to a menu in the buying it make it if you have zero ten thousand one million dollars you can still use the shop
User prompt
Go to a gun selection menu when he goes to the shop instead of just having enough for the shop
User prompt
Give the character gun when he buys it
User prompt
Make the character faster
User prompt
Move the timer 10 cm up
User prompt
Move the time counter a little bit up
User prompt
Move the time counter at the middle bottom
User prompt
Move the queen bar at the middle top and move the time bar at the middle bottom
User prompt
Make the time bar seeable
User prompt
Make the shop work and have guns inside
User prompt
Make it more fast and put a speed button that let you sprint and it has limited stamina in when you use it all to get 10 coins to refill it
User prompt
Make the character a little bit faster
User prompt
Stop the character from teleporting when the someone is on the iPad and click the screen, make it walk there or run put a run button
User prompt
Put a pause button to pause. The game and unpause button is what the pause button into when you click it.
User prompt
And make the word coins seeable
User prompt
And don’t put the coins and tire bar in the same spot
User prompt
Make a shop where you can buy things with the money and the money can stack up and put a timer for how long you survived
User prompt
Make a shop to use the money on and the money stacks and it’s a online game that that has friendly fire
User prompt
Please fix the bug: 'ReferenceError: Can't find variable: friendlyFireEnabled' in or related to this line: 'if (friendlyFireEnabled) {' Line Number: 135
User prompt
Make the enemies follow the player and also make an online game and there’s friendly fire, and the stronger the monsters are the slower they are and some have armor and some of them are different. Some of them are not.
Code edit (1 edits merged)
Please save this source code
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { coins: 0, weaponLevel: 0 }); /**** * Classes ****/ var Character = Container.expand(function () { var self = Container.call(this); var characterGraphics = self.attachAsset('character', { anchorX: 0.5, anchorY: 0.5 }); self.down = function (x, y, obj) { dragNode = self; handleMove(x, y, obj); }; self.up = function (x, y, obj) { dragNode = null; }; return self; }); var Coin = Container.expand(function () { var self = Container.call(this); var coinGraphics = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.health = 3; // Example health value self.speed = 2 / self.health; // The stronger the enemy, the slower it moves self.update = function () { // Example enemy movement logic // Calculate direction towards the character var dx = character.x - self.x; var dy = character.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); // Normalize direction and move towards the character if (distance > 0) { self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } }; self.armor = Math.random() > 0.5 ? 1 : 0; // 50% chance to have armor return self; }); var Gun = Container.expand(function () { var self = Container.call(this); self.level = 1; // Initial gun level self.upgradeCost = 100; // Cost to upgrade the gun self.upgrade = function () { if (storage.coins >= self.upgradeCost) { storage.coins -= self.upgradeCost; self.level += 1; self.upgradeCost *= 2; // Increase cost for next upgrade scoreTxt.setText('Coins: ' + storage.coins); return true; } return false; }; return self; }); var Shop = Container.expand(function () { var self = Container.call(this); var shopGraphics = self.attachAsset('shop', { anchorX: 0.5, anchorY: 0.5 }); self.purchaseWeapon = function (weaponCost) { if (storage.coins >= weaponCost) { storage.coins -= weaponCost; scoreTxt.setText('Coins: ' + storage.coins); return true; } else if (gun.upgrade()) { console.log("Gun upgraded to level " + gun.level); return true; } return false; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Initialize assets used in this game. Scale them according to what is needed for the game. game.setBackgroundColor(0x008080); var character = game.addChild(new Character()); var shop = game.addChild(new Shop()); var gun = new Gun(); character.speed = 7; // Increase character speed shop.x = 1800; // Position the shop on the right side of the screen shop.y = 1366; character.x = 1024; character.y = 1366; character.stamina = 100; // Initialize character stamina var coins = []; var enemies = []; var dragNode = null; var friendlyFireEnabled = false; // Initialize friendlyFireEnabled variable var timerBar = new Container(); // Create a container for the time bar timerBar.x = 1024; // Center horizontally timerBar.y = 2632; // Position at the middle bottom of the screen timerBar.width = 800; // Set the width of the time bar timerBar.height = 50; // Set the height of the time bar timerBar.anchorX = 0.5; // Center the anchor point timerBar.anchorY = 0.5; // Center the anchor point timerBar.color = 0x00FF00; // Set the color of the time bar to green game.addChild(timerBar); // Add the time bar to the game var scoreTxt = new Text2('Coins: ' + storage.coins, { size: 150, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Move score text to the middle top of the screen var timerTxt = new Text2('Time: 0s', { size: 100, fill: 0xFFFFFF }); timerTxt.anchor.set(0.5, 0.5); LK.gui.bottom.addChild(timerTxt); // Add a pause button to the game interface var pauseButton = new Text2('Pause', { size: 100, fill: 0xFFFFFF }); pauseButton.anchor.set(0.5, 0); pauseButton.x = 1024; // Center horizontally pauseButton.y = 50; // Position near the top LK.gui.top.addChild(pauseButton); // Add a run button to the game interface var runButton = new Text2('Run', { size: 100, fill: 0xFFFFFF }); runButton.anchor.set(0.5, 0); runButton.x = 1024; // Center horizontally runButton.y = 150; // Position below the pause button LK.gui.top.addChild(runButton); // Add event listener for run button runButton.down = function () { if (character.speed === 7 && character.stamina > 0) { character.speed = 12; // Increase speed runButton.setText('Walk'); } else { character.speed = 7; // Reset to normal speed runButton.setText('Run'); } }; // Add event listener for pause button pauseButton.down = function () { if (game.paused) { game.resume(); pauseButton.setText('Pause'); } else { game.pause(); pauseButton.setText('Resume'); } }; function handleMove(x, y, obj) { if (dragNode) { var dx = x - dragNode.x; var dy = y - dragNode.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { var speed = character.speed; // Use character's speed dragNode.x += dx / distance * speed; dragNode.y += dy / distance * speed; } } } game.move = handleMove; game.down = function (x, y, obj) { dragNode = character; handleMove(x, y, obj); }; game.up = function (x, y, obj) { dragNode = null; }; game.update = function () { if (game.paused) { return; } // Skip update logic if the game is paused // Deplete stamina when running if (character.speed > 7 && character.stamina > 0) { character.stamina -= 0.5; if (character.stamina <= 0) { character.speed = 7; // Reset to normal speed when stamina is depleted runButton.setText('Run'); } } // Regenerate stamina when not running if (character.speed === 7 && character.stamina < 100) { character.stamina += 0.1; } if (LK.ticks % 60 == 0) { var secondsSurvived = Math.floor(LK.ticks / 60); timerTxt.setText('Time: ' + secondsSurvived + 's'); var totalGameTime = 300; // Total game time in seconds var remainingTime = totalGameTime - secondsSurvived; // Calculate remaining time timerBar.width = remainingTime / totalGameTime * 800; // Update the width of the time bar based on remaining time var newCoin = new Coin(); newCoin.x = Math.random() * 2048; newCoin.y = Math.random() * 2732; coins.push(newCoin); game.addChild(newCoin); } if (LK.ticks % 120 == 0) { var newEnemy = new Enemy(); newEnemy.x = Math.random() * 2048; newEnemy.y = 0; enemies.push(newEnemy); game.addChild(newEnemy); } for (var i = coins.length - 1; i >= 0; i--) { if (character.intersects(coins[i])) { storage.coins += 1; if (storage.coins % 10 === 0) { character.stamina = 100; // Refill stamina every 10 coins } scoreTxt.setText('Coins: ' + storage.coins); LK.getSound('coinCollect').play(); coins[i].destroy(); coins.splice(i, 1); } } for (var j = enemies.length - 1; j >= 0; j--) { enemies[j].update(); if (character.intersects(enemies[j])) { if (friendlyFireEnabled) { // Logic for friendly fire damage character.health -= 1; if (character.health <= 0) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } else { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } if (character.intersects(shop)) { if (shop.purchaseWeapon(100)) { console.log("Weapon purchased or upgraded!"); } else { console.log("Not enough coins to purchase or upgrade weapon."); } } if (enemies[j].health <= 0) { storage.coins += 5; scoreTxt.setText('Coins: ' + storage.coins); LK.getSound('enemyDefeat').play(); enemies[j].destroy(); enemies.splice(j, 1); } } }; LK.playMusic('backgroundMusic');
===================================================================
--- original.js
+++ change.js
@@ -135,10 +135,10 @@
var timerTxt = new Text2('Time: 0s', {
size: 100,
fill: 0xFFFFFF
});
-timerTxt.anchor.set(0.5, 0);
-LK.gui.topRight.addChild(timerTxt);
+timerTxt.anchor.set(0.5, 0.5);
+LK.gui.bottom.addChild(timerTxt);
// Add a pause button to the game interface
var pauseButton = new Text2('Pause', {
size: 100,
fill: 0xFFFFFF
Make it look like a shop. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A scary zombie. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A realistic coin. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A running man running for his life. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A house. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Zombie apocalypse city. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows