Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
add tween effect after dashing ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'ReferenceError: EagleWarningIcon is not defined' in or related to this line: 'var warningIconClassMap = {' Line Number: 2454
User prompt
delete eagle obstacle
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'isJumping')' in or related to this line: 'if (coot.isJumping || coot.isFalling || coot.isDiving || coot.isReturning || coot.returnDelay > 0) {' Line Number: 2696
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'if (powerups[i].x < -powerups[i].width / 2) {' Line Number: 182
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError is not a constructor' in or related to this line: 'throw new TypeError("Super expression must either be null or a function");' Line Number: 95
Code edit (1 edits merged)
Please save this source code
User prompt
prompt for the boat asset
User prompt
make sure the river flowing or not
User prompt
ensuring that the flow appears uninterrupted to the player.
User prompt
creating a loop effect that maintains the visual continuity of the flowing river. This effect is achieved by checking the river's Y position and resetting it when it reaches a certain point
User prompt
the river's movement should loop indefinitely, giving the impression of an endless flow. The river's position should reset once it reaches the bottom of the screen,
User prompt
The river should flow continuously throughout the game to create a seamless and immersive experience. This means that the river's movement should loop indefinitely,
User prompt
The river should flow continuously throughout the game to create a seamless and immersive experience. This means that the river's movement should loop indefinitely, giving the impression of an endless flow. The river's position should reset once it reaches the bottom of the screen, creating a loop effect that maintains the visual continuity of the flowing river. This effect is achieved by checking the river's Y position and resetting it when it reaches a certain point, ensuring that the flow appears uninterrupted to the player.
User prompt
make the river flow
User prompt
Make sure boat wil stop moving forward
User prompt
Stop the boat from moving forward
/**** * Classes ****/ // Boat class var Boat = Container.expand(function () { var self = Container.call(this); var boatGraphics = self.attachAsset('Speedboat', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 6.5; self.dashSpeed = 15; self.lives = 3; self.isFalling = false; self.isDashing = false; self.update = function () { // Boat movement logic if (keys['ArrowLeft']) { self.x -= self.speed; } if (keys['ArrowRight']) { self.x += self.speed; } // Keep boat within screen bounds if (self.x < 50) { self.x = 50; } if (self.x > 1998) { self.x = 1998; } }; }); // Floating Log class var FloatingLog = Container.expand(function () { var self = Container.call(this); var logGraphics = self.attachAsset('FloatingLog', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = -5; self.update = function () { self.x += self.speedX; if (self.x < -logGraphics.width / 2) { self.destroy(); } }; }); // Storm Cloud class var StormCloud = Container.expand(function () { var self = Container.call(this); var cloudGraphics = self.attachAsset('StormCloud', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = -6; self.update = function () { self.x += self.speedX; if (self.x < -cloudGraphics.width / 2) { self.destroy(); } }; }); // Treasure Chest class var TreasureChest = Container.expand(function () { var self = Container.call(this); var chestGraphics = self.attachAsset('TreasureChest', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = -5; self.update = function () { self.x += self.speedX; if (self.x < -chestGraphics.width / 2) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Light blue background for water }); /**** * Game Code ****/ var boat = game.addChild(new Boat()); boat.x = 2048 / 2; boat.y = 2732 * 0.8; var oceanBackground = LK.getAsset('OceanBackground', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); game.addChild(oceanBackground); var waves = LK.getAsset('OceanWaves', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 * 0.9 }); game.addChild(waves); var obstacles = []; var powerups = []; var score = 0; var coinCount = 0; function spawnObstacle() { var obstacleTypes = [FloatingLog, StormCloud]; var obstacle = new obstacleTypes[Math.floor(Math.random() * obstacleTypes.length)](); obstacle.x = 2048 + obstacle.width / 2; obstacle.y = Math.random() * (2732 * 0.6) + 2732 * 0.2; obstacles.push(obstacle); game.addChild(obstacle); } function spawnPowerUp() { var powerUpTypes = [TreasureChest]; var powerUp = new powerUpTypes[Math.floor(Math.random() * powerUpTypes.length)](); powerUp.x = 2048 + powerUp.width / 2; powerUp.y = Math.random() * (2732 * 0.6) + 2732 * 0.2; powerups.push(powerUp); game.addChild(powerUp); } function updateScore() { score += 1; coinCounter.setText('SCORE: ' + score); } var coinCounter = new Text2('0', { size: 150, fill: 0xFFFFFF }); coinCounter.anchor.set(1, 0); LK.gui.topRight.addChild(coinCounter); game.update = function () { boat.update(); // Update obstacles for (var i = obstacles.length - 1; i >= 0; i--) { obstacles[i].update(); if (boat.intersects(obstacles[i])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } if (obstacles[i].x < -obstacles[i].width / 2) { obstacles[i].destroy(); obstacles.splice(i, 1); } } // Update power-ups for (var i = powerups.length - 1; i >= 0; i--) { powerups[i].update(); if (boat.intersects(powerups[i])) { LK.getSound('treasure_collect').play(); coinCount += 10; updateScore(); powerups[i].destroy(); powerups.splice(i, 1); } if (powerups[i] && powerups[i].x < -powerups[i].width / 2) { powerups[i].destroy(); powerups.splice(i, 1); } } // Spawn obstacles and power-ups if (LK.ticks % 120 == 0) { spawnObstacle(); } if (LK.ticks % 240 == 0) { spawnPowerUp(); } }; // Handle keyboard input var keys = {}; game.on('keydown', function (event) { keys[event.code] = true; }); game.on('keyup', function (event) { keys[event.code] = false; });
===================================================================
--- original.js
+++ change.js
@@ -1,954 +1,180 @@
/****
* Classes
****/
-// ALFRomeo class
-var ALFRomeo = Container.expand(function () {
+// Boat class
+var Boat = Container.expand(function () {
var self = Container.call(this);
- var alfaRomeoGraphics = self.attachAsset('ALFRomeo', {
+ var boatGraphics = self.attachAsset('Speedboat', {
anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 1.0,
- scaleY: 1.23
+ anchorY: 0.5
});
- self.speed = 5 / 1.5 * 2 * 1.7;
+ self.speed = 6.5;
+ self.dashSpeed = 15;
+ self.lives = 3;
+ self.isFalling = false;
+ self.isDashing = false;
self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
+ // Boat movement logic
+ if (keys['ArrowLeft']) {
+ self.x -= self.speed;
}
- };
-});
-// AiDU class
-var AiDU = Container.expand(function () {
- var self = Container.call(this);
- var audiGraphics = self.attachAsset('AiDU', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 384.17 / 384.17,
- scaleY: 922.01 / 922.01
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
+ if (keys['ArrowRight']) {
+ self.x += self.speed;
}
- };
-});
-// AiphaTauri class
-var AiphaTauri = Container.expand(function () {
- var self = Container.call(this);
- var aiphaTauriGraphics = self.attachAsset('AiphaTauri', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.83,
- scaleY: 0.96
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
+ // Keep boat within screen bounds
+ if (self.x < 50) {
+ self.x = 50;
}
- };
-});
-// Aipine class
-var Aipine = Container.expand(function () {
- var self = Container.call(this);
- var aipineGraphics = self.attachAsset('Aipine', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.89,
- scaleY: 0.94
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
+ if (self.x > 1998) {
+ self.x = 1998;
}
};
});
-// AshtonMartin class
-var AshtonMartin = Container.expand(function () {
+// Floating Log class
+var FloatingLog = Container.expand(function () {
var self = Container.call(this);
- var astonMartinGraphics = self.attachAsset('AshtonMartin', {
+ var logGraphics = self.attachAsset('FloatingLog', {
anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.91,
- scaleY: 0.98
+ anchorY: 0.5
});
- self.speed = 5 / 1.5 * 2 * 1.7;
+ self.speedX = -5;
self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
+ self.x += self.speedX;
+ if (self.x < -logGraphics.width / 2) {
self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
}
};
});
-// BMiWMotorsport50YearAnniversary class
-var BMiWMotorsport50YearAnniversary = Container.expand(function () {
+// Storm Cloud class
+var StormCloud = Container.expand(function () {
var self = Container.call(this);
- var bmw50AnniversaryGraphics = self.attachAsset('BMiWMotorsport50YearAnniversary', {
+ var cloudGraphics = self.attachAsset('StormCloud', {
anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.89,
- scaleY: 0.94
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-// BMiW Willaims class
-var BMiWWillaims = Container.expand(function () {
- var self = Container.call(this);
- var bmwGraphics = self.attachAsset('BMiWWillaims', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.95,
- scaleY: 0.98
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-// BarRonda class
-var BarRonda = Container.expand(function () {
- var self = Container.call(this);
- var barRondaGraphics = self.attachAsset('BarRonda', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.97,
- scaleY: 0.95
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-var BlueBull = Container.expand(function () {
- var self = Container.call(this);
- var blueBullGraphics = self.attachAsset('BlueBull', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.8,
- scaleY: 0.89
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-var BrainGP = Container.expand(function () {
- var self = Container.call(this);
- var brainGPGraphics = self.attachAsset('BrainGP', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 1.0,
- scaleY: 1.0
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-var Cadillaic = Container.expand(function () {
- var self = Container.call(this);
- var cadillaicGraphics = self.attachAsset('Cadillaic', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 1.0,
- scaleY: 1.0
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-//<Assets used in the game will automatically appear here>
-// Car class
-var Car = Container.expand(function () {
- var self = Container.call(this);
- var carGraphics = self.attachAsset('RealBull', {
- anchorX: 0.5,
anchorY: 0.5
});
- self.speed = 0;
- self.maxSpeed = 10 * 1.7;
- self.acceleration = 0.2 * 1.7;
- self.deceleration = 0.1 * 1.7;
+ self.speedX = -6;
self.update = function () {
- self.y -= self.speed;
- if (self.speed > 0) {
- self.speed -= self.deceleration;
- }
- };
- self.accelerate = function () {
- if (self.speed < self.maxSpeed) {
- self.speed += self.acceleration;
- }
- };
-});
-var FRVR = Container.expand(function () {
- var self = Container.call(this);
- var frvrGraphics = self.attachAsset('FRVR', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 370 / 370,
- scaleY: 760 / 760
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
+ self.x += self.speedX;
+ if (self.x < -cloudGraphics.width / 2) {
self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
}
};
});
-// FerrAi class
-var FerrAi = Container.expand(function () {
+// Treasure Chest class
+var TreasureChest = Container.expand(function () {
var self = Container.call(this);
- var ferrAiGraphics = self.attachAsset('FerrAi', {
+ var chestGraphics = self.attachAsset('TreasureChest', {
anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 1.0,
- scaleY: 0.95
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-// ForceIndAi class
-var ForceIndAi = Container.expand(function () {
- var self = Container.call(this);
- var forceIndAiGraphics = self.attachAsset('ForceIndAi', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.83,
- scaleY: 0.94
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-// Grid class
-var Grid = Container.expand(function () {
- var self = Container.call(this);
- var gridGraphics = self.attachAsset('grid', {
- anchorX: 0.5,
anchorY: 0.5
});
- self.speed = 5 / 1.5 * 2 * 1.7;
+ self.speedX = -5;
self.update = function () {
- self.y += self.speed;
- if (self.y > 2732) {
+ self.x += self.speedX;
+ if (self.x < -chestGraphics.width / 2) {
self.destroy();
- var index = grids.indexOf(self);
- if (index > -1) {
- grids.splice(index, 1);
- }
}
};
});
-// Jaguair class
-var Jaguair = Container.expand(function () {
- var self = Container.call(this);
- var jaguairGraphics = self.attachAsset('Jaguair', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 1.0,
- scaleY: 1.0
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-// Jordain class
-var Jordain = Container.expand(function () {
- var self = Container.call(this);
- var jordainGraphics = self.attachAsset('Jordain', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.95,
- scaleY: 0.98
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-// McLairen class
-var McLairen = Container.expand(function () {
- var self = Container.call(this);
- var mclairenGraphics = self.attachAsset('McLairen', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 1.0,
- scaleY: 0.91
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-// MacLaren Ayrton Senna class
-var McLairenBrasil = Container.expand(function () {
- var self = Container.call(this);
- var mclarenGraphics = self.attachAsset('McLairenBrasil', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 1.0,
- scaleY: 0.91
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-var McLairenMP4 = Container.expand(function () {
- var self = Container.call(this);
- var mclarenMP4Graphics = self.attachAsset('McLairenMP4', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 1.0,
- scaleY: 0.91
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-// McLairenMercedesz class
-var McLairenMercedesz = Container.expand(function () {
- var self = Container.call(this);
- var mclarenMercedesGraphics = self.attachAsset('McLairenMercedesz', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.89,
- scaleY: 0.91
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-// McLairen Ronda MP4-30 (2015) class
-var McLairenRondaMP4302015 = Container.expand(function () {
- var self = Container.call(this);
- var mclarenRondaGraphics = self.attachAsset('McLairenRondaMP4302015', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.89,
- scaleY: 0.94
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-// Mercedesz2000 class
-var Mercedesz2000 = Container.expand(function () {
- var self = Container.call(this);
- var mercedesz2000Graphics = self.attachAsset('Mercedesz2000', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.89,
- scaleY: 0.94
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-var MercedeszAiGPerformance = Container.expand(function () {
- var self = Container.call(this);
- var mercedeszAiGPerformanceGraphics = self.attachAsset('MercedeszAiGPerformance', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.89,
- scaleY: 0.94
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-// MercedeszAiGPetronais class
-var MercedeszAiGPetronais = Container.expand(function () {
- var self = Container.call(this);
- var mercedesGraphics = self.attachAsset('MercedeszAiGPetronais', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.79,
- scaleY: 0.96
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-var Porshe = Container.expand(function () {
- var self = Container.call(this);
- var porsheGraphics = self.attachAsset('Porshe', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 1.0,
- scaleY: 1.0
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-// RealBull class
-var RealBull = Container.expand(function () {
- var self = Container.call(this);
- var realBullGraphics = self.attachAsset('RealBull', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 1.0,
- scaleY: 1.0
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-// Renaiult class
-var Renaiult = Container.expand(function () {
- var self = Container.call(this);
- var renaultGraphics = self.attachAsset('Renaiult', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 1.0,
- scaleY: 1.0
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-var RenaiultTelefonica = Container.expand(function () {
- var self = Container.call(this);
- var renaiultTelefonicaGraphics = self.attachAsset('RenaiultTelefonai', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 1.0,
- scaleY: 1.0
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-// SaiberKick class
-var SaiberKick = Container.expand(function () {
- var self = Container.call(this);
- var saiberKickGraphics = self.attachAsset('SaiberKick', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.89,
- scaleY: 0.94
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-// SaiberPetronais class
-var SaiberPetronais = Container.expand(function () {
- var self = Container.call(this);
- var saiberGraphics = self.attachAsset('SaiberPetronais', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.89,
- scaleY: 0.94
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-var TOTOYA = Container.expand(function () {
- var self = Container.call(this);
- var tGraphics = self.attachAsset('TOTOYA', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 1.0,
- scaleY: 1.0
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
-// Williams class
-var Willaims = Container.expand(function () {
- var self = Container.call(this);
- var williamsGraphics = self.attachAsset('Willaims', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 1.0,
- scaleY: 1.02
- });
- self.speed = 5 / 1.5 * 2 * 1.7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732 || obstacles.length > 4) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- };
-});
/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x87CEEB // Light blue background for water
});
/****
* Game Code
****/
-// Play background music
-LK.playMusic('v', {
- loop: true
-});
-function countCarType(carType) {
- return obstacles.filter(function (obstacle) {
- return obstacle.constructor.name === carType;
- }).length;
-}
-// Add keyboard event listeners for controlling the player's car
-var keys = {};
-game.on('keydown', function (event) {
- keys[event.code] = true;
- if (event.code === 'KeyA') {
- car.x -= car.speed;
- }
-});
-game.on('keyup', function (event) {
- keys[event.code] = false;
-});
-var racetrackSpeed = 0;
-var racetrackAcceleration = 4;
-var racetrack = LK.getAsset('racetrack', {
+var boat = game.addChild(new Boat());
+boat.x = 2048 / 2;
+boat.y = 2732 * 0.8;
+var oceanBackground = LK.getAsset('OceanBackground', {
anchorX: 0.5,
anchorY: 0.5,
- scaleX: 2048 / 2000,
- scaleY: 2732 / 2850,
x: 2048 / 2,
- y: 0
+ y: 2732 / 2
});
-game.addChild(racetrack);
-var racetrack2 = LK.getAsset('racetrack', {
+game.addChild(oceanBackground);
+var waves = LK.getAsset('OceanWaves', {
anchorX: 0.5,
anchorY: 0.5,
- scaleX: 2048 / 2000,
- scaleY: 2732 / 2850,
x: 2048 / 2,
- y: -2732
+ y: 2732 * 0.9
});
-game.addChild(racetrack2);
-var leftFrame = LK.getAsset('leftFrame', {
- anchorX: 0,
- anchorY: 0,
- x: 0,
- y: 0
-});
-game.addChild(leftFrame);
-var closingLine1 = LK.getAsset('closingLine1', {
- anchorX: 0,
- anchorY: 0,
- x: 50,
- y: 0
-});
-game.addChild(closingLine1);
-var rightFrame = LK.getAsset('rightFrame', {
- anchorX: 1,
- anchorY: 0,
- x: 2048,
- y: 0
-});
-game.addChild(rightFrame);
-var closingLine2 = LK.getAsset('closingLine2', {
- anchorX: 1,
- anchorY: 0,
- x: 2048 - 50,
- y: 0
-});
-game.addChild(closingLine2);
-var grids = [];
-for (var i = 0; i < 5; i++) {
- var grid = new Grid();
- grid.x = i % 2 === 0 ? 524 : 1524; // Alternate left and right
- grid.y = 2732 - 1000 - i * 1000; // Ensure all grids are positioned at the same distance apart
- if (!grids.some(function (existingGrid) {
- return existingGrid.x === grid.x && existingGrid.y === grid.y;
- })) {
- game.addChild(grid);
- grids.push(grid);
- }
-}
-game.addChild(car);
-var overtakenObstacles = 0;
-var car = game.addChild(new Car());
-car.x = 524; // Start from the grid on the left side of the map
-car.y = 2732 - 200 - 277 + 25;
+game.addChild(waves);
var obstacles = [];
-var carTypeLoadCounts = {};
+var powerups = [];
var score = 0;
-var lastSpawnTick = 0;
-var scoreTxt = new Text2('0', {
- size: 30,
- // Reduced to one-fifth
- fill: 0xFFFFFF
-});
-scoreTxt.anchor.set(0, 1); // Adjust anchor for bottom-left positioning
-LK.gui.bottomLeft.addChild(scoreTxt); // Move to bottom-left corner
-var timeTxt = new Text2('Current time: 0-0-0-0-0-0', {
- size: 30,
- // Same size as scoreTxt
- fill: 0xFFFFFF
-});
-timeTxt.anchor.set(0.5, 1); // Centered at the bottom
-LK.gui.bottom.addChild(timeTxt); // Add to bottom center
+var coinCount = 0;
function spawnObstacle() {
- if (obstacles.length >= 3) {
- return;
- } // Limit to a maximum of three cars on the track
- var carTypes = [RealBull, BlueBull, FerrAi, Willaims, MercedeszAiGPetronais, AiDU, AshtonMartin, BMiWWillaims, BMiWMotorsport50YearAnniversary, ALFRomeo, McLairenBrasil, Renaiult, RenaiultTelefonica, McLairen, Aipine, McLairenMercedesz, McLairenMP4, AiphaTauri, ForceIndAi, BarRonda, Jaguair, Jordain, TOTOYA, SaiberPetronais, McLairenRondaMP4302015, Mercedesz2000, SaiberKick, MercedeszAiGPerformance];
- carTypes.forEach(function (carType) {
- if (!carTypeLoadCounts[carType.name]) {
- carTypeLoadCounts[carType.name] = 0;
- }
- });
- var carTypeCounts = carTypes.map(function (carType) {
- return countCarType(carType.name);
- });
- if (carTypeCounts.every(function (count) {
- return count >= 2;
- })) {
- return;
- }
- var carTypes = [RealBull, BlueBull, FerrAi, Willaims, MercedeszAiGPetronais, AiDU, AshtonMartin, BMiWWillaims, BMiWMotorsport50YearAnniversary, ALFRomeo, McLairenBrasil, Renaiult, RenaiultTelefonica, McLairen, Aipine, McLairenMercedesz, McLairenMP4, AiphaTauri, ForceIndAi, FRVR, BarRonda, Jaguair, Jordain, TOTOYA, SaiberPetronais, SaiberKick, BrainGP, Cadillaic, Porshe, MercedeszAiGPerformance];
- var startX = 50 + 200; // Ensure at least 50 units from the left edge
- var spacing = (2048 - 100) / 4; // Adjust spacing to ensure at least 50 units from the right edge
- var carType;
- do {
- carType = carTypes[Math.floor(Math.random() * carTypes.length)];
- } while (carTypeLoadCounts[carType.name] >= 2 || carType === FRVR && carTypeLoadCounts[carType.name] >= 1);
- carTypeLoadCounts[carType.name]++;
- if (Object.values(carTypeLoadCounts).every(function (count) {
- return count >= 2;
- })) {
- for (var key in carTypeLoadCounts) {
- carTypeLoadCounts[key] = 0;
- }
- }
- var car = new carType();
- car.x = startX + Math.floor(Math.random() * 4) * spacing;
- car.y = 200; // Position all cars at the same y-coordinate
- obstacles.push(car);
- game.addChild(car);
+ var obstacleTypes = [FloatingLog, StormCloud];
+ var obstacle = new obstacleTypes[Math.floor(Math.random() * obstacleTypes.length)]();
+ obstacle.x = 2048 + obstacle.width / 2;
+ obstacle.y = Math.random() * (2732 * 0.6) + 2732 * 0.2;
+ obstacles.push(obstacle);
+ game.addChild(obstacle);
}
+function spawnPowerUp() {
+ var powerUpTypes = [TreasureChest];
+ var powerUp = new powerUpTypes[Math.floor(Math.random() * powerUpTypes.length)]();
+ powerUp.x = 2048 + powerUp.width / 2;
+ powerUp.y = Math.random() * (2732 * 0.6) + 2732 * 0.2;
+ powerups.push(powerUp);
+ game.addChild(powerUp);
+}
function updateScore() {
score += 1;
- scoreTxt.setText('OVERTAKING: ' + score);
+ coinCounter.setText('SCORE: ' + score);
}
-game.move = function (x, y, obj) {
- car.x = x;
-};
+var coinCounter = new Text2('0', {
+ size: 150,
+ fill: 0xFFFFFF
+});
+coinCounter.anchor.set(1, 0);
+LK.gui.topRight.addChild(coinCounter);
game.update = function () {
- car.update();
- // Calculate elapsed time
- var totalMilliseconds = Math.floor(LK.ticks * (1000 / 60)); // Convert ticks to milliseconds
- var hours = Math.floor(totalMilliseconds / 3600000);
- var minutes = Math.floor(totalMilliseconds % 3600000 / 60000);
- var seconds = Math.floor(totalMilliseconds % 60000 / 1000);
- var tenths = Math.floor(totalMilliseconds % 1000 / 100);
- var hundredths = Math.floor(totalMilliseconds % 100 / 10);
- var feelingMinute = Math.floor(totalMilliseconds % 10);
- // Update time display
- timeTxt.setText("Current time: ".concat(hours, "-").concat(minutes, "-").concat(seconds, "-").concat(tenths, "-").concat(hundredths, "-").concat(feelingMinute));
- // Update grid positions to match racetrack speed
- for (var i = grids.length - 1; i >= 0; i--) {
- grids[i].y += racetrackSpeed;
- if (grids[i].y > 2732) {
- grids[i].y = -1000; // Reset grid position for continuous scrolling
- }
- }
- racetrack.y += racetrackSpeed;
- racetrack2.y += racetrackSpeed;
- if (LK.ticks <= 60) {
- racetrackSpeed += racetrackAcceleration / 20; // Increase acceleration by one and a half times for the first second
- } else {
- racetrackSpeed += racetrackAcceleration / 60; // Normal acceleration
- }
- // Reset racetrack positions for continuous scrolling
- if (racetrack.y >= 2732) {
- racetrack.y = racetrack2.y - 2732;
- }
- if (racetrack2.y >= 2732) {
- racetrack2.y = racetrack.y - 2732;
- }
- // Update car position based on keyboard input
- if (keys['ArrowLeft'] || keys['KeyA']) {
- car.x -= car.speed;
- }
- if (keys['ArrowRight']) {
- car.x += car.speed;
- }
- if (keys['ArrowUp']) {
- car.accelerate();
- }
- // Check if more than 51% of the car is out of bounds and apply drifting
- var carWidth = car.width;
- var carLeftEdge = car.x - carWidth / 2;
- var carRightEdge = car.x + carWidth / 2;
- var fieldLeftEdge = 0;
- var fieldRightEdge = 2048;
- if (carLeftEdge < fieldLeftEdge) {
- if (carRightEdge < fieldLeftEdge + carWidth * 0.49) {
- // More than 51% of the car is out of bounds on the left
- car.x += car.speed * 0.5; // Drift right
- } else {
- car.x = fieldLeftEdge + carWidth / 2;
- }
- } else if (carRightEdge > fieldRightEdge) {
- if (carLeftEdge > fieldRightEdge - carWidth * 0.49) {
- // More than 51% of the car is out of bounds on the right
- car.x -= car.speed * 0.5; // Drift left
- } else {
- car.x = fieldRightEdge - carWidth / 2;
- }
- }
+ boat.update();
+ // Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].update();
- if (car.intersects(obstacles[i])) {
+ if (boat.intersects(obstacles[i])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
- if (obstacles[i].y - obstacles[i].height > 2732) {
- overtakenObstacles++;
+ if (obstacles[i].x < -obstacles[i].width / 2) {
obstacles[i].destroy();
obstacles.splice(i, 1);
}
}
- if (overtakenObstacles >= 10) {
- grid.visible = false;
+ // Update power-ups
+ for (var i = powerups.length - 1; i >= 0; i--) {
+ powerups[i].update();
+ if (boat.intersects(powerups[i])) {
+ LK.getSound('treasure_collect').play();
+ coinCount += 10;
+ updateScore();
+ powerups[i].destroy();
+ powerups.splice(i, 1);
+ }
+ if (powerups[i] && powerups[i].x < -powerups[i].width / 2) {
+ powerups[i].destroy();
+ powerups.splice(i, 1);
+ }
}
- if (LK.ticks > 240 && LK.ticks % 72 == 0) {
- // Spawn a car every 1.2 seconds (72 ticks)
+ // Spawn obstacles and power-ups
+ if (LK.ticks % 120 == 0) {
spawnObstacle();
- updateScore();
}
-};
\ No newline at end of file
+ if (LK.ticks % 240 == 0) {
+ spawnPowerUp();
+ }
+};
+// Handle keyboard input
+var keys = {};
+game.on('keydown', function (event) {
+ keys[event.code] = true;
+});
+game.on('keyup', function (event) {
+ keys[event.code] = false;
+});
\ No newline at end of file
shining moon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
a single shining yellowish golden coin with the boat on it. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
a colorful, cartoon style boat with an orange and blue color scheme. the boat has a small flag on top, round windows and a curved hull , with the BOAT text on it with bold letters. the design is vibrant, playful and optimized for a mobile game. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
white water bubble. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
single rock. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
gold sparkle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
single gold sparkle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
red shining heart symbol. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
whale head in octogonal box with green background asset. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
orange life rings asset that revive from water. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
single rounded white bubble firefly trail. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
shining sun cartoon style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
flying owl with blue gold color mix asset. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
coin magnet white blue red in color. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
warning asset. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows