User prompt
spawn 'Cactus', behaves the same way as "Bighorn"
Code edit (1 edits merged)
Please save this source code
User prompt
delete bighorn as soon as it collides with dunebuggy
User prompt
delete bighorn if collides with dunebuggy or if it leaves the screen
User prompt
if dunebuggy collides with "Bighorn", decrease Tires by 3%
User prompt
start tires at 100%
Code edit (2 edits merged)
Please save this source code
User prompt
randomly spawn 'Bighorn', drop down from top with speed 15
User prompt
if fuel =0, then game over
Code edit (2 edits merged)
Please save this source code
User prompt
decrease fuel by 1 gallon for every 3 distance
User prompt
Fuel is not showing 25
User prompt
start "Fuel:" at 25 Gallons, decrease it by 1 gallon for every 3 distance
User prompt
start Distance at 0, increase distance by 0.1 for every 1 second
User prompt
rename "Score" to "Distance:"
User prompt
add "Tires:" text below fuel
User prompt
Add "Fuel:" in white text below score
User prompt
delete "obstacle" and "supply"
User prompt
i can't see tires label
Code edit (1 edits merged)
Please save this source code
User prompt
add white text below health bar, "Tires"
Code edit (1 edits merged)
Please save this source code
User prompt
position "Fuel" next to health bar
User prompt
Put white Text "Fuel" to the left of heralth bar
User prompt
delete obstacle and supply boxes
/**** * Classes ****/ // Cactus class to represent the randomly spawned Cactus var Cactus = Container.expand(function () { var self = Container.call(this); var cactusGraphics = self.attachAsset('Cactus', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 15; self.update = function () { self.y += self.speed; }; }); //<Assets used in the game will automatically appear here> // DuneBuggy class to represent the player's vehicle var DuneBuggy = Container.expand(function () { var self = Container.call(this); var buggyGraphics = self.attachAsset('duneBuggy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { // Update logic for the buggy, if needed }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ var duneBuggy = game.addChild(new DuneBuggy()); duneBuggy.x = 2048 / 2; duneBuggy.y = 2732 - 200; var obstacles = []; var supplies = []; var score = 0; var scoreTxt = new Text2('Distance: 0', { size: 100, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var fuelTxt = new Text2('Fuel:', { size: 100, fill: "#ffffff" }); fuelTxt.anchor.set(0.5, 0); fuelTxt.y = scoreTxt.height; LK.gui.top.addChild(fuelTxt); var tiresTxt = new Text2('Tires:', { size: 100, fill: "#ffffff" }); tiresTxt.anchor.set(0.5, 0); tiresTxt.y = scoreTxt.height + fuelTxt.height; LK.gui.top.addChild(tiresTxt); var distance = 0; var fuel = 15; var tires = 100; fuelTxt.setText('Fuel: ' + fuel + ' Gallons'); game.update = function () { if (LK.ticks % 60 == 0) { distance += 0.1; scoreTxt.setText('Distance: ' + distance.toFixed(1)); if (distance % 2 < 0.1) { fuel -= 1; fuelTxt.setText('Fuel: ' + fuel + ' Gallons'); if (fuel <= 0) { LK.showGameOver(); } } // Spawn Cactus randomly from the top if (LK.ticks % 35 == 0) { var cactus = new Cactus(); cactus.x = Math.random() * 2048; cactus.y = 0; game.addChild(cactus); } // Check for collision between duneBuggy and Cactus for (var i = game.children.length - 1; i >= 0; i--) { if (game.children[i] instanceof Cactus) { if (duneBuggy.intersects(game.children[i])) { tires -= 3; // decrease tires by 3% tiresTxt.setText('Tires: ' + tires + '%'); // update tires text if (tires <= 0) { LK.showGameOver(); // game over if tires reach 0 } game.children[i].destroy(); // destroy Cactus on collision return; // return after destroying Cactus to prevent accessing it after destruction } else if (game.children[i].y > 2732) { game.children[i].destroy(); // destroy Cactus if it leaves the screen } } } } }; game.down = function (x, y, obj) { duneBuggy.x = x; }; game.move = function (x, y, obj) { duneBuggy.x = x; }; game.up = function (x, y, obj) { // No action needed on up event };
===================================================================
--- original.js
+++ change.js
@@ -1,11 +1,11 @@
/****
* Classes
****/
-// Bighorn class to represent the randomly spawned Bighorn
-var Bighorn = Container.expand(function () {
+// Cactus class to represent the randomly spawned Cactus
+var Cactus = Container.expand(function () {
var self = Container.call(this);
- var bighornGraphics = self.attachAsset('Bighorn', {
+ var cactusGraphics = self.attachAsset('Cactus', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
@@ -77,28 +77,28 @@
if (fuel <= 0) {
LK.showGameOver();
}
}
- // Spawn Bighorn randomly from the top
- if (LK.ticks % 25 == 0) {
- var bighorn = new Bighorn();
- bighorn.x = Math.random() * 2048;
- bighorn.y = 0;
- game.addChild(bighorn);
+ // Spawn Cactus randomly from the top
+ if (LK.ticks % 35 == 0) {
+ var cactus = new Cactus();
+ cactus.x = Math.random() * 2048;
+ cactus.y = 0;
+ game.addChild(cactus);
}
- // Check for collision between duneBuggy and Bighorn
+ // Check for collision between duneBuggy and Cactus
for (var i = game.children.length - 1; i >= 0; i--) {
- if (game.children[i] instanceof Bighorn) {
+ if (game.children[i] instanceof Cactus) {
if (duneBuggy.intersects(game.children[i])) {
tires -= 3; // decrease tires by 3%
tiresTxt.setText('Tires: ' + tires + '%'); // update tires text
if (tires <= 0) {
LK.showGameOver(); // game over if tires reach 0
}
- game.children[i].destroy(); // destroy Bighorn on collision
- return; // return after destroying Bighorn to prevent accessing it after destruction
+ game.children[i].destroy(); // destroy Cactus on collision
+ return; // return after destroying Cactus to prevent accessing it after destruction
} else if (game.children[i].y > 2732) {
- game.children[i].destroy(); // destroy Bighorn if it leaves the screen
+ game.children[i].destroy(); // destroy Cactus if it leaves the screen
}
}
}
}
sheep
Sound effect
crash
Sound effect
yelp
Sound effect
rabbit
Sound effect
runner
Sound effect
runner
Sound effect
roar
Sound effect
airwrench
Sound effect
liquid
Sound effect
music
Music
crash2
Sound effect
yehaw
Sound effect
woohoo
Sound effect
bird
Sound effect
splat
Sound effect
splat
Sound effect
gascanbonus
Sound effect
tirebonus
Sound effect