/**** * Classes ****/ // Hunter class representing the enemies var Hunter = Container.expand(function () { var self = Container.call(this); var hunterGraphics = self.attachAsset('hunter', { 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 } }; }); // Tree class representing the obstacles var Tree = Container.expand(function () { var self = Container.call(this); var treeGraphics = self.attachAsset('tree', { anchorX: 0.5, anchorY: 0.5 }); }); //<Assets used in the game will automatically appear here> // Wolf class representing the player character var Wolf = Container.expand(function () { var self = Container.call(this); var wolfGraphics = self.attachAsset('wolf', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { // Wolf movement logic can be added here }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x228B22 // Init game with forest green background }); /**** * Game Code ****/ // Initialize game variables var startTime = Date.now(); var scoreDisplay = new Text2('0', { size: 150, fill: "#ffffff" }); scoreDisplay.anchor.set(0.5, 0); LK.gui.top.addChild(scoreDisplay); var wolf = game.addChild(new Wolf()); wolf.x = 2048 / 2; wolf.y = 2732 - 150; var hunters = []; for (var i = 0; i < 5; i++) { var hunter = new Hunter(); hunter.x = Math.random() * 2048; hunter.y = Math.random() * -2732; hunters.push(hunter); game.addChild(hunter); } var trees = []; for (var i = 0; i < 10; i++) { var tree = new Tree(); tree.x = Math.random() * 2048; tree.y = Math.random() * 2732; trees.push(tree); game.addChild(tree); } // Handle touch/mouse movement game.move = function (x, y, obj) { wolf.x = x; wolf.y = y; }; // Update game state game.update = function () { var elapsedTime = Date.now() - startTime; scoreDisplay.setText(elapsedTime.toFixed(3)); for (var i = 0; i < hunters.length; i++) { hunters[i].update(); if (wolf.intersects(hunters[i])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } if (hunters[i].y > 2732) { var newHunter = new Hunter(); newHunter.x = Math.random() * 2048; newHunter.y = Math.random() * -2732; hunters.push(newHunter); game.addChild(newHunter); } } };
/****
* Classes
****/
// Hunter class representing the enemies
var Hunter = Container.expand(function () {
var self = Container.call(this);
var hunterGraphics = self.attachAsset('hunter', {
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
}
};
});
// Tree class representing the obstacles
var Tree = Container.expand(function () {
var self = Container.call(this);
var treeGraphics = self.attachAsset('tree', {
anchorX: 0.5,
anchorY: 0.5
});
});
//<Assets used in the game will automatically appear here>
// Wolf class representing the player character
var Wolf = Container.expand(function () {
var self = Container.call(this);
var wolfGraphics = self.attachAsset('wolf', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.update = function () {
// Wolf movement logic can be added here
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x228B22 // Init game with forest green background
});
/****
* Game Code
****/
// Initialize game variables
var startTime = Date.now();
var scoreDisplay = new Text2('0', {
size: 150,
fill: "#ffffff"
});
scoreDisplay.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreDisplay);
var wolf = game.addChild(new Wolf());
wolf.x = 2048 / 2;
wolf.y = 2732 - 150;
var hunters = [];
for (var i = 0; i < 5; i++) {
var hunter = new Hunter();
hunter.x = Math.random() * 2048;
hunter.y = Math.random() * -2732;
hunters.push(hunter);
game.addChild(hunter);
}
var trees = [];
for (var i = 0; i < 10; i++) {
var tree = new Tree();
tree.x = Math.random() * 2048;
tree.y = Math.random() * 2732;
trees.push(tree);
game.addChild(tree);
}
// Handle touch/mouse movement
game.move = function (x, y, obj) {
wolf.x = x;
wolf.y = y;
};
// Update game state
game.update = function () {
var elapsedTime = Date.now() - startTime;
scoreDisplay.setText(elapsedTime.toFixed(3));
for (var i = 0; i < hunters.length; i++) {
hunters[i].update();
if (wolf.intersects(hunters[i])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
if (hunters[i].y > 2732) {
var newHunter = new Hunter();
newHunter.x = Math.random() * 2048;
newHunter.y = Math.random() * -2732;
hunters.push(newHunter);
game.addChild(newHunter);
}
}
};
Wolf puppy 8-bit character cute and adorable. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8-bit character that is a hunter. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8-bit pine tree. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.