/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Bullet class representing the bullets fired by the player
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -10;
self.update = function () {
self.y += self.speed;
};
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Target class representing the targets to be hit
var Target = Container.expand(function () {
var self = Container.call(this);
var targetGraphics = self.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.y = -targetGraphics.height;
self.x = Math.random() * 2048;
}
};
});
// Tas class representing the stones falling from the top
var Tas = Container.expand(function () {
var self = Container.call(this);
var tasGraphics = self.attachAsset('tas', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.y = -tasGraphics.height;
self.x = Math.random() * 2048;
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize variables
var score = 0;
var bullets = [];
var targets = [];
var bulletCount = 5; // Initialize bullet count to 5
// Add the background asset to the game
var background = game.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
var scoreTxt = new Text2('0', {
size: 150,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Display bullet count
var bulletCountTxt = new Text2('Bullets: ' + bulletCount, {
size: 100,
fill: 0xFFFFFF
});
bulletCountTxt.anchor.set(1, 1); // Anchor to bottom right
LK.gui.bottomRight.addChild(bulletCountTxt);
// Initialize timer
var timer = 30;
var timerTxt = new Text2('Time: ' + timer, {
size: 100,
fill: 0xFFFFFF
});
timerTxt.anchor.set(1, 0); // Anchor to top right
LK.gui.topRight.addChild(timerTxt);
// Update timer every second
LK.setInterval(function () {
timer--;
timerTxt.setText('Time: ' + timer);
}, 1000);
// Create targets
for (var i = 0; i < 5; i++) {
var target = new Target();
target.x = Math.random() * 2048;
target.y = Math.random() * 2732;
targets.push(target);
game.addChild(target);
}
// Create tas
for (var i = 0; i < 5; i++) {
var tas = new Tas();
tas.x = Math.random() * 2048;
tas.y = Math.random() * 2732;
targets.push(tas);
game.addChild(tas);
}
// Handle shooting
var bulletCount = 5; // Initialize bullet count to 5
game.down = function (x, y, obj) {
if (bulletCount > 0 && y > 2732 / 2) {
// Check if bullet count is greater than 0 and the touch event is in the bottom half of the screen before firing
var newBullet = new Bullet();
newBullet.x = x;
newBullet.y = 2732; // Bullets start from the bottom of the screen
bullets.push(newBullet);
game.addChild(newBullet);
bulletCount--; // Decrease bullet count by 1 each time a bullet is fired
bulletCountTxt.setText('Bullets: ' + bulletCount); // Update bullet count display
// Play 'ab' music when the first bullet is fired
if (bullets.length === 1) {
LK.stopMusic();
LK.playMusic('ab');
}
}
};
// Update game state
game.update = function () {
for (var i = bullets.length - 1; i >= 0; i--) {
bullets[i].update();
if (bullets[i].y < -50) {
bullets[i].destroy();
bullets.splice(i, 1);
} else if (bullets[i].y >= 2732) {
bulletCount -= 4; // Decrease bullet count by 4
bulletCountTxt.setText('Bullets: ' + bulletCount); // Update bullet count display
score = Math.max(0, score - 2); // Decrease score by 2 but not below 0
scoreTxt.setText(score); // Update score display
bullets[i].destroy();
bullets.splice(i, 1);
}
}
for (var j = targets.length - 1; j >= 0; j--) {
targets[j].update();
for (var k = bullets.length - 1; k >= 0; k--) {
if (bullets[k].intersects(targets[j])) {
score += 1;
scoreTxt.setText(score);
targets[j].y = -targets[j].height;
targets[j].x = Math.random() * 2048;
targets[j].speed += 0.5; // Decrease the speed of the target
bulletCount += 2; // Increase bullet count by 2 when a bullet hits a target
LK.getSound('arda').play(); // Play 'arda' sound
// Check if the score is a multiple of 50 and score is greater than 100
if (score % 50 === 0 && score > 100) {
timer += 3; // Add 3 seconds to the timer
timerTxt.setText('Time: ' + timer); // Update timer display
} else if (score % 25 === 0) {
bulletCount += 5; // Add 5 bullets to the current bullet count
// If score is greater than 125, add 6 seconds to the timer, else add 10 seconds
timer += score > 125 ? 6 : 10;
timerTxt.setText('Time: ' + timer); // Update timer display
}
bulletCountTxt.setText('Bullets: ' + bulletCount); // Update bullet count display
LK.effects.flashObject(targets[j], 0xff0000, 500); // Add explosion effect
// Add light effect at the location where the bullet hits the target
var lightEffect = LK.getAsset('light', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.1,
scaleY: 0.1,
alpha: 0.8
});
lightEffect.x = bullets[k].x; // Position of the bullet
lightEffect.y = bullets[k].y; // Position of the bullet
game.addChild(lightEffect);
tween(lightEffect, {
scaleX: 1,
scaleY: 1,
alpha: 0
}, {
duration: 1000,
onFinish: function onFinish() {
lightEffect.destroy();
}
});
}
}
if (targets[j].y >= 2732) {
score = Math.max(0, score - 3); // Decrease score by 3 but not below 0
scoreTxt.setText(score); // Update score display
targets[j].y = -targets[j].height;
targets[j].x = Math.random() * 2048;
}
}
// Check if bullet count is 0 or timer is 0, if so, end the game
if (bulletCount <= 0 || timer === 0) {
LK.stopMusic();
LK.showGameOver();
}
if (LK.ticks === 0 || LK.getSound('ab').ended && bulletCount !== 0 && timer !== 0) {
LK.playMusic('ab');
}
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Bullet class representing the bullets fired by the player
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -10;
self.update = function () {
self.y += self.speed;
};
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Target class representing the targets to be hit
var Target = Container.expand(function () {
var self = Container.call(this);
var targetGraphics = self.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.y = -targetGraphics.height;
self.x = Math.random() * 2048;
}
};
});
// Tas class representing the stones falling from the top
var Tas = Container.expand(function () {
var self = Container.call(this);
var tasGraphics = self.attachAsset('tas', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.y = -tasGraphics.height;
self.x = Math.random() * 2048;
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize variables
var score = 0;
var bullets = [];
var targets = [];
var bulletCount = 5; // Initialize bullet count to 5
// Add the background asset to the game
var background = game.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
var scoreTxt = new Text2('0', {
size: 150,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Display bullet count
var bulletCountTxt = new Text2('Bullets: ' + bulletCount, {
size: 100,
fill: 0xFFFFFF
});
bulletCountTxt.anchor.set(1, 1); // Anchor to bottom right
LK.gui.bottomRight.addChild(bulletCountTxt);
// Initialize timer
var timer = 30;
var timerTxt = new Text2('Time: ' + timer, {
size: 100,
fill: 0xFFFFFF
});
timerTxt.anchor.set(1, 0); // Anchor to top right
LK.gui.topRight.addChild(timerTxt);
// Update timer every second
LK.setInterval(function () {
timer--;
timerTxt.setText('Time: ' + timer);
}, 1000);
// Create targets
for (var i = 0; i < 5; i++) {
var target = new Target();
target.x = Math.random() * 2048;
target.y = Math.random() * 2732;
targets.push(target);
game.addChild(target);
}
// Create tas
for (var i = 0; i < 5; i++) {
var tas = new Tas();
tas.x = Math.random() * 2048;
tas.y = Math.random() * 2732;
targets.push(tas);
game.addChild(tas);
}
// Handle shooting
var bulletCount = 5; // Initialize bullet count to 5
game.down = function (x, y, obj) {
if (bulletCount > 0 && y > 2732 / 2) {
// Check if bullet count is greater than 0 and the touch event is in the bottom half of the screen before firing
var newBullet = new Bullet();
newBullet.x = x;
newBullet.y = 2732; // Bullets start from the bottom of the screen
bullets.push(newBullet);
game.addChild(newBullet);
bulletCount--; // Decrease bullet count by 1 each time a bullet is fired
bulletCountTxt.setText('Bullets: ' + bulletCount); // Update bullet count display
// Play 'ab' music when the first bullet is fired
if (bullets.length === 1) {
LK.stopMusic();
LK.playMusic('ab');
}
}
};
// Update game state
game.update = function () {
for (var i = bullets.length - 1; i >= 0; i--) {
bullets[i].update();
if (bullets[i].y < -50) {
bullets[i].destroy();
bullets.splice(i, 1);
} else if (bullets[i].y >= 2732) {
bulletCount -= 4; // Decrease bullet count by 4
bulletCountTxt.setText('Bullets: ' + bulletCount); // Update bullet count display
score = Math.max(0, score - 2); // Decrease score by 2 but not below 0
scoreTxt.setText(score); // Update score display
bullets[i].destroy();
bullets.splice(i, 1);
}
}
for (var j = targets.length - 1; j >= 0; j--) {
targets[j].update();
for (var k = bullets.length - 1; k >= 0; k--) {
if (bullets[k].intersects(targets[j])) {
score += 1;
scoreTxt.setText(score);
targets[j].y = -targets[j].height;
targets[j].x = Math.random() * 2048;
targets[j].speed += 0.5; // Decrease the speed of the target
bulletCount += 2; // Increase bullet count by 2 when a bullet hits a target
LK.getSound('arda').play(); // Play 'arda' sound
// Check if the score is a multiple of 50 and score is greater than 100
if (score % 50 === 0 && score > 100) {
timer += 3; // Add 3 seconds to the timer
timerTxt.setText('Time: ' + timer); // Update timer display
} else if (score % 25 === 0) {
bulletCount += 5; // Add 5 bullets to the current bullet count
// If score is greater than 125, add 6 seconds to the timer, else add 10 seconds
timer += score > 125 ? 6 : 10;
timerTxt.setText('Time: ' + timer); // Update timer display
}
bulletCountTxt.setText('Bullets: ' + bulletCount); // Update bullet count display
LK.effects.flashObject(targets[j], 0xff0000, 500); // Add explosion effect
// Add light effect at the location where the bullet hits the target
var lightEffect = LK.getAsset('light', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.1,
scaleY: 0.1,
alpha: 0.8
});
lightEffect.x = bullets[k].x; // Position of the bullet
lightEffect.y = bullets[k].y; // Position of the bullet
game.addChild(lightEffect);
tween(lightEffect, {
scaleX: 1,
scaleY: 1,
alpha: 0
}, {
duration: 1000,
onFinish: function onFinish() {
lightEffect.destroy();
}
});
}
}
if (targets[j].y >= 2732) {
score = Math.max(0, score - 3); // Decrease score by 3 but not below 0
scoreTxt.setText(score); // Update score display
targets[j].y = -targets[j].height;
targets[j].x = Math.random() * 2048;
}
}
// Check if bullet count is 0 or timer is 0, if so, end the game
if (bulletCount <= 0 || timer === 0) {
LK.stopMusic();
LK.showGameOver();
}
if (LK.ticks === 0 || LK.getSound('ab').ended && bulletCount !== 0 && timer !== 0) {
LK.playMusic('ab');
}
};
merminin ucu y eksenin pozitif kısmına baksın böyle bir mermi tasarımı istiyorum. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
tekli balon resmi. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
havai fişek patlaması. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
background ıcın guzel ve yaratıcı resımler. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
taş resmi. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.