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
Code edit (1 edits merged)
Please save this source code
Code edit (17 edits merged)
Please save this source code
User prompt
on tap on the DeliveryDrone, make the packet1 fall to the ground
Code edit (1 edits merged)
Please save this source code
User prompt
inside DeliveryDrone class, create 2 drone instances
User prompt
Create a class DeliveryDrone, put inside 2 drone instances and their visbility logic
Code edit (1 edits merged)
Please save this source code
User prompt
in menuHandling use ticks instead of setInterval
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: game.getChildByName is not a function' in or related to this line: 'var drone = game.getChildByName('drone');' Line Number: 925
User prompt
in menuHandling, alternate visibility of the drones
Code edit (2 edits merged)
Please save this source code
User prompt
in initMenuState , use drone class
Code edit (6 edits merged)
Please save this source code
User prompt
create a new Drone class
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
in checkForCollisions, the setTimeout uses the iterator line, this can cause unwanted behaviour, secrure this part of the code
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: opponents[(line - 1)] is undefined' in or related to this line: 'opponents[line - 1].isRunning = true;' Line Number: 1217
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: blocker is not defined' in or related to this line: 'if (blocker) {' Line Number: 1111
===================================================================
--- original.js
+++ change.js
@@ -405,52 +405,67 @@
self.speedX = globalSpeedPerLine[0];
self.x += self.speedX;
};
});
-var DeliveryDrone = Container.expand(function (isEven) {
+/****************************************************************************************** */
+/************************************** DRONE CLASS ************************************ */
+/****************************************************************************************** */
+/*var Drone = Container.expand(function (isEven) {
var self = Container.call(this);
- // Create two drone instances with distinct graphics based on isEven flag
- self.drone1 = self.attachAsset('drone', {
+ self.droneGraphics = self.attachAsset(isEven ? 'drone2' : 'drone', {
anchorX: 0.5,
anchorY: 0.5
});
- self.drone2 = self.attachAsset('drone2', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- // Set initial properties for drones
self.speedX = 0;
- self.drone1.visible = !isEven; // Visibility based on isEven flag
- self.drone2.visible = isEven; // Visibility based on isEven flag
self._update_migrated = function () {
self.x += self.speedX;
// Reverse direction at screen edges
if (self.x > 2048 || self.x < 0) {
self.speedX *= -1;
}
- // Toggle visibility every 120 ticks (2 seconds)
- if (LK.ticks % 120 == 0) {
- self.drone1.visible = !isEven; // Visibility based on isEven flag
- self.drone2.visible = isEven; // Visibility based on isEven flag
- }
};
});
-/****************************************************************************************** */
-/************************************** DRONE CLASS ************************************ */
-/****************************************************************************************** */
-var Drone = Container.expand(function (isEven) {
+*/
+var DeliveryDrone = Container.expand(function () {
var self = Container.call(this);
- self.droneGraphics = self.attachAsset(isEven ? 'drone2' : 'drone', {
+ self.speedX = 0;
+ self.packet1 = self.attachAsset('packet1', {
anchorX: 0.5,
+ anchorY: 0.5,
+ y: 75
+ });
+ // Create two drone instances with distinct graphics based on isEven flag
+ self.drone1 = self.attachAsset('drone', {
+ anchorX: 0.5,
anchorY: 0.5
});
- self.speedX = 0;
+ self.drone2 = self.attachAsset('drone2', {
+ anchorX: 0.5,
+ 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.packet1.y += 5; // Adjust speed as necessary
+ // Optional: Add logic to stop the packet at ground level
+ };
self._update_migrated = function () {
self.x += self.speedX;
// Reverse direction at screen edges
if (self.x > 2048 || self.x < 0) {
self.speedX *= -1;
}
+ // 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.packet1.y < groundLevel - self.packet1.height / 2) {
+ // Ensure packet stops at ground level
+ self.packet1.y += 5; // Adjust speed as necessary
+ }
};
});
/****************************************************************************************** */
/************************************** FINISH LINE CLASS ************************************ */
@@ -610,12 +625,12 @@
/****
* Game Code
****/
-// Enumeration for game states
/****************************************************************************************** */
/************************************** GLOBAL VARIABLES ********************************** */
/****************************************************************************************** */
+// Enumeration for game states
var GAME_STATE = {
INIT: 'INIT',
MENU: 'MENU',
HELP: 'HELP',
@@ -653,9 +668,8 @@
var track3;
var track4;
var scoreTxt;
var drone;
-var drone2;
var currentFinishPosition = 1;
var difficultyLevel = 1;
var globalBaseSpeed = -20 - 10 * difficultyLevel;
var globalSpeedPerLine = []; // Global speed for tracks and obstacles default -10 / min = -4
@@ -911,31 +925,28 @@
game.addChild(startText);
// TEMP DEBUG TEST BLOCKER
//var blocker = new Blocker(-1024, groundLevel - 200 - 475 * 1);
//game.addChild(blocker);
- drone = new Drone(false); // false for odd drone graphic
+ drone = new DeliveryDrone(); // false for odd drone graphic
drone.x = 2048 - 300;
drone.y = 128; // Positioning the drone
game.addChild(drone);
- drone2 = new Drone(true); // false for odd drone graphic
- drone2.x = 2048 - 300;
- drone2.y = 128; // Positioning the drone
- drone2.visible = false; // Positioning the drone
- game.addChild(drone2);
gameState = GAME_STATE.MENU;
}
function menuHandling() {
// Alternate visibility of drones every 2 seconds
// Use game ticks for drone visibility alternation, assuming 60 ticks per second
- var droneVisibilityTicks = 20; //120; // Equivalent to 2 seconds
+ /*var droneVisibilityTicks = 20; //120; // Equivalent to 2 seconds
var lastDroneToggleTick = 0;
if (LK.ticks - lastDroneToggleTick >= droneVisibilityTicks) {
if (drone && drone2) {
drone.visible = !drone.visible;
drone2.visible = !drone2.visible;
}
lastDroneToggleTick = LK.ticks;
}
+ */
+ drone._update_migrated();
}
function cleanMenuState() {
game.removeChild(startText);
startText.destroy();
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.