User prompt
make red flash longer when killed
Code edit (1 edits merged)
Please save this source code
User prompt
also play killed_1 after accident_1
User prompt
play accident_1 when killed
User prompt
when setting killer[2] active, play ambulance_1
User prompt
when setting killer[1] active, play police_1
User prompt
when setting killer[0] active, play car_1
Code edit (4 edits merged)
Please save this source code
User prompt
play levelWin_1 when wining a level
User prompt
add a function playHit() thay randmoly plays hit_1, hit_2 or hit_3
User prompt
play hit_1 when hitting an obstacle
User prompt
stop bgMusic when player is killed
User prompt
play coin_1 when player collects a coin
User prompt
play bgMusic repeatedly after start button press
User prompt
Please fix the bug: 'ReferenceError: currentTime is not defined' in or related to this line: 'self.lastKillerUpdate = currentTime;' Line Number: 425
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'resetKillers')' in or related to this line: 'killerManager.resetKillers();' Line Number: 1452
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'resetKillers')' in or related to this line: 'killerManager.resetKillers();' Line Number: 1451
Code edit (1 edits merged)
Please save this source code
User prompt
create a KillerManager class to organize killers to activate killers[0] after killerDelay, then killers[1] after killerDelay, then killers[2] after killerDelay, then killers[0] after killerDelay, ....
User prompt
organize killers to activate killers[0] after killerDelay, then killers[1] after killerDelay, then killers[2] after killerDelay, then killers[0] after killerDelay, ....
User prompt
create 3 different killers instead of 1
User prompt
add an index to Killer constructor that allow asset selection
User prompt
create a global array for killers
Code edit (3 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -349,8 +349,33 @@
self.inactive = true;
self.inactiveStartTime = Date.now();
};
});
+var KillerManager = Container.expand(function () {
+ var self = Container.call(this);
+ self.killers = [];
+ self.currentKillerIndex = 0;
+ self.lastKillerUpdate = 0;
+ self.killerDelay = 10000; // Delay in milliseconds before updating killer
+ self.addKiller = function (killer) {
+ self.killers.push(killer);
+ };
+ self.update = function () {
+ var currentTime = Date.now();
+ if (currentTime - self.lastKillerUpdate >= self.killerDelay) {
+ self.killers[self.currentKillerIndex].inactive = false;
+ self.currentKillerIndex = (self.currentKillerIndex + 1) % self.killers.length;
+ self.lastKillerUpdate = currentTime;
+ }
+ };
+ self.resetKillers = function () {
+ self.killers.forEach(function (killer) {
+ killer.reset();
+ });
+ self.currentKillerIndex = 0;
+ self.lastKillerUpdate = Date.now();
+ };
+});
var Landscape = Container.expand(function () {
var self = Container.call(this);
var landscapeGraphics = self.attachAsset('landscape_1', {
anchorX: 0.5,
@@ -1357,25 +1382,12 @@
updateBackgroundColor();
if (!isPlaying || isKilled) {
return;
}
- // Activate killers sequentially with a delay
- var currentTime = Date.now();
- if (currentTime - lastKillerUpdate >= killerDelay) {
- // Deactivate all killers
- killers.forEach(function (killer) {
- killer.inactive = true;
- });
- // Activate the next killer in sequence
- var nextKillerIndex = Math.floor((currentTime - lastKillerUpdate) / killerDelay) % killers.length;
- killers[nextKillerIndex].inactive = false;
- killers[nextKillerIndex].inactiveStartTime = currentTime;
- // Update the last killer update time
- lastKillerUpdate = currentTime;
- }
};
// Initialize game
function gameInitialize() {
+ killerManager.resetKillers();
// Initialize arrays and variables
// Attach the background asset to the game
background = game.addChild(new Background());
background.updateForLevel(currentLevel);
@@ -1453,14 +1465,16 @@
}
obstacleManager.resetObstacles();
game.addChild(obstacleManager);
// Create and attach the killer instance to the game
+ var killerManager = new KillerManager();
for (var i = 0; i < 3; i++) {
var newKiller = new Killer(i); // Pass index for each killer
newKiller.reset();
- killers.push(newKiller);
+ killerManager.addKiller(newKiller);
game.addChild(newKiller);
}
+ game.addChild(killerManager);
// Create player
player = game.addChild(new Player());
player.frame = 0;
player.x = playerPositions[playerPositionIndex]; // Start at the center position
@@ -1486,9 +1500,9 @@
});
debugTxt.anchor.set(1, 1); // Set anchor to the bottom right corner
LK.gui.bottomRight.addChild(debugTxt);
isPlaying = false;
- lastKillerUpdate = Date.now(); // Initialize lastKillerUpdate variable
}
gameInitialize();
// DEVLOG:
-// Delay isPlaying when start button pressed
\ No newline at end of file
+// Delay isPlaying when start button pressed
+killerManager.update();
\ No newline at end of file
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