/****
* Classes
****/
//<Write imports for supported plugins here>
// Define the Cat class
var Cat = Container.expand(function () {
var self = Container.call(this);
var catGraphics = self.attachAsset('cat', {
anchorX: 0.5,
anchorY: 0.5
});
self.lives = 3;
self.swordSwing = function (x, y) {
// Logic for swinging the sword
console.log("Swinging sword at", x, y);
};
});
// Define the Enemy class
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2;
self.update = function () {
self.y += self.speed;
};
self.down = function (x, y, obj) {
self.destroy();
LK.getSound('Frash').play();
var newAsset = game.addChild(new NewAsset());
newAsset.x = self.x;
newAsset.y = self.y;
LK.setScore(LK.getScore() + 1); // Increase score by 1
};
});
// Define the NewAsset class
var NewAsset = Container.expand(function () {
var self = Container.call(this);
var newAssetGraphics = self.attachAsset('newAsset', {
anchorX: 0.5,
anchorY: 0.5
});
});
// Define the Sword class
var Sword = Container.expand(function () {
var self = Container.call(this);
var swordGraphics = self.attachAsset('sword', {
anchorX: 0.5,
anchorY: 0.5
});
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x008000 //Init game with green background
});
/****
* Game Code
****/
var background = game.addChild(LK.getAsset('background', {}));
background.scale.x = 2048 / background.width;
background.scale.y = 2732 / background.height;
background.x = 2048 / 2;
background.y = 2732 / 2;
// Initialize game variables
var self = game;
var sword;
self.down = function (x, y, obj) {
sword = game.addChild(new Sword());
sword.x = x;
sword.y = y;
};
// Play the 'Muny' music track
LK.playMusic('Muny');
var cat = game.addChild(new Cat());
cat.x = 2048 / 2 - 200;
cat.y = 2732 - 200;
var enemies = [];
var lastIntersecting = false;
// Create score text and position it at the top right corner
var scoreTxt = new Text2('0', {
size: 150,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(1, 0); // Sets anchor to the top right corner of the text.
LK.gui.topRight.addChild(scoreTxt);
// Function to spawn enemies
function spawnEnemy() {
var enemy = new Enemy();
enemy.x = Math.random() * 2048;
enemy.y = 0;
enemies.push(enemy);
game.addChild(enemy);
}
// Handle game move events
game.move = function (x, y, obj) {
if (cat.intersects(obj)) {
cat.swordSwing(x, y);
for (var i = enemies.length - 1; i >= 0; i--) {
if (enemies[i].intersects(cat)) {
enemies[i].destroy();
enemies.splice(i, 1);
}
}
}
};
// Handle game update events
game.update = function () {
for (var i = enemies.length - 1; i >= 0; i--) {
enemies[i].update();
if (enemies[i].y > 2732) {
enemies[i].destroy();
enemies.splice(i, 1);
cat.lives -= 1;
if (cat.lives <= 0) {
LK.showGameOver();
}
}
}
if (LK.ticks % 60 == 0) {
spawnEnemy();
}
if (LK.ticks % 10 == 0 && sword) {
sword.destroy();
sword = null;
}
};
2 ayak üstünde yürüyen cat. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Dog. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Blood realistic
Kulübe. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows