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
Code edit (1 edits merged)
Please save this source code
User prompt
set murderShape just above z-index of the road
User prompt
when killed, spawn a MurderShape at playe's last position
Code edit (1 edits merged)
Please save this source code
User prompt
also stop updating coins and decorations when is killed
User prompt
you said "Stop updating road and obstacles if isKilled" but didn't do it
User prompt
when hit by killer, don't stop every thing: - Hide the player - let killer continue - stop road anim - show game over after a tap In oder to do that : - add a isKilled global defaulting to false - don't update road and Obstacles if isKilled (Obstacles only, not killers) - set isKilled to true when hitting a killer - in up event, show game over if isKilled
User prompt
when hit by killer, don't stop every thing: - Hide the player - let killer continue - stop road anim - show game over after a tap
User prompt
reduce currentSpeed when hitting an obstacle
Code edit (1 edits merged)
Please save this source code
User prompt
no, currently killer is updated in a weired way, every 100ms....that's not what we want : we want to : - spawn a killer but it stays intactive let says for 5 seonds - after the 5sec delay, killer is updated normally every frame until passing the bottom of the screen. - after that is no more updated for 5 other seconds.
Code edit (9 edits merged)
Please save this source code
User prompt
use this kind of code : if (obstacles[i] instanceof Killer) { var currentTime = Date.now(); if (currentTime - lastKillerUpdate < killerDelay) { continue; // Skip updating this killer if the delay has not expired } lastKillerUpdate = currentTime; } in Killer class update, not in game update
User prompt
reduce killers frequency by adding a global killerDelay, and not updating killer before this delay expires
User prompt
reduce killers frequency
Code edit (1 edits merged)
Please save this source code
Code edit (18 edits merged)
Please save this source code
User prompt
add a Killer class, that will be very similar to obstacles, except that a collision with a killer leads to game over
===================================================================
--- original.js
+++ change.js
@@ -250,9 +250,9 @@
self.inactive = false;
}
return;
}
- if (player && self.y > 2500 && self.y < 2732 && player.shadow.intersects(self)) {
+ if (!isKilled && player && self.y > 2500 && self.y < 2732 && player.shadow.intersects(self)) {
isKilled = true;
player.visible = false;
LK.effects.flashScreen(0xff0000, 1000);
// Spawn MurderShape at player's last position
@@ -379,10 +379,11 @@
if (!isPlaying || isKilled) {
return;
}
// Check for collision with player
- if (!isIntersectingObstacle && player && !player.isJumping && self.y > 2500 && self.y < 2732 && player.shadow.intersects(self)) {
- isIntersectingObstacle = true; // Set the flag to true
+ var currentTime = Date.now();
+ if (currentTime - lastObstacleHitTime > immunityDelay && player && !player.isJumping && self.y > 2500 && self.y < 2732 && player.shadow.intersects(self)) {
+ lastObstacleHitTime = currentTime; // Update the last hit time
// 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) {
@@ -398,10 +399,8 @@
// 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;
@@ -824,8 +823,10 @@
var maxSpeed = 50; // Define a maximum speed limit
var currentSpeed = 10; //20; // Initialize currentSpeed
var coinsCollected = 0; // Initialize coins collected counter
var isIntersectingObstacle = false; // Flag to track if the player is currently intersecting an obstacle
+var lastObstacleHitTime = 0; // Timestamp of the last obstacle hit
+var immunityDelay = 500; // Immunity delay in milliseconds
var playerPositionIndex = 1; // Initialize player position index
// Define the three fixed x positions for the player
var playerPositions = [2048 / 5, 2048 / 2, 4 * 2048 / 5];
// Create player
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