User prompt
at distance=20, increase speed of all drops to 20
User prompt
at distance=10, increase speed of all drops to 17
Code edit (1 edits merged)
Please save this source code
User prompt
cant see dune buggy now?
User prompt
delete asset immediately upon collision with dunebuggy
Code edit (11 edits merged)
Please save this source code
User prompt
do not spawn drops on top of each other, decrease spawn rate if necessary
Code edit (1 edits merged)
Please save this source code
User prompt
keep dunebuggy in the middle half of the screen
User prompt
keep dunebuggy in the middle of the screen
User prompt
dont angle the dunebuggy, keep it straight
User prompt
angle the dunebuggy into the direction it is moving
User prompt
drop 'gascan' and 'tire' in their on lines
User prompt
angle 'duneBuggy' into the direction it's moving
User prompt
spawn 'gascan' and 'tire' with separation from the other drops
User prompt
show "Tires" at 100% at the beginning of the game
User prompt
for every 3 distance, spawn 'tire'. when dunebuggy collides with 'tire', increase tire by 2%, with a max of 100% for "Tires"
User prompt
delete all assets when they leave the screen
User prompt
spawn 'gascan' separately from other drops
User prompt
if 'gascan', collides with dunebuggy, increase fuel by 2 gallons
User prompt
every 5 distance, drop a 'gascan', which increases fuel by 2 gallons
User prompt
slightly increase the spawn rate of the dropping assets
User prompt
dont spawn everything all at once at the start
User prompt
spawn 'Yucca', behaves the same as the others
User prompt
spawn 'Turtle', behaves the same as the others
/**** * Classes ****/ // Bighorn class to represent the randomly spawned Bighorn var Bighorn = Container.expand(function () { var self = Container.call(this); var bighornGraphics = self.attachAsset('Bighorn', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 15; self.update = function () { self.y += self.speed; }; }); // 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; }; }); // Coyote class to represent the randomly spawned Coyote var Coyote = Container.expand(function () { var self = Container.call(this); var coyoteGraphics = self.attachAsset('Coyote', { 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 }; }); // Joshua class to represent the randomly spawned Joshua var Joshua = Container.expand(function () { var self = Container.call(this); var joshuaGraphics = self.attachAsset('Joshua', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 15; self.update = function () { self.y += self.speed; }; }); // Mojave class to represent the randomly spawned Mojave var Mojave = Container.expand(function () { var self = Container.call(this); var mojaveGraphics = self.attachAsset('Mojave', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 15; self.update = function () { self.y += self.speed; }; }); // Rabbit class to represent the randomly spawned Rabbit var Rabbit = Container.expand(function () { var self = Container.call(this); var rabbitGraphics = self.attachAsset('Rabbit', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 15; self.update = function () { self.y += self.speed; }; }); // Roadrunner class to represent the randomly spawned Roadrunner var Roadrunner = Container.expand(function () { var self = Container.call(this); var roadrunnerGraphics = self.attachAsset('Roadrunner', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 15; self.update = function () { self.y += self.speed; }; }); // Scorpion class to represent the randomly spawned Scorpion var Scorpion = Container.expand(function () { var self = Container.call(this); var scorpionGraphics = self.attachAsset('Scorpion', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 15; self.update = function () { self.y += self.speed; }; }); // Snake class to represent the randomly spawned Snake var Snake = Container.expand(function () { var self = Container.call(this); var snakeGraphics = self.attachAsset('Snake', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 15; self.update = function () { self.y += self.speed; }; }); // Spider class to represent the randomly spawned Spider var Spider = Container.expand(function () { var self = Container.call(this); var spiderGraphics = self.attachAsset('Spider', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 15; self.update = function () { self.y += self.speed; }; }); // Tumble class to represent the randomly spawned Tumble var Tumble = Container.expand(function () { var self = Container.call(this); var tumbleGraphics = self.attachAsset('Tumble', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 15; self.update = function () { self.y += self.speed; }; }); // Turtle class to represent the randomly spawned Turtle var Turtle = Container.expand(function () { var self = Container.call(this); var turtleGraphics = self.attachAsset('Turtle', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 15; self.update = function () { self.y += self.speed; }; }); /**** * 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 Bighorn, Cactus and Coyote at different intervals if (LK.ticks % 50 == 0) { var bighorn = new Bighorn(); bighorn.x = Math.random() * 2048; bighorn.y = 0; game.addChild(bighorn); } if (LK.ticks % 70 == 0) { var cactus = new Cactus(); cactus.x = Math.random() * 2048; cactus.y = 0; game.addChild(cactus); } if (LK.ticks % 90 == 0) { var coyote = new Coyote(); coyote.x = Math.random() * 2048; coyote.y = 0; game.addChild(coyote); } if (LK.ticks % 110 == 0) { var joshua = new Joshua(); joshua.x = Math.random() * 2048; joshua.y = 0; game.addChild(joshua); } if (LK.ticks % 130 == 0) { var mojave = new Mojave(); mojave.x = Math.random() * 2048; mojave.y = 0; game.addChild(mojave); } if (LK.ticks % 150 == 0) { var rabbit = new Rabbit(); rabbit.x = Math.random() * 2048; rabbit.y = 0; game.addChild(rabbit); } if (LK.ticks % 170 == 0) { var roadrunner = new Roadrunner(); roadrunner.x = Math.random() * 2048; roadrunner.y = 0; game.addChild(roadrunner); } if (LK.ticks % 190 == 0) { var scorpion = new Scorpion(); scorpion.x = Math.random() * 2048; scorpion.y = 0; game.addChild(scorpion); } if (LK.ticks % 210 == 0) { var snake = new Snake(); snake.x = Math.random() * 2048; snake.y = 0; game.addChild(snake); } if (LK.ticks % 230 == 0) { var spider = new Spider(); spider.x = Math.random() * 2048; spider.y = 0; game.addChild(spider); } if (LK.ticks % 250 == 0) { var tumble = new Tumble(); tumble.x = Math.random() * 2048; tumble.y = 0; game.addChild(tumble); } if (LK.ticks % 270 == 0) { var turtle = new Turtle(); turtle.x = Math.random() * 2048; turtle.y = 0; game.addChild(turtle); } // Check for collision between duneBuggy and Bighorn, Cactus, Coyote, Joshua, Mojave, Rabbit, Roadrunner, Scorpion, Snake, Spider, Tumble, or Turtle for (var i = game.children.length - 1; i >= 0; i--) { if (game.children[i] instanceof Bighorn || game.children[i] instanceof Cactus || game.children[i] instanceof Coyote || game.children[i] instanceof Joshua || game.children[i] instanceof Mojave || game.children[i] instanceof Rabbit || game.children[i] instanceof Roadrunner || game.children[i] instanceof Scorpion || game.children[i] instanceof Snake || game.children[i] instanceof Spider || game.children[i] instanceof Tumble || game.children[i] instanceof Turtle) { 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, Cactus, Coyote, Joshua, Mojave, Rabbit, Roadrunner, Scorpion, Snake, or Spider on collision return; // return after destroying to prevent accessing it after destruction } else if (game.children[i].y > 2732) { game.children[i].destroy(); // destroy 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 };
/****
* Classes
****/
// Bighorn class to represent the randomly spawned Bighorn
var Bighorn = Container.expand(function () {
var self = Container.call(this);
var bighornGraphics = self.attachAsset('Bighorn', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.update = function () {
self.y += self.speed;
};
});
// 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;
};
});
// Coyote class to represent the randomly spawned Coyote
var Coyote = Container.expand(function () {
var self = Container.call(this);
var coyoteGraphics = self.attachAsset('Coyote', {
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
};
});
// Joshua class to represent the randomly spawned Joshua
var Joshua = Container.expand(function () {
var self = Container.call(this);
var joshuaGraphics = self.attachAsset('Joshua', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.update = function () {
self.y += self.speed;
};
});
// Mojave class to represent the randomly spawned Mojave
var Mojave = Container.expand(function () {
var self = Container.call(this);
var mojaveGraphics = self.attachAsset('Mojave', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.update = function () {
self.y += self.speed;
};
});
// Rabbit class to represent the randomly spawned Rabbit
var Rabbit = Container.expand(function () {
var self = Container.call(this);
var rabbitGraphics = self.attachAsset('Rabbit', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.update = function () {
self.y += self.speed;
};
});
// Roadrunner class to represent the randomly spawned Roadrunner
var Roadrunner = Container.expand(function () {
var self = Container.call(this);
var roadrunnerGraphics = self.attachAsset('Roadrunner', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.update = function () {
self.y += self.speed;
};
});
// Scorpion class to represent the randomly spawned Scorpion
var Scorpion = Container.expand(function () {
var self = Container.call(this);
var scorpionGraphics = self.attachAsset('Scorpion', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.update = function () {
self.y += self.speed;
};
});
// Snake class to represent the randomly spawned Snake
var Snake = Container.expand(function () {
var self = Container.call(this);
var snakeGraphics = self.attachAsset('Snake', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.update = function () {
self.y += self.speed;
};
});
// Spider class to represent the randomly spawned Spider
var Spider = Container.expand(function () {
var self = Container.call(this);
var spiderGraphics = self.attachAsset('Spider', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.update = function () {
self.y += self.speed;
};
});
// Tumble class to represent the randomly spawned Tumble
var Tumble = Container.expand(function () {
var self = Container.call(this);
var tumbleGraphics = self.attachAsset('Tumble', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.update = function () {
self.y += self.speed;
};
});
// Turtle class to represent the randomly spawned Turtle
var Turtle = Container.expand(function () {
var self = Container.call(this);
var turtleGraphics = self.attachAsset('Turtle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.update = function () {
self.y += self.speed;
};
});
/****
* 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 Bighorn, Cactus and Coyote at different intervals
if (LK.ticks % 50 == 0) {
var bighorn = new Bighorn();
bighorn.x = Math.random() * 2048;
bighorn.y = 0;
game.addChild(bighorn);
}
if (LK.ticks % 70 == 0) {
var cactus = new Cactus();
cactus.x = Math.random() * 2048;
cactus.y = 0;
game.addChild(cactus);
}
if (LK.ticks % 90 == 0) {
var coyote = new Coyote();
coyote.x = Math.random() * 2048;
coyote.y = 0;
game.addChild(coyote);
}
if (LK.ticks % 110 == 0) {
var joshua = new Joshua();
joshua.x = Math.random() * 2048;
joshua.y = 0;
game.addChild(joshua);
}
if (LK.ticks % 130 == 0) {
var mojave = new Mojave();
mojave.x = Math.random() * 2048;
mojave.y = 0;
game.addChild(mojave);
}
if (LK.ticks % 150 == 0) {
var rabbit = new Rabbit();
rabbit.x = Math.random() * 2048;
rabbit.y = 0;
game.addChild(rabbit);
}
if (LK.ticks % 170 == 0) {
var roadrunner = new Roadrunner();
roadrunner.x = Math.random() * 2048;
roadrunner.y = 0;
game.addChild(roadrunner);
}
if (LK.ticks % 190 == 0) {
var scorpion = new Scorpion();
scorpion.x = Math.random() * 2048;
scorpion.y = 0;
game.addChild(scorpion);
}
if (LK.ticks % 210 == 0) {
var snake = new Snake();
snake.x = Math.random() * 2048;
snake.y = 0;
game.addChild(snake);
}
if (LK.ticks % 230 == 0) {
var spider = new Spider();
spider.x = Math.random() * 2048;
spider.y = 0;
game.addChild(spider);
}
if (LK.ticks % 250 == 0) {
var tumble = new Tumble();
tumble.x = Math.random() * 2048;
tumble.y = 0;
game.addChild(tumble);
}
if (LK.ticks % 270 == 0) {
var turtle = new Turtle();
turtle.x = Math.random() * 2048;
turtle.y = 0;
game.addChild(turtle);
}
// Check for collision between duneBuggy and Bighorn, Cactus, Coyote, Joshua, Mojave, Rabbit, Roadrunner, Scorpion, Snake, Spider, Tumble, or Turtle
for (var i = game.children.length - 1; i >= 0; i--) {
if (game.children[i] instanceof Bighorn || game.children[i] instanceof Cactus || game.children[i] instanceof Coyote || game.children[i] instanceof Joshua || game.children[i] instanceof Mojave || game.children[i] instanceof Rabbit || game.children[i] instanceof Roadrunner || game.children[i] instanceof Scorpion || game.children[i] instanceof Snake || game.children[i] instanceof Spider || game.children[i] instanceof Tumble || game.children[i] instanceof Turtle) {
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, Cactus, Coyote, Joshua, Mojave, Rabbit, Roadrunner, Scorpion, Snake, or Spider on collision
return; // return after destroying to prevent accessing it after destruction
} else if (game.children[i].y > 2732) {
game.children[i].destroy(); // destroy 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
};
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