User prompt
make simple maze and reduce gold
User prompt
hadirkan musuh dalam maze
User prompt
buat aturan dinding tidak bisa ditembus
User prompt
player bisa menembak dengan swipe
User prompt
hapus batas waktu
User prompt
buat 10 background
User prompt
perkecil ukuran maze dan letakkan di bawah layar
User prompt
tap control untuk player
Code edit (1 edits merged)
Please save this source code
User prompt
Maze Hunter: Golden Ball Chase
Initial prompt
create a maze in the middle with random entrance. hunting a golden balls
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var GoldenBall = Container.expand(function () { var self = Container.call(this); var ballGraphics = self.attachAsset('goldenBall', { anchorX: 0.5, anchorY: 0.5 }); self.collected = false; self.update = function () { if (!self.collected) { ballGraphics.rotation += 0.05; ballGraphics.scaleX = 1 + Math.sin(LK.ticks * 0.1) * 0.1; ballGraphics.scaleY = 1 + Math.sin(LK.ticks * 0.1) * 0.1; } }; self.collect = function () { if (!self.collected) { self.collected = true; tween(ballGraphics, { scaleX: 0, scaleY: 0, alpha: 0 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { self.visible = false; } }); } }; return self; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 4; self.targetX = 0; self.targetY = 0; self.update = function () { var dx = self.targetX - self.x; var dy = self.targetY - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 2) { self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } }; self.setTarget = function (x, y) { self.targetX = x; self.targetY = y; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2c3e50 }); /**** * Game Code ****/ var CELL_SIZE = 48; var MAZE_WIDTH = 20; var MAZE_HEIGHT = 25; var MAZE_START_X = (2048 - MAZE_WIDTH * CELL_SIZE) / 2; var MAZE_START_Y = 2732 - MAZE_HEIGHT * CELL_SIZE - 100; var maze = []; var walls = []; var floors = []; var player; var goldenBalls = []; var gameTimer = 180; // 3 minutes var totalBalls = 0; var collectedBalls = 0; var backgrounds = []; // Create background elements function createBackgrounds() { var backgroundAssets = ['bg1', 'bg2', 'bg3', 'bg4', 'bg5', 'bg6', 'bg7', 'bg8', 'bg9', 'bg10']; for (var i = 0; i < backgroundAssets.length; i++) { var bg = game.addChild(LK.getAsset(backgroundAssets[i], { anchorX: 0.5, anchorY: 0.5, alpha: 0.3 })); // Random positioning across the screen bg.x = Math.random() * 2048; bg.y = Math.random() * (2732 - MAZE_HEIGHT * CELL_SIZE - 200) + 100; // Random rotation bg.rotation = Math.random() * Math.PI * 2; backgrounds.push(bg); } } // Tap controls - no drag node needed // Timer display var timerText = new Text2('03:00', { size: 60, fill: 0xFFFFFF }); timerText.anchor.set(0.5, 0); LK.gui.top.addChild(timerText); // Score display var scoreText = new Text2('Balls: 0/0', { size: 50, fill: 0xFFD700 }); scoreText.anchor.set(1, 0); LK.gui.topRight.addChild(scoreText); scoreText.x = -20; scoreText.y = 80; function generateMaze() { // Initialize maze with walls for (var y = 0; y < MAZE_HEIGHT; y++) { maze[y] = []; for (var x = 0; x < MAZE_WIDTH; x++) { maze[y][x] = 1; // 1 = wall, 0 = path } } // Simple maze generation using recursive backtracking var stack = []; var startX = 1; var startY = 1; maze[startY][startX] = 0; stack.push({ x: startX, y: startY }); var directions = [{ x: 0, y: -2 }, // up { x: 2, y: 0 }, // right { x: 0, y: 2 }, // down { x: -2, y: 0 } // left ]; while (stack.length > 0) { var current = stack[stack.length - 1]; var neighbors = []; for (var i = 0; i < directions.length; i++) { var nx = current.x + directions[i].x; var ny = current.y + directions[i].y; if (nx > 0 && nx < MAZE_WIDTH - 1 && ny > 0 && ny < MAZE_HEIGHT - 1 && maze[ny][nx] === 1) { neighbors.push({ x: nx, y: ny, dir: directions[i] }); } } if (neighbors.length > 0) { var next = neighbors[Math.floor(Math.random() * neighbors.length)]; maze[next.y][next.x] = 0; maze[current.y + next.dir.y / 2][current.x + next.dir.x / 2] = 0; stack.push({ x: next.x, y: next.y }); } else { stack.pop(); } } // Create entrance var entranceX = Math.floor(Math.random() * (MAZE_WIDTH - 2)) + 1; maze[0][entranceX] = 0; return { x: entranceX, y: 0 }; } function createMazeVisuals() { for (var y = 0; y < MAZE_HEIGHT; y++) { for (var x = 0; x < MAZE_WIDTH; x++) { var cellX = MAZE_START_X + x * CELL_SIZE; var cellY = MAZE_START_Y + y * CELL_SIZE; if (maze[y][x] === 1) { var wall = game.addChild(LK.getAsset('wall', { x: cellX, y: cellY })); walls.push(wall); } else { var floor = game.addChild(LK.getAsset('floor', { x: cellX, y: cellY })); floors.push(floor); } } } } function placeholdenBalls() { var ballCount = Math.floor(MAZE_WIDTH * MAZE_HEIGHT * 0.1); // 10% of maze cells var placedBalls = 0; while (placedBalls < ballCount) { var x = Math.floor(Math.random() * MAZE_WIDTH); var y = Math.floor(Math.random() * MAZE_HEIGHT); if (maze[y][x] === 0) { var cellX = MAZE_START_X + x * CELL_SIZE + CELL_SIZE / 2; var cellY = MAZE_START_Y + y * CELL_SIZE + CELL_SIZE / 2; var ball = game.addChild(new GoldenBall()); ball.x = cellX; ball.y = cellY; ball.mazeX = x; ball.mazeY = y; goldenBalls.push(ball); placedBalls++; } } totalBalls = goldenBalls.length; updateScoreText(); } function updateScoreText() { scoreText.setText('Balls: ' + collectedBalls + '/' + totalBalls); } function updateTimerText() { var minutes = Math.floor(gameTimer / 60); var seconds = gameTimer % 60; var timeString = (minutes < 10 ? '0' : '') + minutes + ':' + (seconds < 10 ? '0' : '') + seconds; timerText.setText(timeString); } function isValidPosition(x, y) { var mazeX = Math.floor((x - MAZE_START_X) / CELL_SIZE); var mazeY = Math.floor((y - MAZE_START_Y) / CELL_SIZE); if (mazeX < 0 || mazeX >= MAZE_WIDTH || mazeY < 0 || mazeY >= MAZE_HEIGHT) { return false; } return maze[mazeY][mazeX] === 0; } function getValidTargetPosition(targetX, targetY) { var currentMazeX = Math.floor((player.x - MAZE_START_X) / CELL_SIZE); var currentMazeY = Math.floor((player.y - MAZE_START_Y) / CELL_SIZE); var targetMazeX = Math.floor((targetX - MAZE_START_X) / CELL_SIZE); var targetMazeY = Math.floor((targetY - MAZE_START_Y) / CELL_SIZE); if (targetMazeX < 0 || targetMazeX >= MAZE_WIDTH || targetMazeY < 0 || targetMazeY >= MAZE_HEIGHT) { return { x: player.x, y: player.y }; } if (maze[targetMazeY][targetMazeX] === 1) { return { x: player.x, y: player.y }; } var cellCenterX = MAZE_START_X + targetMazeX * CELL_SIZE + CELL_SIZE / 2; var cellCenterY = MAZE_START_Y + targetMazeY * CELL_SIZE + CELL_SIZE / 2; return { x: cellCenterX, y: cellCenterY }; } // Initialize maze var entrance = generateMaze(); createBackgrounds(); createMazeVisuals(); // Create player player = game.addChild(new Player()); player.x = MAZE_START_X + entrance.x * CELL_SIZE + CELL_SIZE / 2; player.y = MAZE_START_Y + entrance.y * CELL_SIZE + CELL_SIZE / 2; player.setTarget(player.x, player.y); // Place golden balls placeholdenBalls(); // Game timer var gameTimerInterval = LK.setInterval(function () { gameTimer--; updateTimerText(); if (gameTimer <= 0) { LK.showGameOver(); } }, 1000); // Touch controls - tap to move game.down = function (x, y, obj) { var validPos = getValidTargetPosition(x, y); player.setTarget(validPos.x, validPos.y); }; game.move = function (x, y, obj) { // No drag movement needed for tap controls }; game.up = function (x, y, obj) { // No action needed for tap controls }; // Game update loop game.update = function () { // Check ball collection for (var i = 0; i < goldenBalls.length; i++) { var ball = goldenBalls[i]; if (!ball.collected && player.intersects(ball)) { ball.collect(); collectedBalls++; LK.setScore(collectedBalls); updateScoreText(); LK.getSound('collect').play(); // Check win condition if (collectedBalls >= totalBalls) { LK.clearInterval(gameTimerInterval); LK.getSound('complete').play(); LK.setTimeout(function () { LK.showYouWin(); }, 500); } } } };
===================================================================
--- original.js
+++ change.js
@@ -85,8 +85,26 @@
var goldenBalls = [];
var gameTimer = 180; // 3 minutes
var totalBalls = 0;
var collectedBalls = 0;
+var backgrounds = [];
+// Create background elements
+function createBackgrounds() {
+ var backgroundAssets = ['bg1', 'bg2', 'bg3', 'bg4', 'bg5', 'bg6', 'bg7', 'bg8', 'bg9', 'bg10'];
+ for (var i = 0; i < backgroundAssets.length; i++) {
+ var bg = game.addChild(LK.getAsset(backgroundAssets[i], {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ alpha: 0.3
+ }));
+ // Random positioning across the screen
+ bg.x = Math.random() * 2048;
+ bg.y = Math.random() * (2732 - MAZE_HEIGHT * CELL_SIZE - 200) + 100;
+ // Random rotation
+ bg.rotation = Math.random() * Math.PI * 2;
+ backgrounds.push(bg);
+ }
+}
// Tap controls - no drag node needed
// Timer display
var timerText = new Text2('03:00', {
size: 60,
@@ -258,8 +276,9 @@
};
}
// Initialize maze
var entrance = generateMaze();
+createBackgrounds();
createMazeVisuals();
// Create player
player = game.addChild(new Player());
player.x = MAZE_START_X + entrance.x * CELL_SIZE + CELL_SIZE / 2;
2d side scroller bee. In-Game asset. 2d. High contrast. No shadows
big evil wasp. In-Game asset. 2d. High contrast. No shadows
2d side scroller rose fresh rose flower. In-Game asset. 2d. High contrast. No shadows
image 2d classic full warna tentang hamparan bunga bunga liar disuatu lembah. In-Game asset. 2d. High contrast. No shadows