/****
* Classes
****/
// Assets will be automatically created based on usage in the code.
// Astronaut class
var Astronaut = Container.expand(function () {
var self = Container.call(this);
var astronautGraphics = self.attachAsset('astronaut', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Astronaut update logic here
};
});
// Door class
var Door = Container.expand(function (isCorrect) {
var self = Container.call(this);
var doorGraphics = self.attachAsset(isCorrect ? 'doorCorrect' : 'doorWrong', {
anchorX: 0.5,
anchorY: 0.5
});
self.isCorrect = isCorrect;
});
// Hedgehog class
var Hedgehog = Container.expand(function () {
var self = Container.call(this);
var hedgehogGraphics = self.attachAsset('hedgehog', {
anchorX: 0.5,
anchorY: 0.5
});
self.rampage = function () {
// Hedgehog rampage logic here
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
var astronaut = game.addChild(new Astronaut());
astronaut.x = 1024; // Center horizontally
astronaut.y = 2732 - 200; // Position at the bottom
var doors = [];
var correctDoorIndex = Math.floor(Math.random() * 3); // Randomly select the correct door
for (var i = 0; i < 3; i++) {
var door = game.addChild(new Door(i === correctDoorIndex));
door.x = 512 + i * 512; // Position doors with equal spacing
door.y = 1366; // Center vertically
doors.push(door);
door.on('down', function (obj) {
var pos = obj.event.getLocalPosition(game);
var touchedDoor = doors.find(d => d.containsPoint(pos));
if (touchedDoor) {
if (touchedDoor.isCorrect) {
// Open the door and proceed to next level or show success
console.log("Correct door! Proceeding...");
} else {
// Trigger hedgehog rampage
var hedgehog = game.addChild(new Hedgehog());
hedgehog.x = touchedDoor.x;
hedgehog.y = touchedDoor.y;
hedgehog.rampage();
}
}
});
}
LK.on('tick', function () {
astronaut.update();
// Update game logic here
});
an astronaut. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a green door. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a crooked door with holes in it. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a hedgehog. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.