/****
* Classes
****/
// Class for bullets
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2
});
self.speedX = 10;
self.speedY = -10;
self.lifeTime = 300; // Bullet will live for 300 ticks
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
self.lifeTime -= 1;
if (self.lifeTime <= 0) {
self.destroy();
}
if (self.x < 0 || self.x > 2048) {
self.speedX *= -1;
}
if (self.y < 0 || self.y > 2732) {
self.speedY *= -1;
}
};
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Class for the main character
var Character = Container.expand(function () {
var self = Container.call(this);
var characterGraphics = self.attachAsset('character', {
anchorX: 0.5,
anchorY: 0.5
});
self.lives = 3;
self.shoot = function (direction) {
var bulletCount = Math.floor(fallingObjectsHit / 10) + 1;
for (var i = 0; i < bulletCount; i++) {
var bullet = new Bullet();
bullet.x = self.x;
bullet.y = self.y;
bullet.speedX = direction === 'right' ? 10 : -10;
game.addChild(bullet);
bullets.push(bullet);
}
LK.getSound('fireSound').play();
};
self.update = function () {
// Character movement logic
};
});
// Class for falling objects
var FallingObject = Container.expand(function () {
var self = Container.call(this);
var size = Math.floor(Math.random() * 20) + 5;
var color = Math.random() * 0xffffff;
var objectGraphics = self.attachAsset('fallingObject', {
width: size * 20,
height: size * 20,
color: color,
shape: 'ellipse',
anchorX: 0.5,
anchorY: 0.5
});
self.speed = Math.random() * 3 + 1;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.y = 0;
self.x = Math.random() * 2048;
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
LK.playMusic('morl');
// Add new background image
var background = game.attachAsset('background', {
// Add the background image to the game
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
var character = new Character();
character.x = 1024;
character.y = 2500;
game.addChild(character);
var bullets = [];
var fallingObjects = [];
var fallingObjectsHit = 0;
// Create initial falling objects
for (var i = 0; i < 5; i++) {
var fallingObject = new FallingObject();
fallingObject.x = Math.random() * 2048;
fallingObject.y = Math.random() * 1000;
fallingObjects.push(fallingObject);
game.addChild(fallingObject);
}
game.down = function (x, y, obj) {
if (x > character.x) {
character.x += 150;
character.shoot('right');
} else {
character.x -= 150;
character.shoot('left');
}
};
game.update = function () {
character.update();
bullets.forEach(function (bullet, index) {
bullet.update();
fallingObjects.forEach(function (fallingObject, fIndex) {
if (bullet.intersects(fallingObject)) {
bullet.lifeTime -= 50; // Reduce the bullet's lifeTime when it hits a falling object
if (bullet.lifeTime <= 0) {
bullet.destroy();
bullets.splice(index, 1);
}
if (fallingObject.width > 50) {
fallingObject.width /= 2;
fallingObject.height /= 2;
} else {
fallingObject.destroy();
fallingObjects.splice(fIndex, 1);
}
LK.setScore(LK.getScore() + 1);
fallingObjectsHit++;
}
});
});
fallingObjects.forEach(function (fallingObject) {
fallingObject.update();
if (fallingObject.intersects(character)) {
character.lives -= 1;
if (character.lives <= 0) {
LK.stopMusic();
LK.showGameOver();
}
}
});
if (LK.ticks % 240 == 0) {
var newFallingObject = new FallingObject();
newFallingObject.x = Math.random() * 2048;
newFallingObject.y = 0;
fallingObjects.push(newFallingObject);
game.addChild(newFallingObject);
}
}; /****
* Classes
****/
// Class for bullets
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2
});
self.speedX = 10;
self.speedY = -10;
self.lifeTime = 300; // Bullet will live for 300 ticks
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
self.lifeTime -= 1;
if (self.lifeTime <= 0) {
self.destroy();
}
if (self.x < 0 || self.x > 2048) {
self.speedX *= -1;
}
if (self.y < 0 || self.y > 2732) {
self.speedY *= -1;
}
};
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Class for the main character
var Character = Container.expand(function () {
var self = Container.call(this);
var characterGraphics = self.attachAsset('character', {
anchorX: 0.5,
anchorY: 0.5
});
self.lives = 3;
self.shoot = function (direction) {
var bulletCount = Math.floor(fallingObjectsHit / 10) + 1;
for (var i = 0; i < bulletCount; i++) {
var bullet = new Bullet();
bullet.x = self.x;
bullet.y = self.y;
bullet.speedX = direction === 'right' ? 10 : -10;
game.addChild(bullet);
bullets.push(bullet);
}
LK.getSound('fireSound').play();
};
self.update = function () {
// Character movement logic
};
});
// Class for falling objects
var FallingObject = Container.expand(function () {
var self = Container.call(this);
var size = Math.floor(Math.random() * 20) + 5;
var color = Math.random() * 0xffffff;
var objectGraphics = self.attachAsset('fallingObject', {
width: size * 20,
height: size * 20,
color: color,
shape: 'ellipse',
anchorX: 0.5,
anchorY: 0.5
});
self.speed = Math.random() * 3 + 1;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.y = 0;
self.x = Math.random() * 2048;
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
LK.playMusic('morl');
// Add new background image
var background = game.attachAsset('background', {
// Add the background image to the game
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
var character = new Character();
character.x = 1024;
character.y = 2500;
game.addChild(character);
var bullets = [];
var fallingObjects = [];
var fallingObjectsHit = 0;
// Create initial falling objects
for (var i = 0; i < 5; i++) {
var fallingObject = new FallingObject();
fallingObject.x = Math.random() * 2048;
fallingObject.y = Math.random() * 1000;
fallingObjects.push(fallingObject);
game.addChild(fallingObject);
}
game.down = function (x, y, obj) {
if (x > character.x) {
character.x += 150;
character.shoot('right');
} else {
character.x -= 150;
character.shoot('left');
}
};
game.update = function () {
character.update();
bullets.forEach(function (bullet, index) {
bullet.update();
fallingObjects.forEach(function (fallingObject, fIndex) {
if (bullet.intersects(fallingObject)) {
bullet.lifeTime -= 50; // Reduce the bullet's lifeTime when it hits a falling object
if (bullet.lifeTime <= 0) {
bullet.destroy();
bullets.splice(index, 1);
}
if (fallingObject.width > 50) {
fallingObject.width /= 2;
fallingObject.height /= 2;
} else {
fallingObject.destroy();
fallingObjects.splice(fIndex, 1);
}
LK.setScore(LK.getScore() + 1);
fallingObjectsHit++;
}
});
});
fallingObjects.forEach(function (fallingObject) {
fallingObject.update();
if (fallingObject.intersects(character)) {
character.lives -= 1;
if (character.lives <= 0) {
LK.stopMusic();
LK.showGameOver();
}
}
});
if (LK.ticks % 240 == 0) {
var newFallingObject = new FallingObject();
newFallingObject.x = Math.random() * 2048;
newFallingObject.y = 0;
fallingObjects.push(newFallingObject);
game.addChild(newFallingObject);
}
};
Mancınık. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
gülle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
yanan gök taşı. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
beyaz gökyüzü ay delikli. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.