/**** * Classes ****/ // Background class representing the game's background var Background = Container.expand(function () { var self = Container.call(this); var backgroundGraphics = self.attachAsset('background', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Update logic for the background }; }); // Bone class representing collectible items var Bone = Container.expand(function () { var self = Container.call(this); var boneGraphics = self.attachAsset('bone', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.y += 5; // Move bone downwards }; }); // Obstacle class representing obstacles to avoid var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.y += 7; // Move obstacle downwards }; }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Skeleton class representing the player character var Skeleton = Container.expand(function () { var self = Container.call(this); var skeletonGraphics = self.attachAsset('skeleton', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { // Update logic for the skeleton }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize arrays to keep track of bones and obstacles var bones = []; var obstacles = []; // Create the game's background var background = game.addChild(new Background()); background.x = 2048 / 2; background.y = 2732 / 2; // Create the skeleton player character var skeleton = game.addChild(new Skeleton()); skeleton.x = 2048 / 2; skeleton.y = 2732 - 200; // Function to handle movement function handleMove(x, y, obj) { skeleton.x = x; } // Add event listeners for touch/mouse events game.down = function (x, y, obj) { handleMove(x, y, obj); }; game.move = function (x, y, obj) { handleMove(x, y, obj); }; // Game update loop game.update = function () { // Update the game's background background.update(); // Update bones for (var i = bones.length - 1; i >= 0; i--) { var bone = bones[i]; bone.update(); if (bone.y > 2732) { bone.destroy(); bones.splice(i, 1); } else if (skeleton.intersects(bone)) { bone.destroy(); bones.splice(i, 1); // Add points for collecting bones LK.setScore(LK.getScore() + 10); scoreTxt.setText(LK.getScore()); } } // Update obstacles for (var j = obstacles.length - 1; j >= 0; j--) { var obstacle = obstacles[j]; obstacle.update(); if (obstacle.y > 2732) { obstacle.destroy(); obstacles.splice(j, 1); } else if (skeleton.intersects(obstacle)) { LK.effects.flashScreen(0xff0000, 1000); // Subtract points for hitting obstacles LK.setScore(LK.getScore() - 20); scoreTxt.setText(LK.getScore()); if (LK.getScore() <= 0) { LK.showGameOver(); } } } // Spawn new bones and obstacles if (LK.ticks % 60 == 0) { var newBone = new Bone(); newBone.x = Math.random() * 2048; newBone.y = -50; bones.push(newBone); game.addChild(newBone); } if (LK.ticks % 90 == 0) { var newObstacle = new Obstacle(); newObstacle.x = Math.random() * 2048; newObstacle.y = -50; obstacles.push(newObstacle); game.addChild(newObstacle); } }; // Display score var scoreTxt = new Text2('0', { size: 150, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Set base points for the game LK.setScore(0); scoreTxt.setText(LK.getScore()); ;
/****
* Classes
****/
// Background class representing the game's background
var Background = Container.expand(function () {
var self = Container.call(this);
var backgroundGraphics = self.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Update logic for the background
};
});
// Bone class representing collectible items
var Bone = Container.expand(function () {
var self = Container.call(this);
var boneGraphics = self.attachAsset('bone', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.y += 5; // Move bone downwards
};
});
// Obstacle class representing obstacles to avoid
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.y += 7; // Move obstacle downwards
};
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Skeleton class representing the player character
var Skeleton = Container.expand(function () {
var self = Container.call(this);
var skeletonGraphics = self.attachAsset('skeleton', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.update = function () {
// Update logic for the skeleton
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize arrays to keep track of bones and obstacles
var bones = [];
var obstacles = [];
// Create the game's background
var background = game.addChild(new Background());
background.x = 2048 / 2;
background.y = 2732 / 2;
// Create the skeleton player character
var skeleton = game.addChild(new Skeleton());
skeleton.x = 2048 / 2;
skeleton.y = 2732 - 200;
// Function to handle movement
function handleMove(x, y, obj) {
skeleton.x = x;
}
// Add event listeners for touch/mouse events
game.down = function (x, y, obj) {
handleMove(x, y, obj);
};
game.move = function (x, y, obj) {
handleMove(x, y, obj);
};
// Game update loop
game.update = function () {
// Update the game's background
background.update();
// Update bones
for (var i = bones.length - 1; i >= 0; i--) {
var bone = bones[i];
bone.update();
if (bone.y > 2732) {
bone.destroy();
bones.splice(i, 1);
} else if (skeleton.intersects(bone)) {
bone.destroy();
bones.splice(i, 1);
// Add points for collecting bones
LK.setScore(LK.getScore() + 10);
scoreTxt.setText(LK.getScore());
}
}
// Update obstacles
for (var j = obstacles.length - 1; j >= 0; j--) {
var obstacle = obstacles[j];
obstacle.update();
if (obstacle.y > 2732) {
obstacle.destroy();
obstacles.splice(j, 1);
} else if (skeleton.intersects(obstacle)) {
LK.effects.flashScreen(0xff0000, 1000);
// Subtract points for hitting obstacles
LK.setScore(LK.getScore() - 20);
scoreTxt.setText(LK.getScore());
if (LK.getScore() <= 0) {
LK.showGameOver();
}
}
}
// Spawn new bones and obstacles
if (LK.ticks % 60 == 0) {
var newBone = new Bone();
newBone.x = Math.random() * 2048;
newBone.y = -50;
bones.push(newBone);
game.addChild(newBone);
}
if (LK.ticks % 90 == 0) {
var newObstacle = new Obstacle();
newObstacle.x = Math.random() * 2048;
newObstacle.y = -50;
obstacles.push(newObstacle);
game.addChild(newObstacle);
}
};
// Display score
var scoreTxt = new Text2('0', {
size: 150,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Set base points for the game
LK.setScore(0);
scoreTxt.setText(LK.getScore());
;
skeleton hair blu felpa rosso. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
monster dark red meta blu. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
pizza mg. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows