/**** * Classes ****/ // Class for Clue var Clue = Container.expand(function () { var self = Container.call(this); var clueGraphics = self.attachAsset('clue', { anchorX: 0.5, anchorY: 0.5 }); self.showClue = function () { // Logic to show clue }; }); // Class for Player var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.x = 1024; // Position player in the middle of the screen self.y = 1366; }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Class for Treasure var Treasure = Container.expand(function () { var self = Container.call(this); var treasureGraphics = self.attachAsset('treasure', { anchorX: 0.5, anchorY: 0.5 }); self.found = false; self.reveal = function () { if (!self.found) { self.found = true; LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); LK.effects.flashObject(self, 0x00ff00, 500); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize player, treasures and clues var player = game.addChild(new Player()); var treasures = []; var clues = []; var states = ["Johor", "Kedah", "Kelantan", "Malacca", "Negeri Sembilan", "Pahang", "Penang", "Perak", "Perlis", "Sabah", "Sarawak", "Selangor", "Terengganu"]; // Create treasures and clues for each state states.forEach(function (state, index) { for (var i = 0; i < 10; i++) { var treasure = new Treasure(); treasure.x = Math.random() * 2048; treasure.y = Math.random() * 2732; treasures.push(treasure); game.addChild(treasure); var clue = new Clue(); clue.x = Math.random() * 2048; clue.y = Math.random() * 2732; clues.push(clue); game.addChild(clue); } }); // Score display var scoreTxt = new Text2('0', { size: 150, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Handle touch events game.down = function (x, y, obj) { treasures.forEach(function (treasure) { if (treasure.intersects(player)) { treasure.reveal(); } }); clues.forEach(function (clue) { if (clue.intersects(player)) { clue.showClue(); } }); }; // Update game logic game.update = function () { // Move player towards touch position var speed = 5; // Player speed var dx = game.down.x - player.x; var dy = game.down.y - player.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > speed) { player.x += dx * speed / distance; player.y += dy * speed / distance; } };
/****
* Classes
****/
// Class for Clue
var Clue = Container.expand(function () {
var self = Container.call(this);
var clueGraphics = self.attachAsset('clue', {
anchorX: 0.5,
anchorY: 0.5
});
self.showClue = function () {
// Logic to show clue
};
});
// Class for Player
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 1024; // Position player in the middle of the screen
self.y = 1366;
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Class for Treasure
var Treasure = Container.expand(function () {
var self = Container.call(this);
var treasureGraphics = self.attachAsset('treasure', {
anchorX: 0.5,
anchorY: 0.5
});
self.found = false;
self.reveal = function () {
if (!self.found) {
self.found = true;
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
LK.effects.flashObject(self, 0x00ff00, 500);
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize player, treasures and clues
var player = game.addChild(new Player());
var treasures = [];
var clues = [];
var states = ["Johor", "Kedah", "Kelantan", "Malacca", "Negeri Sembilan", "Pahang", "Penang", "Perak", "Perlis", "Sabah", "Sarawak", "Selangor", "Terengganu"];
// Create treasures and clues for each state
states.forEach(function (state, index) {
for (var i = 0; i < 10; i++) {
var treasure = new Treasure();
treasure.x = Math.random() * 2048;
treasure.y = Math.random() * 2732;
treasures.push(treasure);
game.addChild(treasure);
var clue = new Clue();
clue.x = Math.random() * 2048;
clue.y = Math.random() * 2732;
clues.push(clue);
game.addChild(clue);
}
});
// Score display
var scoreTxt = new Text2('0', {
size: 150,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Handle touch events
game.down = function (x, y, obj) {
treasures.forEach(function (treasure) {
if (treasure.intersects(player)) {
treasure.reveal();
}
});
clues.forEach(function (clue) {
if (clue.intersects(player)) {
clue.showClue();
}
});
};
// Update game logic
game.update = function () {
// Move player towards touch position
var speed = 5; // Player speed
var dx = game.down.x - player.x;
var dy = game.down.y - player.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > speed) {
player.x += dx * speed / distance;
player.y += dy * speed / distance;
}
};
Treasure chest, like kept by the pirates with gold inside. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
stick on papers and envelops. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Man with glasses. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.