/**** * Classes ****/ // Define a Cat class var Cat = Container.expand(function () { var self = Container.call(this); var catGraphics = self.attachAsset('cat', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.y = -100; // Reset position to top self.x = Math.random() * 2048; // Randomize x position } }; }); // Define a Gold class var Gold = Container.expand(function () { var self = Container.call(this); var goldGraphics = self.attachAsset('gold', { anchorX: 0.5, anchorY: 0.5 }); }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Define a Player class var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { // Player update logic if needed }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Light blue background }); /**** * Game Code ****/ var sky = game.attachAsset('space', { anchorX: 0, anchorY: 0 }); // Initialize player var player = game.addChild(new Player()); player.x = 1024; // Center horizontally player.y = 2400; // Near bottom // Initialize gold var golds = []; for (var i = 0; i < Math.round(1 * 1.75 * 0.75 * 2); i++) { var gold = new Gold(); gold.x = Math.random() * 2048; // Randomize x position gold.y = Math.random() * 2732; // Randomize y position golds.push(gold); game.addChild(gold); } // Initialize cats var cats = []; for (var i = 0; i < Math.round(24 * 1.3 * 0.95 * 0.9); i++) { // Decrease the number of cats by 10% var cat = new Cat(); cat.x = Math.random() * 2048; cat.y = Math.random() * -2732; // Start off-screen cats.push(cat); game.addChild(cat); } // Handle player movement game.move = function (x, y, obj) { player.x = x; player.y = y; }; // Game update loop game.update = function () { // Check if player intersects with any gold for (var i = 0; i < golds.length; i++) { if (player.intersects(golds[i])) { // Increase score LK.setScore(LK.getScore() + 1); // Move gold to a new random position golds[i].x = Math.random() * 2048; golds[i].y = Math.random() * 2732; } } // Update cats for (var i = 0; i < cats.length; i++) { cats[i].update(); if (player.intersects(cats[i])) { // Flash screen red for 1 second to show collision LK.effects.flashScreen(0xff0000, 1000); // Show game over LK.showGameOver(); } } };
/****
* Classes
****/
// Define a Cat class
var Cat = Container.expand(function () {
var self = Container.call(this);
var catGraphics = self.attachAsset('cat', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.y = -100; // Reset position to top
self.x = Math.random() * 2048; // Randomize x position
}
};
});
// Define a Gold class
var Gold = Container.expand(function () {
var self = Container.call(this);
var goldGraphics = self.attachAsset('gold', {
anchorX: 0.5,
anchorY: 0.5
});
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Define a Player class
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.update = function () {
// Player update logic if needed
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Light blue background
});
/****
* Game Code
****/
var sky = game.attachAsset('space', {
anchorX: 0,
anchorY: 0
});
// Initialize player
var player = game.addChild(new Player());
player.x = 1024; // Center horizontally
player.y = 2400; // Near bottom
// Initialize gold
var golds = [];
for (var i = 0; i < Math.round(1 * 1.75 * 0.75 * 2); i++) {
var gold = new Gold();
gold.x = Math.random() * 2048; // Randomize x position
gold.y = Math.random() * 2732; // Randomize y position
golds.push(gold);
game.addChild(gold);
}
// Initialize cats
var cats = [];
for (var i = 0; i < Math.round(24 * 1.3 * 0.95 * 0.9); i++) {
// Decrease the number of cats by 10%
var cat = new Cat();
cat.x = Math.random() * 2048;
cat.y = Math.random() * -2732; // Start off-screen
cats.push(cat);
game.addChild(cat);
}
// Handle player movement
game.move = function (x, y, obj) {
player.x = x;
player.y = y;
};
// Game update loop
game.update = function () {
// Check if player intersects with any gold
for (var i = 0; i < golds.length; i++) {
if (player.intersects(golds[i])) {
// Increase score
LK.setScore(LK.getScore() + 1);
// Move gold to a new random position
golds[i].x = Math.random() * 2048;
golds[i].y = Math.random() * 2732;
}
}
// Update cats
for (var i = 0; i < cats.length; i++) {
cats[i].update();
if (player.intersects(cats[i])) {
// Flash screen red for 1 second to show collision
LK.effects.flashScreen(0xff0000, 1000);
// Show game over
LK.showGameOver();
}
}
};
Kedi pixel art. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Çizmeli kedi pixel art. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Coin piksel sanatı. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Pixel art uzun gri koridor. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows