User prompt
flykoopa is not spawning
User prompt
add a flykoopa enemy also with 2 frames. this enemy will appear in the air in different heights too
User prompt
coins shoudl be at different hehigt untill the top of the screen
User prompt
coins shouldnot keep moving when player is killed
User prompt
Please fix the bug: 'TypeError: coins[k].update is not a function' in or related to this line: 'coins[k].update();' Line Number: 377
User prompt
coins should not move
User prompt
spawn coins also, but the player will need to jump to catch them
User prompt
still a little high
User prompt
goomba seems to be flying, not right on top of the floor
User prompt
rename mushroom to goomba
User prompt
rename enemy2 to turtle2
User prompt
rename enemy1 to turtle1
User prompt
rename enemy1 to turtle
User prompt
move mushroom enemy 20 pixels down
User prompt
add a new enemy type, mushroom, will also have 2 animations
User prompt
ensure player cant harm enemy after being killed
User prompt
if enemy killed player then player cant kill enemy
User prompt
Almos there, looks like the player after being killed it pops up, but then stays up instead of keep on going down offscreen.
User prompt
when player is killed use the same animation as when an enemy is killed
User prompt
Please fix the bug: 'ReferenceError: tween is not defined' in or related to this line: 'tween(player, {' Line Number: 276 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
add tween to make player pop up and fall off the screen when killed ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
make it 3 seconds from player killed to game over sing
User prompt
when player is killed stop moving the screen but keep enemy moving
User prompt
when player is killed, do not flash screen
User prompt
just play dead sound once
/**** * Classes ****/ var Background = Container.expand(function () { var self = Container.call(this); var backgrounds = ['background1', 'background2', 'background3']; var randomBackground = backgrounds[Math.floor(Math.random() * backgrounds.length)]; var backgroundGraphics = self.attachAsset(randomBackground, { anchorX: 0, anchorY: 0 }); self.speed = 3; self.update = function () { if (!game.playerDead) { self.x -= self.speed; } if (self.x <= -2048) { self.x = 2048; } }; }); var Background2 = Container.expand(function () { var self = Container.call(this); var backgrounds = ['background1', 'background2', 'background3']; var randomBackground = backgrounds[Math.floor(Math.random() * backgrounds.length)]; var backgroundGraphics = self.attachAsset(randomBackground, { anchorX: 0, anchorY: 0 }); self.speed = 3; self.update = function () { if (!game.playerDead) { self.x -= self.speed; } if (self.x <= -2048) { self.x = 2048; } }; }); var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('turtle1', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); self.speed = 6 + Math.random() * 2; self.passed = false; self.isJumping = false; self.velocityY = 0; self.groundY = 2732 - 400; // 400 pixels from bottom self.y = self.groundY; // Set initial position to ground level self.runFrames = ['turtle1', 'turtle2']; self.runFrameIndex = 0; self.runFrameCounter = 0; self.runFrameDelay = 20; self.swapSprite = function (newAsset) { var newGraphics = self.attachAsset(newAsset, { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); if (enemyGraphics) { enemyGraphics.destroy(); } enemyGraphics = newGraphics; }; self.update = function () { self.x -= self.speed; if (self.isJumping) { self.y += self.velocityY; self.velocityY += 0.5; // Gravity effect if (self.y > 2732) { self.destroy(); } } else { self.runFrameCounter++; } if (self.runFrameCounter >= self.runFrameDelay) { self.runFrameIndex = (self.runFrameIndex + 1) % self.runFrames.length; self.swapSprite(self.runFrames[self.runFrameIndex]); self.runFrameCounter = 0; } if (self.x < -100) { self.destroy(); } }; }); var GaugeBar = Container.expand(function () { var self = Container.call(this); // Background of the gauge var gaugeBackground = self.attachAsset('gauge_background', { anchorX: 0.5, // Center the background horizontally anchorY: 0.5 // Center the background vertically }); // Fill of the gauge var gaugeFill = self.attachAsset('gauge_fill', { anchorX: 0, // Anchor the fill to the left edge anchorY: 0.5 // Center the fill vertically }); self.maxWidth = gaugeFill.width; // Store the maximum width of the fill self.currentValue = 0; // Initial value gaugeFill.scaleX = 0; // Start with the gauge empty // Adjust the fill's position to align with the left edge of the background gaugeFill.x = -self.maxWidth / 2; // Offset to the left edge of the background self.updateGauge = function (value) { self.currentValue = Math.min(100, Math.max(0, value)); // Clamp value between 0 and 100 gaugeFill.scaleX = self.currentValue / 100; // Scale the fill from the left }; }); var Goomba = Container.expand(function () { var self = Container.call(this); var goombaGraphics = self.attachAsset('goomba1', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); self.speed = 4 + Math.random() * 2; self.passed = false; self.isJumping = false; self.velocityY = 0; self.groundY = 2732 - 400; // 400 pixels from bottom self.y = self.groundY; // Set initial position to ground level self.runFrames = ['goomba1', 'goomba2']; self.runFrameIndex = 0; self.runFrameCounter = 0; self.runFrameDelay = 25; self.swapSprite = function (newAsset) { var newGraphics = self.attachAsset(newAsset, { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); if (goombaGraphics) { goombaGraphics.destroy(); } goombaGraphics = newGraphics; }; self.update = function () { self.x -= self.speed; if (self.isJumping) { self.y += self.velocityY; self.velocityY += 0.5; // Gravity effect if (self.y > 2732) { self.destroy(); } } else { self.runFrameCounter++; } if (self.runFrameCounter >= self.runFrameDelay) { self.runFrameIndex = (self.runFrameIndex + 1) % self.runFrames.length; self.swapSprite(self.runFrames[self.runFrameIndex]); self.runFrameCounter = 0; } if (self.x < -100) { self.destroy(); } }; }); var Player = Container.expand(function () { var self = Container.call(this); var currentSprite = self.attachAsset('player_run1', { anchorX: 0.5, anchorY: 0.5, visible: true, scaleX: 1.5, scaleY: 1.5 }); var nextSprite = self.attachAsset('player_run1', { anchorX: 0.5, anchorY: 0.5, visible: false, scaleX: 1.5, scaleY: 1.5 }); self.currentAsset = 'player_run1'; self.speed = 5; self.jumpHeight = 25; self.isJumping = false; self.velocityY = 0; self.groundY = 2732 - 400; // 400 pixels from bottom self.y = self.groundY; // Set initial position to ground level self.runFrames = ['player_run1', 'player_run2', 'player_run3']; self.runFrameIndex = 0; self.runFrameCounter = 0; self.runFrameDelay = 15; self.swapSprite = function (newAsset) { if (self.currentAsset !== newAsset) { nextSprite = self.attachAsset(newAsset, { anchorX: 0.5, anchorY: 0.5, visible: true, scaleX: 1.5, scaleY: 1.5 }); currentSprite.visible = false; currentSprite.destroy(); currentSprite = nextSprite; self.currentAsset = newAsset; } }; self.update = function () { if (self.isJumping) { self.y += self.velocityY; self.velocityY += 0.3; if (self.y >= self.groundY - 30) { if (self.y < 0) { // Prevent jump from exceeding the top of the screen self.y = 0; self.velocityY = 0; } if (!self.isDead) { self.y = self.groundY - 30; self.isJumping = false; self.velocityY = 0; self.swapSprite(self.runFrames[self.runFrameIndex]); } } } else { self.runFrameCounter++; if (self.runFrameCounter >= self.runFrameDelay) { self.runFrameIndex = (self.runFrameIndex + 1) % self.runFrames.length; self.swapSprite(self.runFrames[self.runFrameIndex]); self.runFrameCounter = 0; } } }; self.jump = function () { if (!self.isJumping) { self.isJumping = true; LK.getSound('jump').play(); self.velocityY = -self.jumpHeight; self.swapSprite('player_jump'); self.runFrameCounter = 0; } }; }); /**** * Initialize Game ****/ /**** *-Seperator- ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ LK.playMusic('theme'); var background = game.addChild(new Background()); background.x = 0; background.y = 0; var background2 = game.addChild(new Background2()); background2.x = 2048; background2.y = 0; var player = game.addChild(new Player()); player.x = 2048 / 4; player.y = player.groundY - 30; // Use groundY for initial position and move 30 pixels higher var enemies = []; var enemySpawnInterval = 80; var enemySpawnCounter = 0; var gaugeBar = game.addChild(new GaugeBar()); gaugeBar.x = 2048 / 2; gaugeBar.y = 100; var scoreText = new Text2('0', { size: 100, fill: 0xFFFFFF }); LK.gui.top.addChild(scoreText); scoreText.x = 2048 / 2; scoreText.y = 50; game.update = function () { background.update(); background2.update(); player.update(); enemySpawnCounter++; if (enemySpawnCounter >= enemySpawnInterval) { var enemyType = Math.random() < 0.5 ? 'Enemy' : 'Goomba'; var enemy; if (enemyType === 'Enemy') { enemy = new Enemy(); } else { enemy = new Goomba(); } enemy.x = 2048 + Math.random() * 200; enemy.y = enemy.groundY; // Use groundY for initial position enemies.push(enemy); game.addChild(enemy); enemySpawnInterval = Math.floor(Math.random() * 100) + 60; enemySpawnCounter = 0; } for (var j = enemies.length - 1; j >= 0; j--) { enemies[j].update(); if (player.intersects(enemies[j])) { if (!player.isDead && player.isJumping && player.velocityY > 0 && player.y < enemies[j].y) { // Player is falling and lands on enemy enemies[j].velocityY = -10; // Pop up effect LK.getSound('stomp').play(); // Play stomp sound enemies[j].isJumping = true; enemies[j].canHarmPlayer = false; // Enemy can no longer harm player } else if (enemies[j].canHarmPlayer !== false) { if (!player.isDead && enemies[j].canHarmPlayer !== false) { LK.getSound('dead').play(); // Play dead sound player.isDead = true; game.playerDead = true; player.velocityY = -10; // Pop up effect similar to enemy player.isJumping = true; LK.setTimeout(function () { LK.showGameOver(); }, 3000); // Delay game over by 3 seconds } } } else if (player.x > enemies[j].x && !enemies[j].passed) { enemies[j].passed = true; LK.setScore(LK.getScore() + 1); scoreText.setText(LK.getScore()); } if (enemies[j].x < -100) { enemies.splice(j, 1); } } }; game.down = function (x, y, obj) { var startTime = Date.now(); var interval = LK.setInterval(function () { var elapsed = Date.now() - startTime; var newValue = Math.min(100, elapsed / 10); // Increase gauge value over time gaugeBar.updateGauge(newValue); }, 100); game.up = function () { LK.clearInterval(interval); var jumpHeight = gaugeBar.currentValue; // Adjust gauge value to be more proportional to jump height player.jumpHeight = jumpHeight / 1.5; player.jump(); gaugeBar.updateGauge(0); // Reset gauge after jump }; var jumpHeight = gaugeBar.currentValue; // Scale the gauge value to jump height player.jumpHeight = jumpHeight / 1.5; gaugeBar.updateGauge(0); // Reset gauge after jump };
===================================================================
--- original.js
+++ change.js
@@ -111,11 +111,11 @@
self.currentValue = Math.min(100, Math.max(0, value)); // Clamp value between 0 and 100
gaugeFill.scaleX = self.currentValue / 100; // Scale the fill from the left
};
});
-var Mushroom = Container.expand(function () {
+var Goomba = Container.expand(function () {
var self = Container.call(this);
- var mushroomGraphics = self.attachAsset('mushroom1', {
+ var goombaGraphics = self.attachAsset('goomba1', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
@@ -125,9 +125,9 @@
self.isJumping = false;
self.velocityY = 0;
self.groundY = 2732 - 400; // 400 pixels from bottom
self.y = self.groundY; // Set initial position to ground level
- self.runFrames = ['mushroom1', 'mushroom2'];
+ self.runFrames = ['goomba1', 'goomba2'];
self.runFrameIndex = 0;
self.runFrameCounter = 0;
self.runFrameDelay = 25;
self.swapSprite = function (newAsset) {
@@ -136,12 +136,12 @@
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
});
- if (mushroomGraphics) {
- mushroomGraphics.destroy();
+ if (goombaGraphics) {
+ goombaGraphics.destroy();
}
- mushroomGraphics = newGraphics;
+ goombaGraphics = newGraphics;
};
self.update = function () {
self.x -= self.speed;
if (self.isJumping) {
@@ -283,14 +283,14 @@
background2.update();
player.update();
enemySpawnCounter++;
if (enemySpawnCounter >= enemySpawnInterval) {
- var enemyType = Math.random() < 0.5 ? 'Enemy' : 'Mushroom';
+ var enemyType = Math.random() < 0.5 ? 'Enemy' : 'Goomba';
var enemy;
if (enemyType === 'Enemy') {
enemy = new Enemy();
} else {
- enemy = new Mushroom();
+ enemy = new Goomba();
}
enemy.x = 2048 + Math.random() * 200;
enemy.y = enemy.groundY; // Use groundY for initial position
enemies.push(enemy);