User prompt
Now so if a red tree touches a normal tree the tree will be destroyed
User prompt
Make birds not always appear on normal trees like 50/50 Of probability
User prompt
Add birds which will be like red trees but will appear from above to disturb the jump but they can only appear if there are no red trees below
User prompt
Now so the excavator can't jump more than twice in a row
User prompt
Ace the longest jump
User prompt
So the excavator jumps for longer to make it easier to avoid the red trees
User prompt
So the excavator jumps higher to make it easier to avoid the red trees
Initial prompt
Excavator festructor
/**** * Classes ****/ //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Class for the Excavator var Excavator = Container.expand(function () { var self = Container.call(this); var excavatorGraphics = self.attachAsset('excavator', { anchorX: 0.5, anchorY: 0.5 }); self.jumpHeight = 200; self.isJumping = false; self.jumpSpeed = 20; self.originalY = 0; self.jump = function () { if (!self.isJumping) { self.isJumping = true; self.originalY = self.y; } }; self.update = function () { if (self.isJumping) { self.y -= self.jumpSpeed; if (self.y <= self.originalY - self.jumpHeight) { self.isJumping = false; } } else if (self.y < self.originalY) { self.y += self.jumpSpeed; } }; }); // Class for Trees var Tree = Container.expand(function () { var self = Container.call(this); var treeGraphics = self.attachAsset('tree', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.isRed = false; self.update = function () { self.x -= self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ var excavator = game.addChild(new Excavator()); excavator.x = 200; excavator.y = 2000; var trees = []; var score = 0; var scoreTxt = new Text2('0', { size: 150, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); game.down = function (x, y, obj) { excavator.jump(); }; game.update = function () { excavator.update(); if (LK.ticks % 60 == 0) { var newTree = new Tree(); newTree.x = 2048; newTree.y = 2000; if (Math.random() < 0.2) { newTree.isRed = true; newTree.attachAsset('redTree', { anchorX: 0.5, anchorY: 0.5 }); } trees.push(newTree); game.addChild(newTree); } for (var i = trees.length - 1; i >= 0; i--) { var tree = trees[i]; tree.update(); if (tree.x < -100) { tree.destroy(); trees.splice(i, 1); continue; } if (excavator.intersects(tree)) { if (tree.isRed && !excavator.isJumping) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } else if (!tree.isRed) { score++; scoreTxt.setText(score); tree.destroy(); trees.splice(i, 1); if (score >= 50) { LK.showYouWin(); } } } } };
/****
* Classes
****/
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Class for the Excavator
var Excavator = Container.expand(function () {
var self = Container.call(this);
var excavatorGraphics = self.attachAsset('excavator', {
anchorX: 0.5,
anchorY: 0.5
});
self.jumpHeight = 200;
self.isJumping = false;
self.jumpSpeed = 20;
self.originalY = 0;
self.jump = function () {
if (!self.isJumping) {
self.isJumping = true;
self.originalY = self.y;
}
};
self.update = function () {
if (self.isJumping) {
self.y -= self.jumpSpeed;
if (self.y <= self.originalY - self.jumpHeight) {
self.isJumping = false;
}
} else if (self.y < self.originalY) {
self.y += self.jumpSpeed;
}
};
});
// Class for Trees
var Tree = Container.expand(function () {
var self = Container.call(this);
var treeGraphics = self.attachAsset('tree', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.isRed = false;
self.update = function () {
self.x -= self.speed;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
var excavator = game.addChild(new Excavator());
excavator.x = 200;
excavator.y = 2000;
var trees = [];
var score = 0;
var scoreTxt = new Text2('0', {
size: 150,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
game.down = function (x, y, obj) {
excavator.jump();
};
game.update = function () {
excavator.update();
if (LK.ticks % 60 == 0) {
var newTree = new Tree();
newTree.x = 2048;
newTree.y = 2000;
if (Math.random() < 0.2) {
newTree.isRed = true;
newTree.attachAsset('redTree', {
anchorX: 0.5,
anchorY: 0.5
});
}
trees.push(newTree);
game.addChild(newTree);
}
for (var i = trees.length - 1; i >= 0; i--) {
var tree = trees[i];
tree.update();
if (tree.x < -100) {
tree.destroy();
trees.splice(i, 1);
continue;
}
if (excavator.intersects(tree)) {
if (tree.isRed && !excavator.isJumping) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
} else if (!tree.isRed) {
score++;
scoreTxt.setText(score);
tree.destroy();
trees.splice(i, 1);
if (score >= 50) {
LK.showYouWin();
}
}
}
}
};
Excavator with 2d tender rockets. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Tree. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Red tree. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Nube. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Mud ground. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows