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
@@ -428,8 +428,9 @@
var DeliveryDrone = Container.expand(function () {
var self = Container.call(this);
self.speedX = 0;
self.packetSpeed = 0;
+ self.entered = false;
self.packet1 = self.attachAsset('packet1', {
anchorX: 0.5,
anchorY: 0.5,
y: 75
@@ -452,10 +453,10 @@
};
self._update_migrated = function () {
self.x += self.speedX;
// Reverse direction at screen edges
- if (self.x > 2048 || self.x < 0) {
- self.speedX *= -1;
+ if (self.x < 2048 - 300) {
+ self.speedX = 0;
}
// Toggle visibility every 120 ticks (2 seconds)
if (LK.ticks % 2 == 0) {
self.drone1.visible = !self.drone1.visible;
@@ -477,8 +478,28 @@
});
}
}
};
+ self.prepare = function () {
+ self.x = 2048 + 300;
+ self.x.y = 128;
+ self.packetSpeed = 0;
+ game.removeChild(self.packet1);
+ self.packet1.destroy();
+ self.packet1 = self.attachAsset('packet1', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ y: 75
+ });
+ self.x.visible = false;
+ };
+ self.enter = function () {
+ if (!self.entered) {
+ self.x.visible = true;
+ self.speedX = -2;
+ self.entered = true;
+ }
+ };
});
/****************************************************************************************** */
/************************************** FINISH LINE CLASS ************************************ */
/****************************************************************************************** */
@@ -637,12 +658,12 @@
/****
* Game Code
****/
-// Enumeration for game states
/****************************************************************************************** */
/************************************** GLOBAL VARIABLES ********************************** */
/****************************************************************************************** */
+// Enumeration for game states
var GAME_STATE = {
INIT: 'INIT',
MENU: 'MENU',
HELP: 'HELP',
@@ -937,12 +958,25 @@
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
+ anchorY: 0.5,
+ // Center the button vertically
+ x: 600,
+ // Position horizontally in the center
+ y: groundLevel + 75
+ });
+ game.addChild(hoverboard);
+ */
gameState = GAME_STATE.MENU;
}
function menuHandling() {
// Alternate visibility of drones every 2 seconds
@@ -956,9 +990,8 @@
}
lastDroneToggleTick = LK.ticks;
}
*/
- drone._update_migrated();
}
function cleanMenuState() {
game.removeChild(startText);
startText.destroy();
@@ -1009,25 +1042,30 @@
for (var i = 0; i <= numberOfOpponents; i++) {
var athletes = [athlete].concat(opponents);
athletes[i]._update_migrated();
}
- drone._update_migrated();
+ if (drone) {
+ drone._update_migrated();
+ }
}
// PLAYING HURDLES
function initPlayingState() {
scoreTxt = new Text2("0/" + numberOfObstacles.toString(), {
- size: 100,
- fill: "#000000" // White color for better visibility
+ size: 80,
+ fill: "#FFFFFF"
});
//scoreTxt.anchor.set(1.1, 0.15); // Center the score text horizontally
- scoreTxt.anchor.set(0.25, 0); // Center the score text horizontally
+ scoreTxt.anchor.set(0.25, 0.125); // Center the score text horizontally
LK.gui.top.addChild(scoreTxt); // Add the score text to the GUI overlay at the top center
currentFinishPosition = 1;
// Remove starting blocks offset
for (var i = numberOfOpponents - 1; i >= 0; i--) {
opponents[i].y -= 150;
}
athlete.y -= 150;
+ drone = new DeliveryDrone(); // false for odd drone graphic
+ drone.prepare();
+ game.addChild(drone);
gameState = GAME_STATE.PLAYING;
}
function cleanPlayingHurdlesState() {
// Remove Opponents & Athlete
@@ -1072,8 +1110,10 @@
athlete._update_migrated();
game.addChild(athlete);
// Check for collisions
checkForCollisions();
+ // Update drone
+ drone._update_migrated();
}
/****************************************************************************************** */
/************************************** GAME FUNCTIONS ************************************ */
/****************************************************************************************** */
@@ -1255,8 +1295,11 @@
globalSpeedPerLine[line] = 0;
}
}
}
+ if (numberOfObstacles - obstacles[0].length > 1) {
+ drone.enter();
+ }
}
function checkForCollisions() {
if (finishLine.isCut) {
return;
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.