User prompt
add a smooth sinusoidal vertical movement to coins, it should be relative, that is it doesn't change current y movement and shadow should not be afected by the relavive move
User prompt
add a smooth sinusoidal relative vertical movement to coins
Code edit (1 edits merged)
Please save this source code
User prompt
in Coin update, Update also the y offset of shadow to grow with progress
User prompt
update the y offset of shadow to grow with progress
User prompt
Please fix the bug: 'TypeError: coinGraphics is undefined' in or related to this line: 'coinShadow.y = coinGraphics.height * 0.1; // Offset shadow slightly below the coin' Line Number: 41
User prompt
add and y offset between coin and its shadow
User prompt
in Coin, make Shadow w & h 80% of coin's w & h
User prompt
rename playerShadow to shadow
User prompt
add a shadow under coins graphics
User prompt
add the cent sign to the score when level == 1 and $ sign when level > 1
User prompt
add a global names currentLevel
User prompt
in game.up when killed, wait 1 se before game over
Code edit (2 edits merged)
Please save this source code
User prompt
replace ``` var newCoin = new Coin(); newCoin.reset(); coins.push(newCoin); game.addChild(newCoin); ``` by a loop to create 5 coins at y = roadTop - i * 50
User prompt
now instead of spwning 1 coin, spaw a serie of 5 on the same path at with an y offset of 50
User prompt
update `currentSpeed = currentSpeed * 0.8;` to ensure speed is always between 10 and 20 and is an integer
Code edit (1 edits merged)
Please save this source code
User prompt
add 2 globals lastObstacleHitTime and immunityDelay = 500; then use then in Obstacle update to avoid multiple collision with the same obstacle
Code edit (1 edits merged)
Please save this source code
User prompt
move player/obstacle collision logic relative to Killers from Obstacle class to Killer class
Code edit (7 edits merged)
Please save this source code
User prompt
move player/Obstacle (except Killer) intersection logic in Obstacle class
Code edit (7 edits merged)
Please save this source code
User prompt
move player/coin intersection login in Coin class
===================================================================
--- original.js
+++ change.js
@@ -62,9 +62,9 @@
if (self.y > endY + endSize / 2) {
self.reset();
}
// Check for collision with player
- if (player && player.shadow && player.shadow.intersects(self) && !player.isJumping) {
+ if (!player.isJumping && self.y > 2500 && self.y < 2732 && player.shadow.intersects(self)) {
score += 1;
coinsCollected += 1; // Increment coins collected counter
scoreTxt.setText(score);
LK.effects.flashObject(player, 0xffd700, 500); // Flash gold for 0.5 seconds
@@ -321,8 +321,15 @@
});
self.update = function () {
// MurderShape does not need to update its position or behavior
};
+ self.fixPosition = function () {
+ if (self.x < 600) {
+ self.x += 150;
+ } else if (self.x > 1400) {
+ self.x -= 150;
+ }
+ };
});
// Obstacle class
var Obstacle = Container.expand(function () {
var self = Container.call(this);
@@ -359,8 +366,45 @@
self.update = function () {
if (!isPlaying || isKilled) {
return;
}
+ // Check for collision with player
+ if (player && self.y > 2500 && self.y < 2732 && player.shadow.intersects(self)) {
+ if (self instanceof Killer) {
+ isKilled = true;
+ player.visible = false;
+ LK.effects.flashScreen(0xff0000, 1000);
+ // Spawn MurderShape at player's last position
+ var murderShape = new MurderShape();
+ murderShape.x = player.x;
+ murderShape.y = player.y;
+ murderShape.fixPosition();
+ game.addChildAt(murderShape, game.getChildIndex(road) + 1);
+ return;
+ }
+ if (!player.isJumping && !isIntersectingObstacle) {
+ isIntersectingObstacle = true; // Set the flag to true
+ // Make player flash red for 1 second
+ LK.effects.flashObject(player, 0xff0000, 1000);
+ // Add coin animation only if score is greater than 0
+ if (score > 0) {
+ var coinAnimation = new CoinAnimation();
+ coinAnimation.x = player.x;
+ coinAnimation.y = player.y;
+ game.addChild(coinAnimation);
+ }
+ // Reduce score by 1
+ score = Math.max(0, score - 1);
+ scoreTxt.setText(score);
+ console.log("Obstacle y:", self.y);
+ // Reduce currentSpeed by a factor (e.g., 0.8)
+ console.log("Old speed :", currentSpeed);
+ //currentSpeed = currentSpeed * 0.8; // Ensure speed doesn't go below a minimum value
+ console.log("New speed :", currentSpeed);
+ }
+ } else {
+ isIntersectingObstacle = false; // Reset the flag when the intersection ends
+ }
self.progress = Math.max(0, self.y - startY) / (endY - startY); // Update progress property
obstacleGraphics.width = startSize + (endSize - startSize) * self.progress;
obstacleGraphics.height = startSize + (endSize - startSize) * self.progress;
var tempSpeed = currentSpeed * 0.05 + currentSpeed * (self.progress * 3);
@@ -867,45 +911,11 @@
/*for (var i = coins.length - 1; i >= 0; i--) {
coins[i].update();
}
*/
- // Update obstacles and check for collisions
+ // Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
- if (player && obstacles[i].y > 2500 && obstacles[i].y < 2732 && player.shadow.intersects(obstacles[i])) {
- if (obstacles[i] instanceof Killer) {
- isKilled = true;
- player.visible = false;
- LK.effects.flashScreen(0xff0000, 1000);
- // Spawn MurderShape at player's last position
- var murderShape = new MurderShape();
- murderShape.x = player.x;
- murderShape.y = player.y;
- game.addChildAt(murderShape, game.getChildIndex(road) + 1);
- return;
- }
- if (!player.isJumping && !isIntersectingObstacle) {
- isIntersectingObstacle = true; // Set the flag to true
- // Make player flash red for 1 second
- LK.effects.flashObject(player, 0xff0000, 1000);
- // Add coin animation only if score is greater than 0
- if (score > 0) {
- var coinAnimation = new CoinAnimation();
- coinAnimation.x = player.x;
- coinAnimation.y = player.y;
- game.addChild(coinAnimation);
- }
- // Reduce score by 1
- score = Math.max(0, score - 1);
- scoreTxt.setText(score);
- console.log("Obstacle y:", obstacles[i].y);
- // Reduce currentSpeed by a factor (e.g., 0.8)
- console.log("Old speed :", currentSpeed);
- //currentSpeed = currentSpeed * 0.8; // Ensure speed doesn't go below a minimum value
- console.log("New speed :", currentSpeed);
- }
- } else {
- isIntersectingObstacle = false; // Reset the flag when the intersection ends
- }
+ obstacles[i].update();
}
// Removed continuous speed increase
};
// Initialize game
Directly overhead, plumb view of a beggar heading top (we see his back).. Zenith view, directly overhead, plumb view. NOT PERSPECTIVE! Fantasy theme. Pixel art
a traffic cone. video game sprite
face view of a big start button in the shape of a dollar bill. video game style
a tree. video game style
a black garbage bag. video game style
Dollar bill. Perspective. video game sprite
perspective of a simple snake rolled up on itself.. video game sprite
Ball of dry desert bushes. video game sprite
tractor. high definition video game sprite
street ad billboard with 1 or 2 posts with "Get rich!" on it. high definition video game sprite
a dog sleeping on a street. video game sprite
desert bush. video game sprite
profile view of an empty motorcycle helmet. black with a white vertical central band and another thiner orange band on the center. NOT PERSPECTIVE!. Pixel art high definition
simple red and white magnet. video game style
gold sign with a "X" and a "2". video game style
bgMusic
Music
coin_1
Sound effect
hit_1
Sound effect
hit_2
Sound effect
hit_3
Sound effect
levelWin_1
Sound effect
car_1
Sound effect
police_1
Sound effect
ambulance_1
Sound effect
accident_1
Sound effect
killed_1
Sound effect
jump_1
Sound effect
rip_1
Sound effect
bonus_take
Sound effect
bonus_approaching
Sound effect