User prompt
I don't want the coins to be in the probabilty code, it should spawn coins 100% and add probabilty between the sheild and lives that are rarely spawned, not dependendt on the coins.
User prompt
Make coins to 80% and just make a condition for the lives and shield defferent from the coins ( these should spawned randomly and rarely )
User prompt
spawn coin only on the location where no obstacles are spwned.
User prompt
Add a check inside the spawning logic of obstacles the if any time the obstacle is intersect with the coin collectables, it will destroy itself.
User prompt
Coins are not visible
User prompt
Now i want to change the coin spawning logic little bit, i want to spawn the coin cluster on the path, when the obstacle group is not spawn on that path.
User prompt
if the coin is overlaping with the obstacle then remove the coin.
User prompt
Currently the coins are overlaping with the obstacles sometimes, fix the bug
User prompt
Increase the cluster size of the coins to 5, 7, 12
User prompt
Increase the spawn frequency of the coins
User prompt
Currently the coins are moving slow from left to right but the obstacles are moving fast, move the coin at the same speed
User prompt
When spawning coins, mirror the obstacle spawning logic, ensuring they appear on the path opposite to where obstacles are placed. This means: Vertical Spacing: Maintain the same vertical spacing rules used for obstacles. If an obstacle is above the top path, the corresponding coin should be placed on the bottom path, and vice-versa. Random Horizontal Placement: Similar to obstacles, introduce random horizontal spacing between coins within a defined range. However, make sure coins are not spawned too close to where obstacles are present on the opposite path to avoid immediate collection or collisions. Grouping: Consider spawning coins in small groups or clusters on the opposite path to provide an opportunity for the player to collect multiple coins in quick succession. By implementing this mirroring logic, you'll ensure that coins and obstacles are never placed on the same path simultaneously, creating a more balanced and strategic gameplay experience.
User prompt
Spawn the coins same as the obstacle but in the opposite direction of the obstacles.
User prompt
Fix the bugs of coins
User prompt
Coins are having some issue, they are spawning but despawning instantly after spawning.
User prompt
Okay now i want th coins, to be spawned in the groups( same as obstacles are spawning ) of ( 3 , 5 , 7 ); but should not overlap with each other and with the obstacles. and the speed of coins should be same as the speed of the path.
User prompt
Whenever i collet the sheild show the sheild icon on the left centre and make it show the 10s timer for the sheild and when timer ends it will remove the sheild and reset the tint of the ninja to default.
User prompt
Ewhen i am collecting other colletibles, the sheild is getting down, make the sheild strictly stay for 10s after collection, no matter what i collect after the sheild.
User prompt
when i am collecting other colletibles, the sheild is getting down, make the sheild strictly stay for 10s after collection, no matter what i collect after the sheild.
User prompt
Remove the shield effect, instead when the ninja collects the sheild make the tint of ninja to blue and make him invincible for 10s, also whenever the ninja is in the sheild mode and it hits the obstacles then distroy the obstacles ( also show the distruction effect )
User prompt
Currently when i collet the sheild the ninja is not getting the invincibility, and also when i collect the sheild and change the path the sheild effect is not moving with the ninja, make it currect and fix the issue.
User prompt
When i collect the shield it should show the Sheild effect at the location of the ninja for 10s and make the ninja invincible for 10s, after 10 sec remove the sheild effect from the ninja.
User prompt
When i collect the lives on the path it should update the display lives by one, and should show one more life on the lives display.
User prompt
Now the live is not reducing on the hitting the obstacle ( also not updating on the display )
User prompt
Fix the bugs : - I want the collectable lives and display lives class different from each other, - Collectibles should spawn in the same way, same direction, same rotation, the obstacles are spawned - Also find other bugs and fix them in the code.
/****
* Classes
****/
var Background = Container.expand(function () {
var self = Container.call(this);
var backgroundGraphics = self.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
backgroundGraphics.alpha = 0.5;
var zoomDirection = 1;
self.update = function () {
if (this.scale.x >= 1.0025) {
zoomDirection = -1;
} else if (this.scale.x <= 0.9975) {
zoomDirection = 1;
}
this.scale.x += 0.000025 * zoomDirection;
this.scale.y += 0.000025 * zoomDirection;
};
});
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.x -= 5;
if (self.x < -self.width) {
self.destroy();
}
};
});
var Dash = Container.expand(function () {
var self = Container.call(this);
var dashGraphics = self.attachAsset('dash', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.opacity = 0.4;
self.update = function () {
self.x -= self.speed;
self.alpha -= 0.01;
if (self.alpha <= 0) {
self.destroy();
}
};
});
var DisplayLife = Container.expand(function () {
var self = Container.call(this);
var lifeGraphics = self.attachAsset('life', {
anchorX: 0.5,
anchorY: 0.5
});
});
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.x -= self.speed;
self.x += Math.sin(LK.ticks / 10) * 2.5;
if (self.x < -self.width) {
self.destroy();
}
};
});
var Life = Container.expand(function () {
var self = Container.call(this);
var lifeGraphics = self.attachAsset('life', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.x -= 5;
if (self.x < -self.width) {
self.destroy();
}
};
});
var Ninja = Container.expand(function () {
var self = Container.call(this);
var ninjaGraphics = self.attachAsset('ninja', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
if (self.currentPath === 'lower' && self.y >= path2.y - self.height && !self.dashActive) {
var dash = new Dash();
dash.x = self.x - self.width / 2;
dash.y = self.y;
game.addChildAt(dash, game.getChildIndex(ninja));
self.dashActive = true;
LK.setTimeout(function () {
dash.destroy();
self.dashActive = false;
}, 100);
} else if (self.currentPath === 'upper' && self.y <= path1.y - self.height && !self.dashActive) {
var dash = new Dash();
dash.x = self.x - self.width / 2;
dash.y = self.y;
game.addChildAt(dash, game.getChildIndex(ninja));
self.dashActive = true;
LK.setTimeout(function () {
dash.destroy();
self.dashActive = false;
}, 50);
}
if (self.currentPath === 'upper' && self.y > path1.y - self.height - 50) {
self.y -= 10;
if (self.y <= path1.y - self.height - 50) {
self.y = path1.y - self.height - 50;
}
} else if (self.currentPath === 'lower' && self.y < path2.y - self.height + 50) {
self.y += 10;
if (self.y >= path2.y - self.height + 50) {
self.y = path2.y - self.height + 50;
}
}
scoreTxt.setText(ninja.distanceTraveled + 'm'); // Update the score display
for (var i = coins.length - 1; i >= 0; i--) {
if (self.intersects(coins[i])) {
coinCounter++;
scoreMultiplier = 2;
LK.setTimeout(function () {
scoreMultiplier = 1;
}, 5000);
coins[i].destroy();
coins.splice(i, 1);
i--;
}
}
for (var i = lives.length - 1; i >= 0; i--) {
if (self.intersects(lives[i])) {
self.lives++;
lives[i].destroy();
lives.splice(i, 1);
i--;
}
}
for (var i = shields.length - 1; i >= 0; i--) {
if (self.intersects(shields[i])) {
invincible = true;
LK.setTimeout(function () {
invincible = false;
}, 5000);
shields[i].destroy();
shields.splice(i, 1);
i--;
}
}
for (var i = 0; i < game.children.length; i++) {
if (game.children[i] instanceof Obstacle && self.intersects(game.children[i]) && !self.invincible) {
// Reduce the lives by one
self.lives--;
// Update the display
for (var j = game.children.length - 1; j >= 0; j--) {
if (game.children[j] instanceof Life) {
game.children[j].destroy();
break;
}
}
// If no lives left, game over
if (self.lives === 0) {
LK.showGameOver();
}
// Make ninja invincible for 3 seconds
self.invincible = true;
ninjaGraphics.alpha = 1;
var opacityDirection = -1;
var _opacityChange = function opacityChange() {
ninjaGraphics.alpha += 0.18 * opacityDirection;
if (ninjaGraphics.alpha <= 0.1) {
opacityDirection = 1;
} else if (ninjaGraphics.alpha >= 1) {
opacityDirection = -1;
}
if (self.invincible) {
LK.setTimeout(_opacityChange, 60);
} else {
ninjaGraphics.alpha = 1;
}
};
LK.setTimeout(_opacityChange, 60);
LK.setTimeout(function () {
self.invincible = false;
ninjaGraphics.alpha = 1; // Reset opacity to 1 when invincibility ends
}, 3000);
}
}
};
self.down = function () {
if (self.currentPath === 'lower') {
targetPath = 'upper';
self.y -= 20;
self.x += 10;
} else {
targetPath = 'lower';
self.y += 20;
self.x -= 10;
}
};
self.up = function () {
targetPath = null;
};
});
var NinjaStar = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.attachAsset('ninjaStar', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -5;
self.update = function () {
self.y += self.speed;
};
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 30;
self.update = function () {
self.x -= self.speed;
if (self.x < -self.width) {
self.destroy();
}
};
});
var Path = Container.expand(function () {
var self = Container.call(this);
var pathGraphics = self.attachAsset('path', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 30;
self.update = function () {
self.x -= self.speed;
if (self.x < -self.width) {
self.destroy();
}
};
});
var Shield = Container.expand(function () {
var self = Container.call(this);
var shieldGraphics = self.attachAsset('shield', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.x -= 5;
if (self.x < -self.width) {
self.destroy();
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
var coins = [];
var lives = [];
var shields = [];
var coinCounter = 0;
var scoreMultiplier = 1;
var invincible = false;
function spawnCollectible() {
var collectibleType = Math.random();
var newCollectible;
if (collectibleType < 0.6) {
newCollectible = new Coin();
coins.push(newCollectible);
} else if (collectibleType < 0.8) {
newCollectible = new Life();
lives.push(newCollectible);
} else {
newCollectible = new Shield();
shields.push(newCollectible);
}
var randomPath = Math.random() > 0.5 ? 1 : 2;
newCollectible.x = 2048;
if (randomPath === 1) {
newCollectible.y = 2732 / 3 + 80;
newCollectible.rotation = Math.PI; // Rotate 180 degrees
} else {
newCollectible.y = 2732 * 2 / 3 - 80;
newCollectible.rotation = 0; // No rotation
}
game.addChild(newCollectible);
}
LK.setInterval(spawnCollectible, 5000);
var background = game.addChild(new Background());
var path1 = game.addChild(new Path());
path1.y = 2732 / 3;
var path2 = game.addChild(new Path());
path2.y = 2732 * 2 / 3;
var ninja = game.addChild(new Ninja());
ninja.x = 1024;
ninja.y = path2.y - ninja.height;
ninja.currentPath = 'lower';
ninja.lives = 3;
ninja.distanceTraveled = 0; // Initialize distance traveled to 0
var targetPath;
// Display the lives a little bit more up in y axis from the upper path
for (var i = 0; i < ninja.lives; i++) {
var life = game.addChild(new DisplayLife());
life.x = 100 + i * 100; // Move the lives little bit right on x axis
life.y = path1.y - 150; // Move lives a little bit more up
game.setChildIndex(life, game.children.length - 1);
}
// Display the score based on the distance traveled
var scoreTxt = new Text2('0m', {
resolution: 2,
size: 100,
fill: "#ffffff",
font: "lexend"
});
scoreTxt.anchor.set(0.5, 0);
scoreTxt.y = path1.y - 450; // Move the score display a little bit more up, above the upper path
LK.gui.top.addChild(scoreTxt);
game.down = function (x, y, obj) {
if (ninja.currentPath === 'lower' && ninja.y >= path2.y - ninja.height || ninja.currentPath === 'upper' && ninja.y <= path1.y - ninja.height) {
if (ninja.currentPath === 'lower') {
targetPath = 'upper';
ninja.y -= 500; // Increase the jump speed
ninja.scale.y *= -1; // Flip vertically
// No code to insert, we are removing the timeout that destroys the dash
} else {
targetPath = 'lower';
ninja.y += 500; // Increase the jump speed
ninja.scale.y *= -1; // Flip vertically
// No code to insert, we are removing the timeout that destroys the dash
}
ninja.currentPath = targetPath;
}
};
game.update = function () {
var lastPath = 0;
if (LK.ticks % 50 == 0) {
var randomPath = Math.random() > 0.5 ? 1 : 2;
var spawnDistance = randomPath === lastPath ? 512 : 4096;
var obstacleGroupSize = Math.floor(Math.random() * 3) + 1;
for (var i = 0; i < obstacleGroupSize; i++) {
var newObstacle = new Obstacle();
newObstacle.x = spawnDistance + i * newObstacle.width;
if (randomPath === 1) {
newObstacle.y = 2732 / 3 + 80;
} else {
newObstacle.y = 2732 * 2 / 3 - 80;
}
if (randomPath === 1) {
newObstacle.rotation = Math.PI; // Rotate 180 degrees
} else {
newObstacle.rotation = 0; // No rotation
}
game.addChildAt(newObstacle, game.children.length);
}
lastPath = randomPath;
}
if (LK.ticks % 20 == 0) {
var newPath1 = new Path();
newPath1.x = 2048 + 100; // Increase the x-coordinate by 100 to create a gap
newPath1.y = 2732 / 3;
game.addChild(newPath1);
var newPath2 = new Path();
newPath2.x = 2048 + 100; // Increase the x-coordinate by 100 to create a gap
newPath2.y = 2732 * 2 / 3;
game.addChild(newPath2);
ninja.distanceTraveled += 100; // Increase distance traveled by 100 meters for each new path
}
};
Ninja Star. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A minimalist icon depicting a ninja head silhouette in black. The silhouette should be simple and recognizable, with a headband or mask detail. The background should be transparent or a contrasting color (e.g., red or white).. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Coin. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Shield. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Transparent sheild bubble. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a series of curved, tapered lines that originate from the ninja's body and extend outward in the direction of movement. The lines should vary in length and thickness, with a sense of energy and dynamism.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
backgroundMusic
Sound effect
coinCollect
Sound effect
jumpSound
Sound effect
footstepSound1
Sound effect
footstepSound2
Sound effect
footstepSound3
Sound effect
shooterSpawn
Sound effect
destructorSpawn
Sound effect
attackerSpawn
Sound effect
shooterAttack
Sound effect
destructorAttack
Sound effect
attackerAttack
Sound effect
enemyHit
Sound effect
shieldCollect
Sound effect
shieldCollectSound
Sound effect
ninjaGrunt
Sound effect
destructorAttackSound
Sound effect