Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: bonusGraphics is not defined' in or related to this line: 'bonusGraphics.visible = false;' Line Number: 502
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: BonusManager is not defined' in or related to this line: 'bonusManager = new BonusManager();' Line Number: 1041
Code edit (4 edits merged)
Please save this source code
User prompt
add a new class Bonus
Code edit (10 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: drone is undefined' in or related to this line: 'drone._update_migrated();' Line Number: 1076
Code edit (2 edits merged)
Please save this source code
User prompt
in DeliveryDrone class, add a bonus1 asset to the class and make it pop from the box when on ground
User prompt
in DeliveryDrone class, add an asset for the bonus that pops up from the box when on ground
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: self.useBonus is not a function' in or related to this line: 'self.useBonus();' Line Number: 420
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
ok, now update the rest of the DeliveryDrone class to use layers
User prompt
in DeliveryDrone, add a layer for packet assets and a layer for drone assets
User prompt
in drone prepare(), when attaching Asset packet1 put it as 1st child so it appears behind the drone
User prompt
in drone prepare(), attachAsset packet1 at z-index 0
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: drone is undefined' in or related to this line: 'drone._update_migrated();' Line Number: 1075
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: self.detachAsset is not a function' in or related to this line: 'self.detachAsset('packet1');' Line Number: 499
User prompt
Please fix the bug: 'TypeError: self.detechAsset is not a function' in or related to this line: 'self.detechAsset('packet1');' Line Number: 499
===================================================================
--- original.js
+++ change.js
@@ -429,8 +429,11 @@
var self = Container.call(this);
self.speedX = 0;
self.packetSpeed = 0;
self.entered = false;
+ self.enterTime = 0;
+ self.movePacket = false;
+ self.droneLeaving = false;
// Create layers for packets and drones
self.packetLayer = new Container();
self.droneLayer = new Container();
game.addChild(self.packetLayer);
@@ -449,26 +452,32 @@
anchorY: 0.5
});
self.drone1.visible = true; // Visibility based on isEven flag
self.drone2.visible = false; // Visibility based on isEven flag
- self.down = function (x, y, obj) {
- // Make packet1 fall to the ground
- self.throwPacket = true; // Adjust speed as necessary
- // Optional: Add logic to stop the packet at ground level
+ // Down works on last layer only
+ self.droneLayer.down = function (x, y, obj) {
+ if (!self.packetFalling) {
+ // Make packet1 fall to the ground
+ self.packetFalling = true;
+ log("THROW PACKET! self.packet1.y < groundLevel : " + self.packet1.y + " < " + groundLevel);
+ }
};
self._update_migrated = function () {
self.x += self.speedX;
// Reverse direction at screen edges
if (self.x < 2048 - 300) {
self.speedX = 0;
}
+ if (self.x > 2048 + 512) {
+ self.speedX = 0;
+ }
// Toggle visibility every 120 ticks (2 seconds)
if (LK.ticks % 2 == 0) {
self.drone1.visible = !self.drone1.visible;
self.drone2.visible = !self.drone2.visible;
}
// Update packet1 position to simulate falling
- if (self.throwPacket && self.packet1.y < groundLevel - self.packet1.height / 2) {
+ if (self.packetFalling && self.packet1.y < groundLevel - self.packet1.height / 2) {
// Ensure packet stops at ground level
self.packetSpeed += 1;
self.packet1.y += self.packetSpeed; // Adjust speed as necessary
if (self.packet1.y >= groundLevel - self.packet1.height / 2) {
@@ -479,10 +488,21 @@
anchorX: 0.5,
anchorY: 0.5,
y: groundLevel - self.packet1.height / 2
});
+ self.packetFalling = false;
+ self.movePacket = true;
+ self.droneLeaving = true;
+ self.speedX = 5;
}
}
+ self.packetLayer.x = self.x;
+ self.packetLayer.y = self.y;
+ self.droneLayer.x = self.x;
+ self.droneLayer.y = self.y;
+ if (self.movePacket && self.x + self.packet1.x > -512) {
+ self.packet1.x += globalSpeedPerLine[0];
+ }
};
self.prepare = function () {
self.x = 2048 + 300;
self.y = 128;
@@ -498,10 +518,11 @@
};
self.enter = function () {
if (!self.entered) {
self.x.visible = true;
- self.speedX = -2;
+ self.speedX = -4;
self.entered = true;
+ self.enterTime = Date.now();
}
};
});
/****************************************************************************************** */
@@ -662,12 +683,12 @@
/****
* Game Code
****/
+// Enumeration for game states
/****************************************************************************************** */
/************************************** GLOBAL VARIABLES ********************************** */
/****************************************************************************************** */
-// Enumeration for game states
var GAME_STATE = {
INIT: 'INIT',
MENU: 'MENU',
HELP: 'HELP',
@@ -824,8 +845,9 @@
cleanMenuState();
initHurdlesStartingState();
}
function gamePlayingDown() {
+ log("gamePlayingDown ...");
if (athlete.isRunning && !finishLine.isCut) {
// Make the athlete jump
athlete.jump();
} else {
@@ -962,13 +984,15 @@
game.addChild(startText);
// TEMP DEBUG TEST BLOCKER
//var blocker = new Blocker(-1024, groundLevel - 200 - 475 * 1);
//game.addChild(blocker);
- /*
+ /*
drone = new DeliveryDrone(); // false for odd drone graphic
drone.x = 2048 - 300;
drone.y = 128; // Positioning the drone
game.addChild(drone);
+ */
+ /*
/// TEST overboard
var hoverboard = LK.getAsset('hoverboard', {
anchorX: 0.5,
// Center the button horizontally
@@ -993,8 +1017,9 @@
drone2.visible = !drone2.visible;
}
lastDroneToggleTick = LK.ticks;
}
+ drone._update_migrated();
*/
}
function cleanMenuState() {
game.removeChild(startText);
@@ -1349,8 +1374,11 @@
finishLine.isCut = true;
finishLine.cut();
}
}
+ if (drone && athlete.rightLeg.intersects(drone.packet1)) {
+ athlete.jumpSpeed = -50;
+ }
}
function handleFallEvent() {
if (athlete.isFalling && !athlete.hasFlashed) {
LK.effects.flashScreen(0xaaaaaa, 500); // Flash screen red for half a second
Elongated elipse with black top half and white bottom half.
full close and front view of empty stands. retro gaming style
delete
delete
Basquettes Γ ressort futuriste. vue de profile. Retro gaming style
a blue iron man style armor flying. Retro gaming style
a blue iron man style armor flying horizontally. Retro gaming style
round button with a big "up" arrow icon and a small line under it. UI
A big black horizontal arrow pointing left with centred text 'YOU' in capital letters, painted on an orange floor.. horizontal and pointing left
remove
gold athletics medal with ribbon. retro gaming style
a black oval with a crying smiley face.