User prompt
Now make the players stay in like the maze and like they can't move out of the maze otherwise that would just be bad
User prompt
it can the joystick be like pretty big and then when you move it around when you like touch it or move around and it moves in that direction and also make it stay in like the box like the maze so yeah
Code edit (1 edits merged)
Please save this source code
User prompt
Mine Shaft Escape
Initial prompt
the game the game will be about a guy who is stuck in a mine shaft and monsters one one monster the skeleton tries to change
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Exit = Container.expand(function () { var self = Container.call(this); var exitGraphics = self.attachAsset('exit', { anchorX: 0.5, anchorY: 0.5 }); // Pulsing effect self.pulseDirection = 1; self.update = function () { exitGraphics.alpha += self.pulseDirection * 0.02; if (exitGraphics.alpha >= 1) { self.pulseDirection = -1; } else if (exitGraphics.alpha <= 0.3) { self.pulseDirection = 1; } }; return self; }); var Floor = Container.expand(function () { var self = Container.call(this); var floorGraphics = self.attachAsset('floor', { anchorX: 0, anchorY: 0 }); return self; }); var Player = Container.expand(function () { var self = Container.call(this); self.moveToTarget = function (targetX, targetY) { self.targetX = targetX; self.targetY = targetY; self.isMoving = true; }; self.update = function () { if (self.isMoving && self.targetX !== undefined && self.targetY !== undefined) { var dx = self.targetX - self.x; var dy = self.targetY - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 5) { var speed = 4; self.x += dx / distance * speed; self.y += dy / distance * speed; } else { self.x = self.targetX; self.y = self.targetY; self.isMoving = false; } } }; var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.isMoving = false; self.targetX = 0; self.targetY = 0; return self; }); var Skeleton = Container.expand(function () { var self = Container.call(this); self.update = function () { if (player) { var dx = player.x - self.x; var dy = player.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { var speed = 2.5; self.x += dx / distance * speed; self.y += dy / distance * speed; } // Random roar sound if (Math.random() < 0.002) { LK.getSound('skeleton_roar').play(); } } }; var skeletonGraphics = self.attachAsset('skeleton', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var Wall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('wall', { anchorX: 0, anchorY: 0 }); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a1a }); /**** * Game Code ****/ // Game variables var player; var skeleton; var walls = []; var floors = []; var exit; var gameStarted = false; var lastPlayerX = 0; var lastPlayerY = 0; var lastSkeletonDistance = Infinity; // Create maze layout var mazeLayout = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]; var cellSize = 100; var offsetX = (2048 - mazeLayout[0].length * cellSize) / 2; var offsetY = 200; // Create maze for (var row = 0; row < mazeLayout.length; row++) { for (var col = 0; col < mazeLayout[row].length; col++) { var x = offsetX + col * cellSize; var y = offsetY + row * cellSize; if (mazeLayout[row][col] === 1) { var wall = new Wall(); wall.x = x; wall.y = y; walls.push(wall); game.addChild(wall); } else { var floor = new Floor(); floor.x = x; floor.y = y; floors.push(floor); game.addChild(floor); } } } // Create player at starting position player = new Player(); player.x = offsetX + 1.5 * cellSize; player.y = offsetY + 1.5 * cellSize; lastPlayerX = player.x; lastPlayerY = player.y; game.addChild(player); // Create skeleton at bottom of maze skeleton = new Skeleton(); skeleton.x = offsetX + 18.5 * cellSize; skeleton.y = offsetY + 13.5 * cellSize; game.addChild(skeleton); // Create exit at top right exit = new Exit(); exit.x = offsetX + 18.5 * cellSize; exit.y = offsetY + 1.5 * cellSize; game.addChild(exit); // UI elements var instructionText = new Text2('Tap to move. Escape the mine!', { size: 60, fill: 0xFFFFFF }); instructionText.anchor.set(0.5, 0); LK.gui.top.addChild(instructionText); instructionText.y = 100; var distanceText = new Text2('', { size: 50, fill: 0xFF4444 }); distanceText.anchor.set(0.5, 0); LK.gui.top.addChild(distanceText); distanceText.y = 180; function checkWallCollision(x, y) { var col = Math.floor((x - offsetX) / cellSize); var row = Math.floor((y - offsetY) / cellSize); if (row < 0 || row >= mazeLayout.length || col < 0 || col >= mazeLayout[0].length) { return true; } return mazeLayout[row][col] === 1; } game.down = function (x, y, obj) { if (!checkWallCollision(x, y)) { player.moveToTarget(x, y); if (Math.random() < 0.3) { LK.getSound('footstep').play(); } } }; game.update = function () { // Check if player reached exit if (player.intersects(exit)) { LK.getSound('escape').play(); LK.showYouWin(); return; } // Check if skeleton caught player var skeletonDistance = Math.sqrt(Math.pow(player.x - skeleton.x, 2) + Math.pow(player.y - skeleton.y, 2)); if (!lastSkeletonDistance) lastSkeletonDistance = skeletonDistance; if (lastSkeletonDistance > 80 && skeletonDistance <= 80) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } lastSkeletonDistance = skeletonDistance; // Update distance display var distanceToExit = Math.sqrt(Math.pow(player.x - exit.x, 2) + Math.pow(player.y - exit.y, 2)); distanceText.setText('Skeleton Distance: ' + Math.floor(skeletonDistance)); // Create tension effect when skeleton is close if (skeletonDistance < 200) { var intensity = (200 - skeletonDistance) / 200; game.setBackgroundColor(Math.floor(0x1a * (1 + intensity)) << 16 | Math.floor(0x1a * (1 - intensity * 0.5)) << 8 | Math.floor(0x1a * (1 - intensity * 0.5))); } else { game.setBackgroundColor(0x1a1a1a); } }; // Start ambient music LK.playMusic('horror_ambient');
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,221 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Exit = Container.expand(function () {
+ var self = Container.call(this);
+ var exitGraphics = self.attachAsset('exit', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Pulsing effect
+ self.pulseDirection = 1;
+ self.update = function () {
+ exitGraphics.alpha += self.pulseDirection * 0.02;
+ if (exitGraphics.alpha >= 1) {
+ self.pulseDirection = -1;
+ } else if (exitGraphics.alpha <= 0.3) {
+ self.pulseDirection = 1;
+ }
+ };
+ return self;
+});
+var Floor = Container.expand(function () {
+ var self = Container.call(this);
+ var floorGraphics = self.attachAsset('floor', {
+ anchorX: 0,
+ anchorY: 0
+ });
+ return self;
+});
+var Player = Container.expand(function () {
+ var self = Container.call(this);
+ self.moveToTarget = function (targetX, targetY) {
+ self.targetX = targetX;
+ self.targetY = targetY;
+ self.isMoving = true;
+ };
+ self.update = function () {
+ if (self.isMoving && self.targetX !== undefined && self.targetY !== undefined) {
+ var dx = self.targetX - self.x;
+ var dy = self.targetY - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > 5) {
+ var speed = 4;
+ self.x += dx / distance * speed;
+ self.y += dy / distance * speed;
+ } else {
+ self.x = self.targetX;
+ self.y = self.targetY;
+ self.isMoving = false;
+ }
+ }
+ };
+ var playerGraphics = self.attachAsset('player', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.isMoving = false;
+ self.targetX = 0;
+ self.targetY = 0;
+ return self;
+});
+var Skeleton = Container.expand(function () {
+ var self = Container.call(this);
+ self.update = function () {
+ if (player) {
+ var dx = player.x - self.x;
+ var dy = player.y - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > 0) {
+ var speed = 2.5;
+ self.x += dx / distance * speed;
+ self.y += dy / distance * speed;
+ }
+ // Random roar sound
+ if (Math.random() < 0.002) {
+ LK.getSound('skeleton_roar').play();
+ }
+ }
+ };
+ var skeletonGraphics = self.attachAsset('skeleton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ return self;
+});
+var Wall = Container.expand(function () {
+ var self = Container.call(this);
+ var wallGraphics = self.attachAsset('wall', {
+ anchorX: 0,
+ anchorY: 0
+ });
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x1a1a1a
+});
+
+/****
+* Game Code
+****/
+// Game variables
+var player;
+var skeleton;
+var walls = [];
+var floors = [];
+var exit;
+var gameStarted = false;
+var lastPlayerX = 0;
+var lastPlayerY = 0;
+var lastSkeletonDistance = Infinity;
+// Create maze layout
+var mazeLayout = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]];
+var cellSize = 100;
+var offsetX = (2048 - mazeLayout[0].length * cellSize) / 2;
+var offsetY = 200;
+// Create maze
+for (var row = 0; row < mazeLayout.length; row++) {
+ for (var col = 0; col < mazeLayout[row].length; col++) {
+ var x = offsetX + col * cellSize;
+ var y = offsetY + row * cellSize;
+ if (mazeLayout[row][col] === 1) {
+ var wall = new Wall();
+ wall.x = x;
+ wall.y = y;
+ walls.push(wall);
+ game.addChild(wall);
+ } else {
+ var floor = new Floor();
+ floor.x = x;
+ floor.y = y;
+ floors.push(floor);
+ game.addChild(floor);
+ }
+ }
+}
+// Create player at starting position
+player = new Player();
+player.x = offsetX + 1.5 * cellSize;
+player.y = offsetY + 1.5 * cellSize;
+lastPlayerX = player.x;
+lastPlayerY = player.y;
+game.addChild(player);
+// Create skeleton at bottom of maze
+skeleton = new Skeleton();
+skeleton.x = offsetX + 18.5 * cellSize;
+skeleton.y = offsetY + 13.5 * cellSize;
+game.addChild(skeleton);
+// Create exit at top right
+exit = new Exit();
+exit.x = offsetX + 18.5 * cellSize;
+exit.y = offsetY + 1.5 * cellSize;
+game.addChild(exit);
+// UI elements
+var instructionText = new Text2('Tap to move. Escape the mine!', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+instructionText.anchor.set(0.5, 0);
+LK.gui.top.addChild(instructionText);
+instructionText.y = 100;
+var distanceText = new Text2('', {
+ size: 50,
+ fill: 0xFF4444
+});
+distanceText.anchor.set(0.5, 0);
+LK.gui.top.addChild(distanceText);
+distanceText.y = 180;
+function checkWallCollision(x, y) {
+ var col = Math.floor((x - offsetX) / cellSize);
+ var row = Math.floor((y - offsetY) / cellSize);
+ if (row < 0 || row >= mazeLayout.length || col < 0 || col >= mazeLayout[0].length) {
+ return true;
+ }
+ return mazeLayout[row][col] === 1;
+}
+game.down = function (x, y, obj) {
+ if (!checkWallCollision(x, y)) {
+ player.moveToTarget(x, y);
+ if (Math.random() < 0.3) {
+ LK.getSound('footstep').play();
+ }
+ }
+};
+game.update = function () {
+ // Check if player reached exit
+ if (player.intersects(exit)) {
+ LK.getSound('escape').play();
+ LK.showYouWin();
+ return;
+ }
+ // Check if skeleton caught player
+ var skeletonDistance = Math.sqrt(Math.pow(player.x - skeleton.x, 2) + Math.pow(player.y - skeleton.y, 2));
+ if (!lastSkeletonDistance) lastSkeletonDistance = skeletonDistance;
+ if (lastSkeletonDistance > 80 && skeletonDistance <= 80) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ return;
+ }
+ lastSkeletonDistance = skeletonDistance;
+ // Update distance display
+ var distanceToExit = Math.sqrt(Math.pow(player.x - exit.x, 2) + Math.pow(player.y - exit.y, 2));
+ distanceText.setText('Skeleton Distance: ' + Math.floor(skeletonDistance));
+ // Create tension effect when skeleton is close
+ if (skeletonDistance < 200) {
+ var intensity = (200 - skeletonDistance) / 200;
+ game.setBackgroundColor(Math.floor(0x1a * (1 + intensity)) << 16 | Math.floor(0x1a * (1 - intensity * 0.5)) << 8 | Math.floor(0x1a * (1 - intensity * 0.5)));
+ } else {
+ game.setBackgroundColor(0x1a1a1a);
+ }
+};
+// Start ambient music
+LK.playMusic('horror_ambient');
\ No newline at end of file
A guy with a bag over his head with a cross on it. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
The player with a torch in his hand and the monster skeleton dead on the floor with a knife in his head and blood everywhere. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat