/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Arrow class var Arrow = Container.expand(function () { var self = Container.call(this); var arrowGraphics = self.attachAsset('arrow', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { // Apply physics self.speedY = (self.speedY || 0) + 0.2; // further reduced gravity self.y += Math.sin(self.rotation) * self.speed + self.speedY; self.x += Math.cos(self.rotation) * self.speed; }; }); // Balloon class var Balloon = Container.expand(function () { var self = Container.call(this); var balloonColors = ['redBalloon', 'greenBalloon', 'blueBalloon']; var randomColor = balloonColors[Math.floor(Math.random() * balloonColors.length)]; var balloonGraphics = self.attachAsset(randomColor, { anchorX: 0.5, anchorY: 0.5 }); self.speed = Math.random() * 2; self.active = false; self.update = function () { if (self.active) { self.y -= self.speed; } }; self.reset = function () { self.active = false; self.y = 2732; self.x = Math.random() * 2048; }; self.activate = function () { self.active = true; }; }); // PowerUp class var PowerUp = Container.expand(function () { var self = Container.call(this); var powerUpGraphics = self.attachAsset('powerUp', { anchorX: 0.5, anchorY: 0.5 }); self.speed = Math.random() * 5 + 1; self.update = function () { self.y -= self.speed; }; }); // Stickman class var Stickman = Container.expand(function () { var self = Container.call(this); var stickmanGraphics = self.attachAsset('stickman', { anchorX: 0.5, anchorY: 0.5, tint: 0xADD8E6 }); self.update = function () { // Stickman can have some movement logic if needed }; }); // Target class var Target = Container.expand(function () { var self = Container.call(this); var targetGraphics = self.attachAsset('target', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Targets can have some movement logic if needed }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xdc0a04 }); /**** * Game Code ****/ var background = game.attachAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); // Create a timer to spawn balloons at a regular interval var balloonSpawnTimer = LK.setInterval(function () { for (var i = 0; i < wave; i++) { createTarget(); } }, 2000); // Spawn balloons every 2 seconds var arrows = []; var stickman = new Stickman(); stickman.x = 2048 / 2; stickman.y = 2732 / 2; game.addChild(stickman); var targets = []; var wave = 1; var score = 0; var scoreTxt = new Text2('0', { size: 150, fill: "#00008B" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var balloonSkips = 5; var balloonSkipIcons = []; for (var i = 0; i < balloonSkips; i++) { var balloonSkipIcon = LK.getAsset('balloonSkip', { anchorX: 0.0, anchorY: 0.0, x: i * 120, y: 0 }); balloonSkipIcons.push(balloonSkipIcon); LK.gui.topLeft.addChild(balloonSkipIcon); } // Create initial target function createTarget() { var balloon = new Balloon(); balloon.x = Math.random() * 2048; balloon.y = 2732; targets.push(balloon); game.addChild(balloon); } // Update score function updateScore() { scoreTxt.setText(score); } // Handle shooting arrows game.down = function (x, y, obj) { // Do nothing on mouse down }; var isMouseDown = false; game.down = function (x, y, obj) { isMouseDown = true; }; game.up = function (x, y, obj) { if (isMouseDown) { var arrow = new Arrow(); arrow.x = stickman.x + 50; // Adjust the x-coordinate to match the hand of the stickman arrow.y = stickman.y - 50; // Adjust the y-coordinate to match the hand of the stickman arrow.rotation = Math.atan2(stickman.y - y, stickman.x - x); stickman.rotation = arrow.rotation; var distance = Math.sqrt(Math.pow(stickman.x - x, 2) + Math.pow(stickman.y - y, 2)); arrow.speed = distance / 50; arrows.push(arrow); game.addChild(arrow); // Play a different sound LK.getSound('differentSound').play(); isMouseDown = false; } }; game.move = function (x, y, obj) { if (isMouseDown) { // Rotate the stickman towards the mouse pointer stickman.rotation = Math.atan2(stickman.y - y, stickman.x - x); } }; // Game update loop game.update = function () { // Update and check arrows for (var i = arrows.length - 1; i >= 0; i--) { var arrow = arrows[i]; arrow.update(); // Remove off-screen arrows if (arrow.y < -50 || arrow.y > 2732 || arrow.x < 0 || arrow.x > 2048) { arrow.destroy(); arrows.splice(i, 1); continue; } // Check for collisions with targets for (var j = targets.length - 1; j >= 0; j--) { var target = targets[j]; if (arrow.intersects(target)) { // Update score score += 2; updateScore(); // Destroy target target.destroy(); targets.splice(j, 1); // Play sound LK.getSound('arrowHit').play(); // Check for wave increase if (score % 50 == 0) { wave++; var waveText = new Text2('Wave ' + wave, { size: 150, fill: "#00008B" }); waveText.anchor.set(0.5, 0.5); LK.gui.center.addChild(waveText); LK.setTimeout(function () { waveText.destroy(); }, 2000); // Remove instruction text after wave 1 if (wave == 2) { instructionTxt.destroy(); } } break; } } } // Update and check targets for (var j = targets.length - 1; j >= 0; j--) { var target = targets[j]; target.update(); // Reset off-screen targets if (target.y < -50 || target.y > 2732 || target.x < 0 || target.x > 2048) { target.destroy(); targets.splice(j, 1); // Decrease balloon skips balloonSkips--; if (balloonSkips >= 0) { balloonSkipIcons[balloonSkips].destroy(); balloonSkipIcons.splice(balloonSkips, 1); // Flash screen red LK.effects.flashScreen(0xff0000, 1000); } // Score remains the same when a balloon is skipped // Check for game over if (balloonSkips <= 0) { LK.showGameOver(); LK.gui.center.addChild(new Text2('Final Score: ' + score, { size: 150, fill: "#ffffff" })); } } } // Increase the speed of balloons in each wave for (var j = 0; j < targets.length; j++) { var target = targets[j]; if (!target.active) { target.speed += wave * 0.1; // Increase the speed by 10% for each wave target.activate(); } } // Check for power up collection for (var i = 0; i < game.children.length; i++) { var child = game.children[i]; if (child instanceof PowerUp && child.intersects(stickman)) { // Destroy all targets for (var j = targets.length - 1; j >= 0; j--) { targets[j].destroy(); targets.splice(j, 1); } // Destroy the power up child.destroy(); } } }; // Initialize first target createTarget(); // Show wave 1 at the start of the game var waveText = new Text2('Wave ' + wave, { size: 150, fill: "#ffffff" }); waveText.anchor.set(0.5, 0.5); LK.gui.center.addChild(waveText); LK.setTimeout(function () { waveText.destroy(); }, 2000); // Add instruction text at the bottom center of the screen var instructionTxt = new Text2('Click And Drag Behind to Shoot With More Power', { size: 50, fill: "#00008B" }); instructionTxt.anchor.set(0.5, 1); // Anchor at the bottom center LK.gui.bottom.addChild(instructionTxt);
/****
* Classes
****/
//<Assets used in the game will automatically appear here>
// Arrow class
var Arrow = Container.expand(function () {
var self = Container.call(this);
var arrowGraphics = self.attachAsset('arrow', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.update = function () {
// Apply physics
self.speedY = (self.speedY || 0) + 0.2; // further reduced gravity
self.y += Math.sin(self.rotation) * self.speed + self.speedY;
self.x += Math.cos(self.rotation) * self.speed;
};
});
// Balloon class
var Balloon = Container.expand(function () {
var self = Container.call(this);
var balloonColors = ['redBalloon', 'greenBalloon', 'blueBalloon'];
var randomColor = balloonColors[Math.floor(Math.random() * balloonColors.length)];
var balloonGraphics = self.attachAsset(randomColor, {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = Math.random() * 2;
self.active = false;
self.update = function () {
if (self.active) {
self.y -= self.speed;
}
};
self.reset = function () {
self.active = false;
self.y = 2732;
self.x = Math.random() * 2048;
};
self.activate = function () {
self.active = true;
};
});
// PowerUp class
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.attachAsset('powerUp', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = Math.random() * 5 + 1;
self.update = function () {
self.y -= self.speed;
};
});
// Stickman class
var Stickman = Container.expand(function () {
var self = Container.call(this);
var stickmanGraphics = self.attachAsset('stickman', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xADD8E6
});
self.update = function () {
// Stickman can have some movement logic if needed
};
});
// Target class
var Target = Container.expand(function () {
var self = Container.call(this);
var targetGraphics = self.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Targets can have some movement logic if needed
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xdc0a04
});
/****
* Game Code
****/
var background = game.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
// Create a timer to spawn balloons at a regular interval
var balloonSpawnTimer = LK.setInterval(function () {
for (var i = 0; i < wave; i++) {
createTarget();
}
}, 2000); // Spawn balloons every 2 seconds
var arrows = [];
var stickman = new Stickman();
stickman.x = 2048 / 2;
stickman.y = 2732 / 2;
game.addChild(stickman);
var targets = [];
var wave = 1;
var score = 0;
var scoreTxt = new Text2('0', {
size: 150,
fill: "#00008B"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var balloonSkips = 5;
var balloonSkipIcons = [];
for (var i = 0; i < balloonSkips; i++) {
var balloonSkipIcon = LK.getAsset('balloonSkip', {
anchorX: 0.0,
anchorY: 0.0,
x: i * 120,
y: 0
});
balloonSkipIcons.push(balloonSkipIcon);
LK.gui.topLeft.addChild(balloonSkipIcon);
}
// Create initial target
function createTarget() {
var balloon = new Balloon();
balloon.x = Math.random() * 2048;
balloon.y = 2732;
targets.push(balloon);
game.addChild(balloon);
}
// Update score
function updateScore() {
scoreTxt.setText(score);
}
// Handle shooting arrows
game.down = function (x, y, obj) {
// Do nothing on mouse down
};
var isMouseDown = false;
game.down = function (x, y, obj) {
isMouseDown = true;
};
game.up = function (x, y, obj) {
if (isMouseDown) {
var arrow = new Arrow();
arrow.x = stickman.x + 50; // Adjust the x-coordinate to match the hand of the stickman
arrow.y = stickman.y - 50; // Adjust the y-coordinate to match the hand of the stickman
arrow.rotation = Math.atan2(stickman.y - y, stickman.x - x);
stickman.rotation = arrow.rotation;
var distance = Math.sqrt(Math.pow(stickman.x - x, 2) + Math.pow(stickman.y - y, 2));
arrow.speed = distance / 50;
arrows.push(arrow);
game.addChild(arrow);
// Play a different sound
LK.getSound('differentSound').play();
isMouseDown = false;
}
};
game.move = function (x, y, obj) {
if (isMouseDown) {
// Rotate the stickman towards the mouse pointer
stickman.rotation = Math.atan2(stickman.y - y, stickman.x - x);
}
};
// Game update loop
game.update = function () {
// Update and check arrows
for (var i = arrows.length - 1; i >= 0; i--) {
var arrow = arrows[i];
arrow.update();
// Remove off-screen arrows
if (arrow.y < -50 || arrow.y > 2732 || arrow.x < 0 || arrow.x > 2048) {
arrow.destroy();
arrows.splice(i, 1);
continue;
}
// Check for collisions with targets
for (var j = targets.length - 1; j >= 0; j--) {
var target = targets[j];
if (arrow.intersects(target)) {
// Update score
score += 2;
updateScore();
// Destroy target
target.destroy();
targets.splice(j, 1);
// Play sound
LK.getSound('arrowHit').play();
// Check for wave increase
if (score % 50 == 0) {
wave++;
var waveText = new Text2('Wave ' + wave, {
size: 150,
fill: "#00008B"
});
waveText.anchor.set(0.5, 0.5);
LK.gui.center.addChild(waveText);
LK.setTimeout(function () {
waveText.destroy();
}, 2000);
// Remove instruction text after wave 1
if (wave == 2) {
instructionTxt.destroy();
}
}
break;
}
}
}
// Update and check targets
for (var j = targets.length - 1; j >= 0; j--) {
var target = targets[j];
target.update();
// Reset off-screen targets
if (target.y < -50 || target.y > 2732 || target.x < 0 || target.x > 2048) {
target.destroy();
targets.splice(j, 1);
// Decrease balloon skips
balloonSkips--;
if (balloonSkips >= 0) {
balloonSkipIcons[balloonSkips].destroy();
balloonSkipIcons.splice(balloonSkips, 1);
// Flash screen red
LK.effects.flashScreen(0xff0000, 1000);
}
// Score remains the same when a balloon is skipped
// Check for game over
if (balloonSkips <= 0) {
LK.showGameOver();
LK.gui.center.addChild(new Text2('Final Score: ' + score, {
size: 150,
fill: "#ffffff"
}));
}
}
}
// Increase the speed of balloons in each wave
for (var j = 0; j < targets.length; j++) {
var target = targets[j];
if (!target.active) {
target.speed += wave * 0.1; // Increase the speed by 10% for each wave
target.activate();
}
}
// Check for power up collection
for (var i = 0; i < game.children.length; i++) {
var child = game.children[i];
if (child instanceof PowerUp && child.intersects(stickman)) {
// Destroy all targets
for (var j = targets.length - 1; j >= 0; j--) {
targets[j].destroy();
targets.splice(j, 1);
}
// Destroy the power up
child.destroy();
}
}
};
// Initialize first target
createTarget();
// Show wave 1 at the start of the game
var waveText = new Text2('Wave ' + wave, {
size: 150,
fill: "#ffffff"
});
waveText.anchor.set(0.5, 0.5);
LK.gui.center.addChild(waveText);
LK.setTimeout(function () {
waveText.destroy();
}, 2000);
// Add instruction text at the bottom center of the screen
var instructionTxt = new Text2('Click And Drag Behind to Shoot With More Power', {
size: 50,
fill: "#00008B"
});
instructionTxt.anchor.set(0.5, 1); // Anchor at the bottom center
LK.gui.bottom.addChild(instructionTxt);
Ballon Skiped. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Needle Shooting Stickman. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A clear blue sky with fluffy white clouds drifting lazily across.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.