User prompt
There shall be new advancements in advancements menu: Kill A White Tank - NOT DONE/DONE Kill A Black Tank - NOT DONE/DONE Have 1000 Score - NOT DONE/DONE Pass 5 Levels Without Dying - NOT DONE/DONE ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
White Tank and Black Tank's bullets shall be like what happens when bullets touch player tank when each other's bullet touches each other ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
There can be between 1 and 3 of Black Tanks in a level. There can be between 2 and 4 of White Tanks in a level.
User prompt
New Enemies: White Tank: This tank shoots white balls at the player. If a white ball hits the player, it explodes and releases electricity in a circular area with a radius of 2 blocks. Any player tank in that area takes 2 HP damage per second. Each "Skin Color Tank" in the area takes 0.5 HP damage per second. Each "Red Tank" in the area takes 2 HP damage per second. Each "Green Tank" in the area takes 10 HP damage per second. And if an enemy takes damage in that area, it stops attacking the player and starts attacking the "White Tank." When the "White Tank" sees the "Black Tank," it stops attacking the player and starts attacking the "Black Tank." "White Tank" = 275 HP "Black Tank": This tank shoots black balls at the player. If a black ball hits the player, it explodes and creates a black hole covering a circular area with a radius of 1 block. This black hole slowly pulls in the player and enemies. If the player is in the center of the black hole, they start losing 8 HP per second. The black hole disappears after 5 seconds. The "Skin Color Tank" takes 2 HP damage per second in the black hole. The "Red Tank" takes 4 HP damage per second. The "Green Tank" takes 15 HP damage per second. The "White Tank" dies instantly upon entering the black hole. When the "Black Tank" sees the "White Tank," it stops attacking the player and starts attacking the "White Tank." "Black Tank" = 225 HP There can be between 0 and 2 of Black Tanks in a level. There can be between 0 and 2 of White Tanks in a level. (If "New Enemies" is on) ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Now, if mouse clicks "play", don't generate the level and start immediately, first, there shall a screen come. Top of screen, there shall write "Do You Wanna Activate Experiments". Under it, there shall be a button (text color red); "New Enemies - Off". If mouse clicks it, the button's text color shall be green and write "New Enemies - On". ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
The player tank shall turn to where it shot to.
User prompt
It shall be able to be seen
User prompt
In the main menu, there shall write "v.0.1.4" in the right down corner (color: yellow) A little big
User prompt
In the main menu, there shall write "v.0.1.4" in the right down corner (color: turquoise)
User prompt
In the main menu, there shall write "v.0.1.4" in the right down corner (color: aqua)
User prompt
If the screen that there is next level button in it is on, dragging shall be unuseable
User prompt
Add the same button to Game Over Screen
User prompt
In Game Over screen, there shall be a button writes "return to main menu" and when mouse clicks that button, return to main menu and clear the previous level (the same button shall be under the "Next Level" button in the screen when player is so close to portal)
User prompt
When player starts the game, don't generate the level. There shall be a menu. There shall be a button writes "PLAY". If mouse clicks that, generate level 1. And there shall be a picture about the game background of the menu
User prompt
When player opens the "Achievements" menu, the dragging mode shall be unuseable
User prompt
And change the achievement write "Finish without dying" in the achievements menu as writing "Finish a level without dying"
User prompt
And when you generate the next level, don't generate another player tank
User prompt
I wanna add new achievements to the achievements menu. New achievements: Arrive at level 3 - Done/Not Done Kill 50 Enemies in Total - Done/Not Done ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
But before teleport the player into it, there shall be a screen, in screen, there shall be a button, writing "Next Level". When player clicks that, the player shall teleport into the next level you generated and the previous level shall be cleared
User prompt
Now, when player is so close to the portal, do not spawn the "You Won" screen, generate a new level and teleport the player into it. After, clear the previous level.
User prompt
And the enemy tanks shall turn to the way where they're moving to ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
And the pipe of tank shall turn to the way where the mouse drags it ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
It shall be more smoothly ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var AcidBomb = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('acidBomb', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.directionX = 0; self.directionY = 0; self.damage = 5; self.poisonDamage = 2; self.poisonDuration = 180; self.update = function () { if (gamePaused) return; self.x += self.directionX * self.speed; self.y += self.directionY * self.speed; }; return self; }); var Dynamite = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('dynamite', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.directionX = 0; self.directionY = 0; self.damage = 25; self.explosionRadius = 80; self.update = function () { if (gamePaused) return; self.x += self.directionX * self.speed; self.y += self.directionY * self.speed; }; return self; }); var EnemyBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('enemyBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 4; self.directionX = 0; self.directionY = 0; self.damage = 10; self.update = function () { if (gamePaused) return; self.x += self.directionX * self.speed; self.y += self.directionY * self.speed; }; return self; }); var GreenTank = Container.expand(function () { var self = Container.call(this); var tankGraphics = self.attachAsset('greenTank', { anchorX: 0.5, anchorY: 0.5 }); self.health = 40; self.speed = 0.8; self.shootCooldown = 0; self.update = function () { if (gamePaused) return; if (self.shootCooldown > 0) { self.shootCooldown--; } var dx = playerTank.x - self.x; var dy = playerTank.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); // Move toward player when they can see them (within range) if (distance < 300) { var moveX = dx > 0 ? self.speed : -self.speed; var moveY = dy > 0 ? self.speed : -self.speed; var newX = self.x + moveX; var newY = self.y + moveY; // Calculate target angle for rotation var targetAngle = Math.atan2(dy, dx); // Stop any existing rotation tween tween.stop(self, { rotation: true }); // Smoothly rotate the tank to face the movement direction tween(self, { rotation: targetAngle }, { duration: 300, easing: tween.easeOut }); if (!checkWallCollision(newX, self.y)) { self.x = newX; } if (!checkWallCollision(self.x, newY)) { self.y = newY; } } if (distance < 200 && self.shootCooldown <= 0) { var length = Math.sqrt(dx * dx + dy * dy); var dirX = dx / length; var dirY = dy / length; var acidBomb = new AcidBomb(); acidBomb.x = self.x; acidBomb.y = self.y; acidBomb.directionX = dirX; acidBomb.directionY = dirY; acidBombs.push(acidBomb); game.addChild(acidBomb); self.shootCooldown = 150; LK.getSound('shoot').play(); } }; return self; }); var Medkit = Container.expand(function () { var self = Container.call(this); var medkitGraphics = self.attachAsset('medkit', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var PlayerBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('playerBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.directionX = 0; self.directionY = 0; self.damage = 10; self.update = function () { if (gamePaused) return; self.x += self.directionX * self.speed; self.y += self.directionY * self.speed; }; return self; }); var PlayerTank = Container.expand(function () { var self = Container.call(this); var tankGraphics = self.attachAsset('playerTank', { anchorX: 0.5, anchorY: 0.5 }); self.maxHealth = 100; self.health = 100; self.speed = 3; self.shootCooldown = 0; self.poisonTimer = 0; self.poisonDamage = 0; self.update = function () { if (gamePaused) return; if (self.shootCooldown > 0) { self.shootCooldown--; } if (self.poisonTimer > 0) { self.poisonTimer--; if (LK.ticks % 30 === 0) { self.health -= self.poisonDamage; if (self.health <= 0) { LK.showGameOver(); } } } }; return self; }); var Portal = Container.expand(function () { var self = Container.call(this); var portalGraphics = self.attachAsset('portal', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Portal no longer rotates }; return self; }); var RedTank = Container.expand(function () { var self = Container.call(this); var tankGraphics = self.attachAsset('redTank', { anchorX: 0.5, anchorY: 0.5 }); self.health = 80; self.speed = 1; self.shootCooldown = 0; self.update = function () { if (gamePaused) return; if (self.shootCooldown > 0) { self.shootCooldown--; } var dx = playerTank.x - self.x; var dy = playerTank.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); // Move toward player when they can see them (within range) if (distance < 350) { var moveX = dx > 0 ? self.speed : -self.speed; var moveY = dy > 0 ? self.speed : -self.speed; var newX = self.x + moveX; var newY = self.y + moveY; // Calculate target angle for rotation var targetAngle = Math.atan2(dy, dx); // Stop any existing rotation tween tween.stop(self, { rotation: true }); // Smoothly rotate the tank to face the movement direction tween(self, { rotation: targetAngle }, { duration: 300, easing: tween.easeOut }); if (!checkWallCollision(newX, self.y)) { self.x = newX; } if (!checkWallCollision(self.x, newY)) { self.y = newY; } } if (distance < 250 && self.shootCooldown <= 0) { var length = Math.sqrt(dx * dx + dy * dy); var dirX = dx / length; var dirY = dy / length; var dynamite = new Dynamite(); dynamite.x = self.x; dynamite.y = self.y; dynamite.directionX = dirX; dynamite.directionY = dirY; dynamites.push(dynamite); game.addChild(dynamite); self.shootCooldown = 120; LK.getSound('shoot').play(); } }; return self; }); var SkinTank = Container.expand(function () { var self = Container.call(this); var tankGraphics = self.attachAsset('skinTank', { anchorX: 0.5, anchorY: 0.5 }); self.health = 50; self.speed = 1.5; self.shootCooldown = 0; self.explosionRadius = 100; self.lastPlayerX = 0; self.lastPlayerY = 0; self.update = function () { if (gamePaused) return; if (self.shootCooldown > 0) { self.shootCooldown--; } var dx = playerTank.x - self.x; var dy = playerTank.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 150) { var moveX = dx > 0 ? self.speed : -self.speed; var moveY = dy > 0 ? self.speed : -self.speed; var newX = self.x + moveX; var newY = self.y + moveY; // Calculate target angle for rotation var targetAngle = Math.atan2(dy, dx); // Stop any existing rotation tween tween.stop(self, { rotation: true }); // Smoothly rotate the tank to face the movement direction tween(self, { rotation: targetAngle }, { duration: 300, easing: tween.easeOut }); if (!checkWallCollision(newX, self.y)) { self.x = newX; } if (!checkWallCollision(self.x, newY)) { self.y = newY; } } if (distance < 300 && self.shootCooldown <= 0) { var length = Math.sqrt(dx * dx + dy * dy); var dirX = dx / length; var dirY = dy / length; var bullet = new EnemyBullet(); bullet.x = self.x; bullet.y = self.y; bullet.directionX = dirX; bullet.directionY = dirY; bullet.damage = 3; enemyBullets.push(bullet); game.addChild(bullet); self.shootCooldown = 90; LK.getSound('shoot').play(); } }; return self; }); var Wall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('wall', { anchorX: 0.5, anchorY: 0.5 }); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2F4F2F }); /**** * Game Code ****/ var gridWidth = 32; var gridHeight = 42; var cellSize = 64; var walls = []; var skinTanks = []; var redTanks = []; var greenTanks = []; var playerBullets = []; var enemyBullets = []; var dynamites = []; var acidBombs = []; var explosions = []; var medkits = []; var playerTank; var portal; var currentLevel = 1; var gameStarted = false; var isDragging = false; var gamePaused = false; var nextLevelScreen = new Container(); nextLevelScreen.visible = false; LK.gui.center.addChild(nextLevelScreen); // Next level screen background var nextLevelBackground = LK.getAsset('wall', { anchorX: 0.5, anchorY: 0.5, scaleX: 12, scaleY: 8, tint: 0x000000, alpha: 0.9 }); nextLevelScreen.addChild(nextLevelBackground); // Next level button var nextLevelButton = new Text2('NEXT LEVEL', { size: 80, fill: 0xFFFFFF, font: "monospace" }); nextLevelButton.anchor.set(0.5, 0.5); nextLevelButton.x = 0; nextLevelButton.y = 0; nextLevelScreen.addChild(nextLevelButton); // Next level button click handler nextLevelButton.down = function (x, y, obj) { nextLevelScreen.visible = false; gamePaused = false; // Generate new level startLevel(); }; var healthBarBackground = LK.getAsset('wall', { anchorX: 0, anchorY: 1, scaleX: 4, scaleY: 0.8, tint: 0x333333 }); LK.gui.bottomLeft.addChild(healthBarBackground); var healthBarFill = LK.getAsset('wall', { anchorX: 0, anchorY: 1, scaleX: 4, scaleY: 0.8, tint: 0x00ff00 }); LK.gui.bottomLeft.addChild(healthBarFill); var levelText = new Text2('Level: 1', { size: 50, fill: 0xFFFFFF, font: "monospace" }); levelText.anchor.set(0.5, 0); LK.gui.top.addChild(levelText); var scoreText = new Text2('Score: 0', { size: 40, fill: 0xFFFFFF, font: "monospace" }); scoreText.anchor.set(0.5, 0); scoreText.x = 0; scoreText.y = 80; LK.gui.top.addChild(scoreText); var bestScoreText = new Text2('Best: ' + (storage.bestScore || 0), { size: 35, fill: 0xFFFF00, font: "monospace" }); bestScoreText.anchor.set(0.5, 0); bestScoreText.x = 0; bestScoreText.y = 130; LK.gui.top.addChild(bestScoreText); // Achievement button var achievementButton = new Text2('ACHIEVEMENTS', { size: 30, fill: 0xFFFFFF, font: "monospace" }); achievementButton.anchor.set(1, 0); LK.gui.topRight.addChild(achievementButton); // Achievement menu (initially hidden) var achievementMenu = new Container(); achievementMenu.visible = false; LK.gui.center.addChild(achievementMenu); // Achievement menu background var menuBackground = LK.getAsset('wall', { anchorX: 0.5, anchorY: 0.5, scaleX: 15, scaleY: 20, tint: 0x000000, alpha: 0.8 }); achievementMenu.addChild(menuBackground); // Achievement title background var titleBackground = LK.getAsset('wall', { anchorX: 0.5, anchorY: 0.5, scaleX: 8, scaleY: 1.5, tint: 0x000000, alpha: 0.9 }); titleBackground.x = 0; titleBackground.y = -400; achievementMenu.addChild(titleBackground); // Achievement title var achievementTitle = new Text2('ACHIEVEMENTS', { size: 60, fill: 0xFFFF00, font: "monospace" }); achievementTitle.anchor.set(0.5, 0.5); achievementTitle.x = 0; achievementTitle.y = -400; achievementMenu.addChild(achievementTitle); // Initialize achievements in storage if they don't exist var achievements = storage.achievements || { killAllEnemies: false, useFirstMedkit: false, killFirstEnemy: false, finishWithoutDying: false, get150Score: false, beatPreviousBest: false, arriveAtLevel3: false, kill50EnemiesTotal: false }; storage.achievements = achievements; // Achievement tracking variables var totalEnemiesAtStart = 0; var hasUsedMedkit = false; var hasKilledEnemy = false; var hasBeenHurt = false; var totalEnemiesKilled = storage.totalEnemiesKilled || 0; // Achievement text elements var achievement1Text = new Text2('', { size: 40, fill: 0xFFFFFF, font: "monospace" }); achievement1Text.anchor.set(0, 0.5); achievement1Text.x = -300; achievement1Text.y = -200; achievementMenu.addChild(achievement1Text); var achievement2Text = new Text2('', { size: 40, fill: 0xFFFFFF, font: "monospace" }); achievement2Text.anchor.set(0, 0.5); achievement2Text.x = -300; achievement2Text.y = -100; achievementMenu.addChild(achievement2Text); var achievement3Text = new Text2('', { size: 40, fill: 0xFFFFFF, font: "monospace" }); achievement3Text.anchor.set(0, 0.5); achievement3Text.x = -300; achievement3Text.y = 0; achievementMenu.addChild(achievement3Text); var achievement4Text = new Text2('', { size: 40, fill: 0xFFFFFF, font: "monospace" }); achievement4Text.anchor.set(0, 0.5); achievement4Text.x = -300; achievement4Text.y = 100; achievementMenu.addChild(achievement4Text); var achievement5Text = new Text2('', { size: 40, fill: 0xFFFFFF, font: "monospace" }); achievement5Text.anchor.set(0, 0.5); achievement5Text.x = -300; achievement5Text.y = 200; achievementMenu.addChild(achievement5Text); var achievement6Text = new Text2('', { size: 40, fill: 0xFFFFFF, font: "monospace" }); achievement6Text.anchor.set(0, 0.5); achievement6Text.x = -300; achievement6Text.y = 300; achievementMenu.addChild(achievement6Text); var achievement7Text = new Text2('', { size: 40, fill: 0xFFFFFF, font: "monospace" }); achievement7Text.anchor.set(0, 0.5); achievement7Text.x = -300; achievement7Text.y = 400; achievementMenu.addChild(achievement7Text); var achievement8Text = new Text2('', { size: 40, fill: 0xFFFFFF, font: "monospace" }); achievement8Text.anchor.set(0, 0.5); achievement8Text.x = -300; achievement8Text.y = 500; achievementMenu.addChild(achievement8Text); function updateAchievementTexts() { achievement1Text.setText('Kill all enemies in map - ' + (achievements.killAllEnemies ? 'DONE' : 'NOT DONE')); achievement2Text.setText('Use your first MedKit - ' + (achievements.useFirstMedkit ? 'DONE' : 'NOT DONE')); achievement3Text.setText('Kill your first enemy - ' + (achievements.killFirstEnemy ? 'DONE' : 'NOT DONE')); achievement4Text.setText('Finish a level without dying - ' + (achievements.finishWithoutDying ? 'DONE' : 'NOT DONE')); achievement5Text.setText('Get 150 Score - ' + (achievements.get150Score ? 'DONE' : 'NOT DONE')); achievement6Text.setText('Beat previous best score - ' + (achievements.beatPreviousBest ? 'DONE' : 'NOT DONE')); achievement7Text.setText('Arrive at level 3 - ' + (achievements.arriveAtLevel3 ? 'DONE' : 'NOT DONE')); achievement8Text.setText('Kill 50 Enemies in Total - ' + (achievements.kill50EnemiesTotal ? 'DONE' : 'NOT DONE')); // Set colors for achievement text - green for DONE, red for NOT DONE if (achievements.killAllEnemies) { achievement1Text.fill = 0x00FF00; achievement1Text.tint = 0x00FF00; } else { achievement1Text.fill = 0xFF0000; achievement1Text.tint = 0xFF0000; } if (achievements.useFirstMedkit) { achievement2Text.fill = 0x00FF00; achievement2Text.tint = 0x00FF00; } else { achievement2Text.fill = 0xFF0000; achievement2Text.tint = 0xFF0000; } if (achievements.killFirstEnemy) { achievement3Text.fill = 0x00FF00; achievement3Text.tint = 0x00FF00; } else { achievement3Text.fill = 0xFF0000; achievement3Text.tint = 0xFF0000; } if (achievements.finishWithoutDying) { achievement4Text.fill = 0x00FF00; achievement4Text.tint = 0x00FF00; } else { achievement4Text.fill = 0xFF0000; achievement4Text.tint = 0xFF0000; } if (achievements.get150Score) { achievement5Text.fill = 0x00FF00; achievement5Text.tint = 0x00FF00; } else { achievement5Text.fill = 0xFF0000; achievement5Text.tint = 0xFF0000; } if (achievements.beatPreviousBest) { achievement6Text.fill = 0x00FF00; achievement6Text.tint = 0x00FF00; } else { achievement6Text.fill = 0xFF0000; achievement6Text.tint = 0xFF0000; } if (achievements.arriveAtLevel3) { achievement7Text.fill = 0x00FF00; achievement7Text.tint = 0x00FF00; } else { achievement7Text.fill = 0xFF0000; achievement7Text.tint = 0xFF0000; } if (achievements.kill50EnemiesTotal) { achievement8Text.fill = 0x00FF00; achievement8Text.tint = 0x00FF00; } else { achievement8Text.fill = 0xFF0000; achievement8Text.tint = 0xFF0000; } } // Initial text update updateAchievementTexts(); // Achievement button click handler achievementButton.down = function (x, y, obj) { achievementMenu.visible = !achievementMenu.visible; gamePaused = achievementMenu.visible; updateAchievementTexts(); }; // Close menu when clicking background menuBackground.down = function (x, y, obj) { achievementMenu.visible = false; gamePaused = false; }; function generateMaze() { walls = []; var playerTankX = 1024; var playerTankY = 1366; for (var x = 0; x < gridWidth; x++) { for (var y = 0; y < gridHeight; y++) { var wallX = x * cellSize + cellSize / 2; var wallY = y * cellSize + cellSize / 2; // Check if this wall position would be too close to player tank position var dx = Math.abs(wallX - playerTankX); var dy = Math.abs(wallY - playerTankY); var isNearPlayerTank = dx < 64 && dy < 64; // Within one cell distance if (x === 0 || x === gridWidth - 1 || y === 0 || y === gridHeight - 1) { if (!isNearPlayerTank) { var wall = new Wall(); wall.x = wallX; wall.y = wallY; walls.push(wall); game.addChild(wall); } } else if (Math.random() < 0.3 && !isNearPlayerTank) { var wall = new Wall(); wall.x = wallX; wall.y = wallY; walls.push(wall); game.addChild(wall); } } } } function spawnEnemies() { var skinCount = Math.floor(Math.random() * 6) + 10; // 10-15 skin tanks var redCount = Math.floor(Math.random() * 6) + 5; // 5-10 red tanks var greenCount = Math.floor(Math.random() * 6) + 7; // 7-12 green tanks for (var i = 0; i < skinCount; i++) { var tank = new SkinTank(); do { tank.x = Math.random() * (2048 - 200) + 100; tank.y = Math.random() * (2732 - 200) + 100; } while (checkWallCollision(tank.x, tank.y) || getDistanceToPlayer(tank.x, tank.y) < 640); skinTanks.push(tank); game.addChild(tank); } for (var i = 0; i < redCount; i++) { var tank = new RedTank(); do { tank.x = Math.random() * (2048 - 200) + 100; tank.y = Math.random() * (2732 - 200) + 100; } while (checkWallCollision(tank.x, tank.y) || getDistanceToPlayer(tank.x, tank.y) < 640); redTanks.push(tank); game.addChild(tank); } for (var i = 0; i < greenCount; i++) { var tank = new GreenTank(); do { tank.x = Math.random() * (2048 - 200) + 100; tank.y = Math.random() * (2732 - 200) + 100; } while (checkWallCollision(tank.x, tank.y) || getDistanceToPlayer(tank.x, tank.y) < 640); greenTanks.push(tank); game.addChild(tank); } } function checkWallCollision(x, y) { for (var i = 0; i < walls.length; i++) { var wall = walls[i]; var dx = Math.abs(x - wall.x); var dy = Math.abs(y - wall.y); if (dx < 32 && dy < 32) { return true; } } return false; } function getDistanceToPlayer(x, y) { if (!playerTank) { return 1000; } var dx = x - playerTank.x; var dy = y - playerTank.y; return Math.sqrt(dx * dx + dy * dy); } function spawnMedkits() { var medkitCount = Math.floor(Math.random() * 4) + 3; // 3-6 medkits per level for (var i = 0; i < medkitCount; i++) { var medkit = new Medkit(); do { medkit.x = Math.random() * (2048 - 200) + 100; medkit.y = Math.random() * (2732 - 200) + 100; } while (checkWallCollision(medkit.x, medkit.y) || getDistanceToPlayer(medkit.x, medkit.y) < 150); medkits.push(medkit); game.addChild(medkit); } } function createExplosion(x, y, radius, damage) { var explosion = LK.getAsset('explosion', { anchorX: 0.5, anchorY: 0.5, x: x, y: y, scaleX: radius / 60, scaleY: radius / 60, alpha: 0.8 }); game.addChild(explosion); explosions.push(explosion); tween(explosion, { alpha: 0, scaleX: explosion.scaleX * 1.5, scaleY: explosion.scaleY * 1.5 }, { duration: 500, onFinish: function onFinish() { explosion.destroy(); var index = explosions.indexOf(explosion); if (index > -1) { explosions.splice(index, 1); } } }); var dx = playerTank.x - x; var dy = playerTank.y - y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < radius) { playerTank.health -= damage; LK.getSound('hit').play(); // Track that player has been hurt hasBeenHurt = true; if (playerTank.health <= 0) { LK.showGameOver(); } } LK.getSound('explosion').play(); } function startLevel() { for (var i = walls.length - 1; i >= 0; i--) { walls[i].destroy(); } walls = []; for (var i = skinTanks.length - 1; i >= 0; i--) { skinTanks[i].destroy(); } skinTanks = []; for (var i = redTanks.length - 1; i >= 0; i--) { redTanks[i].destroy(); } redTanks = []; for (var i = greenTanks.length - 1; i >= 0; i--) { greenTanks[i].destroy(); } greenTanks = []; for (var i = medkits.length - 1; i >= 0; i--) { medkits[i].destroy(); } medkits = []; generateMaze(); spawnEnemies(); spawnMedkits(); // Track total enemies for achievement totalEnemiesAtStart = skinTanks.length + redTanks.length + greenTanks.length; // Reset achievement tracking variables hasUsedMedkit = false; hasKilledEnemy = false; hasBeenHurt = false; // Only create player tank if it doesn't exist (first level) if (!playerTank) { playerTank = new PlayerTank(); playerTank.x = 1024; playerTank.y = 1366; playerTank.health = 100; game.addChild(playerTank); } else { // Just reset position and health for existing player tank playerTank.x = 1024; playerTank.y = 1366; playerTank.health = 100; } portal = new Portal(); do { portal.x = Math.random() * (2048 - 200) + 100; portal.y = Math.random() * (2732 - 200) + 100; } while (checkWallCollision(portal.x, portal.y) || getDistanceToPlayer(portal.x, portal.y) < 300); game.addChild(portal); levelText.setText('Level: ' + currentLevel); gameStarted = true; // Achievement: Arrive at level 3 if (currentLevel >= 3 && !achievements.arriveAtLevel3) { achievements.arriveAtLevel3 = true; storage.achievements = achievements; } } // Mouse functionality - player tank follows mouse position game.down = function (x, y, obj) { // Only start dragging if mouse is pressed on the player tank and achievements menu is not visible if (playerTank && playerTank.x && playerTank.y && !achievementMenu.visible) { var dx = x - playerTank.x; var dy = y - playerTank.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance <= 60) { // Within tank radius (tank is 120px wide, so radius ~60) isDragging = true; } } }; game.move = function (x, y, obj) { if (!gameStarted || !playerTank || !isDragging || achievementMenu.visible) { return; } // Only allow dragging if mouse is not on a wall if (checkWallCollision(x, y)) { isDragging = false; // Stop dragging when mouse is on wall return; } // Calculate direction from tank to mouse for rotation var dx = x - playerTank.x; var dy = y - playerTank.y; var targetAngle = Math.atan2(dy, dx); // Stop any existing rotation tween tween.stop(playerTank, { rotation: true }); // Smoothly rotate the tank to face the mouse direction tween(playerTank, { rotation: targetAngle }, { duration: 200, easing: tween.easeOut }); // Move player tank directly to mouse position if no wall collision playerTank.x = x; playerTank.y = y; }; game.up = function (x, y, obj) { isDragging = false; if (!gameStarted || !playerTank || achievementMenu.visible) { return; } if (playerTank.shootCooldown <= 0) { var dx = x - playerTank.x; var dy = y - playerTank.y; var length = Math.sqrt(dx * dx + dy * dy); if (length > 0) { var dirX = dx / length; var dirY = dy / length; var bullet = new PlayerBullet(); bullet.x = playerTank.x; bullet.y = playerTank.y; bullet.directionX = dirX; bullet.directionY = dirY; playerBullets.push(bullet); game.addChild(bullet); playerTank.shootCooldown = 15; LK.getSound('shoot').play(); } } }; game.update = function () { if (!gameStarted) { startLevel(); return; } if (gamePaused) return; // Movement is handled via touch/drag in game.move method for (var i = playerBullets.length - 1; i >= 0; i--) { var bullet = playerBullets[i]; if (bullet.x < 0 || bullet.x > 2048 || bullet.y < 0 || bullet.y > 2732) { bullet.destroy(); playerBullets.splice(i, 1); continue; } if (checkWallCollision(bullet.x, bullet.y)) { bullet.destroy(); playerBullets.splice(i, 1); continue; } for (var j = skinTanks.length - 1; j >= 0; j--) { if (bullet.intersects(skinTanks[j])) { skinTanks[j].health -= 3; bullet.destroy(); playerBullets.splice(i, 1); if (skinTanks[j].health <= 0) { createExplosion(skinTanks[j].x, skinTanks[j].y, 100, 15); skinTanks[j].destroy(); skinTanks.splice(j, 1); LK.setScore(LK.getScore() + 10); // Track total enemies killed totalEnemiesKilled++; storage.totalEnemiesKilled = totalEnemiesKilled; // Achievement: Kill first enemy if (!hasKilledEnemy) { hasKilledEnemy = true; achievements.killFirstEnemy = true; storage.achievements = achievements; } // Achievement: Kill 50 enemies total if (totalEnemiesKilled >= 50 && !achievements.kill50EnemiesTotal) { achievements.kill50EnemiesTotal = true; storage.achievements = achievements; } } break; } } for (var j = redTanks.length - 1; j >= 0; j--) { if (bullet.intersects(redTanks[j])) { redTanks[j].health -= 10; bullet.destroy(); playerBullets.splice(i, 1); if (redTanks[j].health <= 0) { redTanks[j].destroy(); redTanks.splice(j, 1); LK.setScore(LK.getScore() + 20); // Track total enemies killed totalEnemiesKilled++; storage.totalEnemiesKilled = totalEnemiesKilled; // Achievement: Kill first enemy if (!hasKilledEnemy) { hasKilledEnemy = true; achievements.killFirstEnemy = true; storage.achievements = achievements; } // Achievement: Kill 50 enemies total if (totalEnemiesKilled >= 50 && !achievements.kill50EnemiesTotal) { achievements.kill50EnemiesTotal = true; storage.achievements = achievements; } } break; } } for (var j = greenTanks.length - 1; j >= 0; j--) { if (bullet.intersects(greenTanks[j])) { greenTanks[j].health -= 25; bullet.destroy(); playerBullets.splice(i, 1); if (greenTanks[j].health <= 0) { greenTanks[j].destroy(); greenTanks.splice(j, 1); LK.setScore(LK.getScore() + 30); // Track total enemies killed totalEnemiesKilled++; storage.totalEnemiesKilled = totalEnemiesKilled; // Achievement: Kill first enemy if (!hasKilledEnemy) { hasKilledEnemy = true; achievements.killFirstEnemy = true; storage.achievements = achievements; } // Achievement: Kill 50 enemies total if (totalEnemiesKilled >= 50 && !achievements.kill50EnemiesTotal) { achievements.kill50EnemiesTotal = true; storage.achievements = achievements; } } break; } } } for (var i = enemyBullets.length - 1; i >= 0; i--) { var bullet = enemyBullets[i]; if (bullet.x < 0 || bullet.x > 2048 || bullet.y < 0 || bullet.y > 2732) { bullet.destroy(); enemyBullets.splice(i, 1); continue; } if (checkWallCollision(bullet.x, bullet.y)) { bullet.destroy(); enemyBullets.splice(i, 1); continue; } if (bullet.intersects(playerTank)) { playerTank.health -= bullet.damage; bullet.destroy(); enemyBullets.splice(i, 1); LK.getSound('hit').play(); // Track that player has been hurt hasBeenHurt = true; if (playerTank.health <= 0) { LK.showGameOver(); } continue; } } for (var i = dynamites.length - 1; i >= 0; i--) { var dynamite = dynamites[i]; if (dynamite.x < 0 || dynamite.x > 2048 || dynamite.y < 0 || dynamite.y > 2732) { createExplosion(dynamite.x, dynamite.y, dynamite.explosionRadius, dynamite.damage); dynamite.destroy(); dynamites.splice(i, 1); continue; } if (checkWallCollision(dynamite.x, dynamite.y)) { createExplosion(dynamite.x, dynamite.y, dynamite.explosionRadius, dynamite.damage); dynamite.destroy(); dynamites.splice(i, 1); continue; } if (dynamite.intersects(playerTank)) { createExplosion(dynamite.x, dynamite.y, dynamite.explosionRadius, dynamite.damage); dynamite.destroy(); dynamites.splice(i, 1); continue; } } for (var i = acidBombs.length - 1; i >= 0; i--) { var acidBomb = acidBombs[i]; if (acidBomb.x < 0 || acidBomb.x > 2048 || acidBomb.y < 0 || acidBomb.y > 2732) { acidBomb.destroy(); acidBombs.splice(i, 1); continue; } if (checkWallCollision(acidBomb.x, acidBomb.y)) { acidBomb.destroy(); acidBombs.splice(i, 1); continue; } if (acidBomb.intersects(playerTank)) { playerTank.health -= acidBomb.damage; playerTank.poisonTimer = acidBomb.poisonDuration; playerTank.poisonDamage = acidBomb.poisonDamage; acidBomb.destroy(); acidBombs.splice(i, 1); LK.getSound('hit').play(); // Track that player has been hurt hasBeenHurt = true; if (playerTank.health <= 0) { LK.showGameOver(); } continue; } } for (var i = skinTanks.length - 1; i >= 0; i--) { if (skinTanks[i].intersects(playerTank)) { createExplosion(skinTanks[i].x, skinTanks[i].y, skinTanks[i].explosionRadius, 20); skinTanks[i].destroy(); skinTanks.splice(i, 1); } } for (var i = redTanks.length - 1; i >= 0; i--) { if (redTanks[i].intersects(playerTank)) { // Check if any part of player is within circular explosion area (radius 100) // Player tank is 120px wide, so radius is 60px var dx = playerTank.x - redTanks[i].x; var dy = playerTank.y - redTanks[i].y; var distance = Math.sqrt(dx * dx + dy * dy); var playerRadius = 60; // Half of player tank width (120px) var explosionRadius = 100; // Check if there's a clear path from explosion center to player (no walls blocking) var canDamagePlayer = true; var stepSize = 32; // Check every 32 pixels along the path var steps = Math.ceil(distance / stepSize); for (var step = 1; step <= steps; step++) { var checkX = redTanks[i].x + dx * step / steps; var checkY = redTanks[i].y + dy * step / steps; if (checkWallCollision(checkX, checkY)) { canDamagePlayer = false; break; } } if (distance <= explosionRadius + playerRadius && canDamagePlayer) { // Any part of player is within explosion radius and no walls block - deal 70 damage playerTank.health -= 70; LK.getSound('hit').play(); hasBeenHurt = true; if (playerTank.health <= 0) { LK.showGameOver(); } } createExplosion(redTanks[i].x, redTanks[i].y, 100, 0); // No additional damage from explosion redTanks[i].destroy(); redTanks.splice(i, 1); } } // Check medkit collision for healing for (var i = medkits.length - 1; i >= 0; i--) { var medkit = medkits[i]; var dx = playerTank.x - medkit.x; var dy = playerTank.y - medkit.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 50 && playerTank.health < playerTank.maxHealth) { // Close enough to collect medkit and player needs healing playerTank.health = playerTank.maxHealth; // Restore to full health medkit.destroy(); medkits.splice(i, 1); LK.getSound('hit').play(); // Use existing sound for medkit pickup // Achievement: Use first medkit if (!hasUsedMedkit) { hasUsedMedkit = true; achievements.useFirstMedkit = true; storage.achievements = achievements; } } } // Check if player is close to portal (within 100 pixels) var dx = playerTank.x - portal.x; var dy = playerTank.y - portal.y; var distanceToPortal = Math.sqrt(dx * dx + dy * dy); if (distanceToPortal < 100) { // Achievement: Kill all enemies in map var totalEnemiesRemaining = skinTanks.length + redTanks.length + greenTanks.length; if (totalEnemiesRemaining === 0) { achievements.killAllEnemies = true; storage.achievements = achievements; } // Achievement: Finish without dying if (!hasBeenHurt) { achievements.finishWithoutDying = true; storage.achievements = achievements; } LK.getSound('win').play(); // Clear current level enemies and bullets for (var i = playerBullets.length - 1; i >= 0; i--) { playerBullets[i].destroy(); } playerBullets = []; for (var i = enemyBullets.length - 1; i >= 0; i--) { enemyBullets[i].destroy(); } enemyBullets = []; for (var i = dynamites.length - 1; i >= 0; i--) { dynamites[i].destroy(); } dynamites = []; for (var i = acidBombs.length - 1; i >= 0; i--) { acidBombs[i].destroy(); } acidBombs = []; for (var i = explosions.length - 1; i >= 0; i--) { explosions[i].destroy(); } explosions = []; // Remove current portal portal.destroy(); // Advance to next level currentLevel++; // Show next level screen nextLevelScreen.visible = true; gamePaused = true; } // Update score display scoreText.setText('Score: ' + LK.getScore()); // Update best score if current score is higher var currentScore = LK.getScore(); var bestScore = storage.bestScore || 0; if (currentScore > bestScore) { storage.bestScore = currentScore; bestScoreText.setText('Best: ' + currentScore); // Achievement: Beat previous best score if (bestScore > 0) { achievements.beatPreviousBest = true; storage.achievements = achievements; } } // Achievement: Get 150 Score if (currentScore >= 150 && !achievements.get150Score) { achievements.get150Score = true; storage.achievements = achievements; } var healthPercentage = Math.max(0, playerTank.health) / 100; healthBarFill.scaleX = 4 * healthPercentage; if (healthPercentage > 0.6) { healthBarFill.tint = 0x00ff00; // Green } else if (healthPercentage > 0.3) { healthBarFill.tint = 0xffff00; // Yellow } else { healthBarFill.tint = 0xff0000; // Red } };
===================================================================
--- original.js
+++ change.js
@@ -824,10 +824,10 @@
}
}
// Mouse functionality - player tank follows mouse position
game.down = function (x, y, obj) {
- // Only start dragging if mouse is pressed on the player tank
- if (playerTank && playerTank.x && playerTank.y) {
+ // Only start dragging if mouse is pressed on the player tank and achievements menu is not visible
+ if (playerTank && playerTank.x && playerTank.y && !achievementMenu.visible) {
var dx = x - playerTank.x;
var dy = y - playerTank.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance <= 60) {
@@ -836,9 +836,9 @@
}
}
};
game.move = function (x, y, obj) {
- if (!gameStarted || !playerTank || !isDragging) {
+ if (!gameStarted || !playerTank || !isDragging || achievementMenu.visible) {
return;
}
// Only allow dragging if mouse is not on a wall
if (checkWallCollision(x, y)) {
@@ -865,9 +865,9 @@
playerTank.y = y;
};
game.up = function (x, y, obj) {
isDragging = false;
- if (!gameStarted || !playerTank) {
+ if (!gameStarted || !playerTank || achievementMenu.visible) {
return;
}
if (playerTank.shootCooldown <= 0) {
var dx = x - playerTank.x;
pixel art dynamite. In-Game asset. 2d. High contrast. No shadows
skin color tank pixel art top down. In-Game asset. 2d. High contrast. No shadows
green tank pixel art top down. In-Game asset. 2d. High contrast. No shadows
red tank pixel art top down. In-Game asset. 2d. High contrast. No shadows
blue tank pixel art top down. In-Game asset. 2d. High contrast. No shadows
pixel art bullet. In-Game asset. 2d. High contrast. No shadows
a green bomb (pixel art) writes "Acid" on it. In-Game asset. 2d. High contrast. No shadows
medkit pixel art. In-Game asset. 2d. High contrast. No shadows
dark green square 16*16 pixels pixel art. In-Game asset. 2d. High contrast. No shadows
orange circle pixel art. In-Game asset. 2d. High contrast. No shadows
A portal, outline is purple, and inside is magenta. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat pixel art
dark gray square 16*16 pixels pixel art.. In-Game asset. 2d. High contrast. No shadows
pixel art blackhole. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat