/****
* Classes
****/
// The assets will be automatically created and loaded by the LK engine
// Class for the Player
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Player movement logic goes here
};
});
// Class for the Puzzle Pieces
var PuzzlePiece = Container.expand(function () {
var self = Container.call(this);
var puzzlePieceGraphics = self.attachAsset('puzzlePiece', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Puzzle piece movement logic goes here
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize the player
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 / 2;
// Initialize the puzzle pieces
var puzzlePieces = [];
for (var i = 0; i < 10; i++) {
var puzzlePiece = game.addChild(new PuzzlePiece());
puzzlePiece.x = Math.random() * 2048;
puzzlePiece.y = Math.random() * 2732;
puzzlePieces.push(puzzlePiece);
}
// Game update function
game.update = function () {
// Check for collisions between the player and the puzzle pieces
for (var i = puzzlePieces.length - 1; i >= 0; i--) {
if (player.intersects(puzzlePieces[i])) {
// Remove the puzzle piece from the game
puzzlePieces[i].destroy();
puzzlePieces.splice(i, 1);
}
}
// Check if all puzzle pieces have been collected
if (puzzlePieces.length === 0) {
// Show game over
LK.showGameOver();
}
};
// Handle player movement
game.move = function (x, y, obj) {
player.x = x;
player.y = y;
}; /****
* Classes
****/
// The assets will be automatically created and loaded by the LK engine
// Class for the Player
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Player movement logic goes here
};
});
// Class for the Puzzle Pieces
var PuzzlePiece = Container.expand(function () {
var self = Container.call(this);
var puzzlePieceGraphics = self.attachAsset('puzzlePiece', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Puzzle piece movement logic goes here
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize the player
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 / 2;
// Initialize the puzzle pieces
var puzzlePieces = [];
for (var i = 0; i < 10; i++) {
var puzzlePiece = game.addChild(new PuzzlePiece());
puzzlePiece.x = Math.random() * 2048;
puzzlePiece.y = Math.random() * 2732;
puzzlePieces.push(puzzlePiece);
}
// Game update function
game.update = function () {
// Check for collisions between the player and the puzzle pieces
for (var i = puzzlePieces.length - 1; i >= 0; i--) {
if (player.intersects(puzzlePieces[i])) {
// Remove the puzzle piece from the game
puzzlePieces[i].destroy();
puzzlePieces.splice(i, 1);
}
}
// Check if all puzzle pieces have been collected
if (puzzlePieces.length === 0) {
// Show game over
LK.showGameOver();
}
};
// Handle player movement
game.move = function (x, y, obj) {
player.x = x;
player.y = y;
};