User prompt
Add the game hub back
User prompt
Remove jumper
User prompt
Please fix the bug: 'TypeError: undefined is not an object (evaluating 'coins[i].destroy')' in or related to this line: 'coins[i].destroy();' Line Number: 1507
User prompt
Add the back to game hub button
User prompt
Make a new game thatβs called jumper
User prompt
Make the snake body grow we never it gets a point
User prompt
Make more for game creator
User prompt
Add back the back to game hub button
User prompt
Put it in the corner of the screen
User prompt
Add a back to game hub button
User prompt
Add a jump controll
User prompt
Fix the player in platformer
User prompt
Make a game that is like geometry dash βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make it so that every game is free to play
User prompt
Add a button for categories
User prompt
Add a scroll bar
User prompt
Add a platformer game βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make a game creator if people does not find these fun
User prompt
Make a new game mode named maze
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.gameData = savedData;' Line Number: 453 βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'var backPos = LK.gui.center.toLocal(obj.parent.toGlobal(obj.position));' Line Number: 475
Code edit (1 edits merged)
Please save this source code
User prompt
Game Hub Collection
Initial prompt
Multiple games in one game
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Ball = Container.expand(function () {
var self = Container.call(this);
var graphic = self.attachAsset('ball', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = 5;
self.speedY = -5;
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
// Bounce off walls
if (self.x < 20 || self.x > 2028) {
self.speedX = -self.speedX;
LK.getSound('bounce').play();
}
if (self.y < 20) {
self.speedY = -self.speedY;
LK.getSound('bounce').play();
}
// Game over if ball goes below paddle
if (self.y > 2732) {
endCurrentGame();
}
// Bounce off paddle
if (paddle && self.intersects(paddle) && self.speedY > 0) {
self.speedY = -self.speedY;
LK.getSound('bounce').play();
}
};
return self;
});
var Brick = Container.expand(function () {
var self = Container.call(this);
var graphic = self.attachAsset('brick', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
var Circle = Container.expand(function () {
var self = Container.call(this);
var graphic = self.attachAsset('circle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2 + Math.random() * 3;
self.direction = Math.random() * Math.PI * 2;
self.lifetime = 180; // 3 seconds at 60fps
self.maxLifetime = self.lifetime;
self.update = function () {
self.x += Math.cos(self.direction) * self.speed;
self.y += Math.sin(self.direction) * self.speed;
// Bounce off walls
if (self.x < 60 || self.x > 1988) {
self.direction = Math.PI - self.direction;
}
if (self.y < 60 || self.y > 2672) {
self.direction = -self.direction;
}
self.lifetime--;
var alpha = self.lifetime / self.maxLifetime;
graphic.alpha = alpha;
if (self.lifetime <= 0) {
self.shouldRemove = true;
}
};
self.down = function (x, y, obj) {
LK.getSound('tap').play();
LK.setScore(LK.getScore() + 10);
updateScoreDisplay();
self.shouldRemove = true;
};
return self;
});
var Food = Container.expand(function () {
var self = Container.call(this);
var graphic = self.attachAsset('food', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 100 + Math.random() * 1848;
self.y = 100 + Math.random() * 2532;
return self;
});
var GameCard = Container.expand(function (gameInfo) {
var self = Container.call(this);
var isLocked = gameInfo.locked || false;
var cardBg = self.attachAsset(isLocked ? 'gameCard' : 'gameCard', {
anchorX: 0.5,
anchorY: 0.5
});
if (isLocked) {
var lock = self.attachAsset('lockIcon', {
anchorX: 0.5,
anchorY: 0.5
});
}
var titleText = new Text2(gameInfo.title, {
size: 48,
fill: isLocked ? "#666666" : "#ffffff"
});
titleText.anchor.set(0.5, 0.5);
titleText.y = -50;
self.addChild(titleText);
var scoreText = new Text2('Best: ' + (gameInfo.bestScore || 0), {
size: 32,
fill: isLocked ? "#444444" : "#cccccc"
});
scoreText.anchor.set(0.5, 0.5);
scoreText.y = 20;
self.addChild(scoreText);
self.gameInfo = gameInfo;
self.isLocked = isLocked;
self.down = function (x, y, obj) {
if (!self.isLocked) {
tween(cardBg, {
scaleX: 0.95,
scaleY: 0.95
}, {
duration: 100
});
LK.getSound('tap').play();
}
};
self.up = function (x, y, obj) {
if (!self.isLocked) {
tween(cardBg, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
currentGame = self.gameInfo.id;
switchToGame(currentGame);
}
};
self.updateScore = function (newScore) {
gameInfo.bestScore = newScore;
scoreText.setText('Best: ' + newScore);
};
self.unlock = function () {
self.isLocked = false;
gameInfo.locked = false;
cardBg.tint = 0x16213e;
titleText.tint = 0xffffff;
scoreText.tint = 0xcccccc;
if (lock) {
lock.visible = false;
}
};
return self;
});
var MazePlayer = Container.expand(function () {
var self = Container.call(this);
var graphic = self.attachAsset('mazePlayer', {
anchorX: 0.5,
anchorY: 0.5
});
self.gridX = 0;
self.gridY = 0;
self.cellSize = 80;
self.moveToGrid = function (gridX, gridY) {
self.gridX = gridX;
self.gridY = gridY;
self.x = gridX * self.cellSize + self.cellSize / 2;
self.y = gridY * self.cellSize + self.cellSize / 2 + 200;
};
return self;
});
var MazeWall = Container.expand(function () {
var self = Container.call(this);
var graphic = self.attachAsset('mazeWall', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
var Paddle = Container.expand(function () {
var self = Container.call(this);
var graphic = self.attachAsset('paddle', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 1024;
self.y = 2600;
return self;
});
var Snake = Container.expand(function () {
var self = Container.call(this);
var graphic = self.attachAsset('snake', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 4;
self.direction = {
x: 0,
y: -1
};
self.update = function () {
self.x += self.direction.x * self.speed;
self.y += self.direction.y * self.speed;
// Wrap around screen
if (self.x < 0) self.x = 2048;
if (self.x > 2048) self.x = 0;
if (self.y < 0) self.y = 2732;
if (self.y > 2732) self.y = 0;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a2e
});
/****
* Game Code
****/
// Game state management
// Game 1: Tap the Circles
// Game 2: Snake-like Runner
// Game 3: Block Breaker
var currentGame = 'hub';
var gameStates = {
hub: 'hub',
tapCircles: 'tapCircles',
snakeRunner: 'snakeRunner',
blockBreaker: 'blockBreaker',
maze: 'maze'
};
// Load saved data using individual storage properties
var tapCirclesBest = storage.tapCirclesBest || 0;
var snakeRunnerBest = storage.snakeRunnerBest || 0;
var blockBreakerBest = storage.blockBreakerBest || 0;
var mazeBest = storage.mazeBest || 0;
var snakeRunnerUnlocked = storage.snakeRunnerUnlocked || false;
var blockBreakerUnlocked = storage.blockBreakerUnlocked || false;
var mazeUnlocked = storage.mazeUnlocked || false;
// Game definitions
var gameInfo = [{
id: 'tapCircles',
title: 'Tap Circles',
bestScore: tapCirclesBest,
locked: false
}, {
id: 'snakeRunner',
title: 'Snake Runner',
bestScore: snakeRunnerBest,
locked: !snakeRunnerUnlocked
}, {
id: 'blockBreaker',
title: 'Block Breaker',
bestScore: blockBreakerBest,
locked: !blockBreakerUnlocked
}, {
id: 'maze',
title: 'Maze Runner',
bestScore: mazeBest,
locked: !mazeUnlocked
}];
// Hub elements
var hubBackground;
var gameCards = [];
var hubTitle;
// Game elements
var circles = [];
var snake;
var foods = [];
var paddle;
var ball;
var bricks = [];
var mazePlayer;
var mazeWalls = [];
var mazeExit;
var mazeGrid = [];
// UI elements
var currentScoreText;
var backButton;
// Game timers
var spawnTimer = 0;
var gameTimer = 0;
function initializeHub() {
// Clear game
while (game.children.length > 0) {
game.removeChild(game.children[0]);
}
// Clear GUI
while (LK.gui.center.children.length > 0) {
LK.gui.center.removeChild(LK.gui.center.children[0]);
}
while (LK.gui.top.children.length > 0) {
LK.gui.top.removeChild(LK.gui.top.children[0]);
}
hubBackground = game.addChild(LK.getAsset('hubBackground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
hubTitle = new Text2('Game Hub Collection', {
size: 72,
fill: 0xFFFFFF
});
hubTitle.anchor.set(0.5, 0.5);
hubTitle.x = 1024;
hubTitle.y = 400;
game.addChild(hubTitle);
// Create game cards
var startY = 800;
var spacing = 400;
for (var i = 0; i < gameInfo.length; i++) {
var card = new GameCard(gameInfo[i]);
card.x = 1024;
card.y = startY + i * spacing;
game.addChild(card);
gameCards.push(card);
}
LK.setScore(0);
}
function switchToGame(gameId) {
// Clear current game
while (game.children.length > 0) {
game.removeChild(game.children[0]);
}
// Clear GUI
while (LK.gui.center.children.length > 0) {
LK.gui.center.removeChild(LK.gui.center.children[0]);
}
while (LK.gui.top.children.length > 0) {
LK.gui.top.removeChild(LK.gui.top.children[0]);
}
// Reset game variables
circles = [];
foods = [];
bricks = [];
spawnTimer = 0;
gameTimer = 0;
LK.setScore(0);
// Create back button
backButton = new Text2('β Back to Hub', {
size: 48,
fill: 0xFFFFFF
});
backButton.anchor.set(0, 0);
backButton.x = 120;
backButton.y = 80;
LK.gui.center.addChild(backButton);
// Create score display
currentScoreText = new Text2('Score: 0', {
size: 48,
fill: 0xFFFFFF
});
currentScoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(currentScoreText);
// Initialize specific game
if (gameId === 'tapCircles') {
initializeTapCircles();
} else if (gameId === 'snakeRunner') {
initializeSnakeRunner();
} else if (gameId === 'blockBreaker') {
initializeBlockBreaker();
} else if (gameId === 'maze') {
initializeMaze();
}
}
function initializeTapCircles() {
var bg = game.addChild(LK.getAsset('gameBackground1', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
}
function initializeSnakeRunner() {
var bg = game.addChild(LK.getAsset('gameBackground2', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
snake = game.addChild(new Snake());
snake.x = 1024;
snake.y = 1366;
// Create initial food
var food = game.addChild(new Food());
foods.push(food);
}
function initializeBlockBreaker() {
var bg = game.addChild(LK.getAsset('gameBackground3', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
paddle = game.addChild(new Paddle());
ball = game.addChild(new Ball());
ball.x = 1024;
ball.y = 2400;
// Create bricks
var rows = 5;
var cols = 12;
var brickWidth = 150;
var brickHeight = 50;
var startX = (2048 - cols * brickWidth) / 2 + brickWidth / 2;
var startY = 300;
for (var row = 0; row < rows; row++) {
for (var col = 0; col < cols; col++) {
var brick = game.addChild(new Brick());
brick.x = startX + col * brickWidth;
brick.y = startY + row * (brickHeight + 10);
bricks.push(brick);
}
}
}
function initializeMaze() {
var bg = game.addChild(LK.getAsset('gameBackground4', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
mazeWalls = [];
mazeGrid = [];
var cols = 25;
var rows = 28;
var cellSize = 80;
// Initialize grid
for (var row = 0; row < rows; row++) {
mazeGrid[row] = [];
for (var col = 0; col < cols; col++) {
mazeGrid[row][col] = 1; // 1 = wall, 0 = path
}
}
// Create simple maze pattern
for (var row = 1; row < rows - 1; row += 2) {
for (var col = 1; col < cols - 1; col += 2) {
mazeGrid[row][col] = 0; // Create path
// Randomly create connections
if (Math.random() > 0.5 && col < cols - 2) {
mazeGrid[row][col + 1] = 0;
}
if (Math.random() > 0.5 && row < rows - 2) {
mazeGrid[row + 1][col] = 0;
}
}
}
// Ensure start and end are paths
mazeGrid[1][1] = 0; // Start
mazeGrid[rows - 2][cols - 2] = 0; // End
// Create walls based on grid
for (var row = 0; row < rows; row++) {
for (var col = 0; col < cols; col++) {
if (mazeGrid[row][col] === 1) {
var wall = game.addChild(new MazeWall());
wall.x = col * cellSize + cellSize / 2;
wall.y = row * cellSize + cellSize / 2 + 200;
mazeWalls.push(wall);
}
}
}
// Create player
mazePlayer = game.addChild(new MazePlayer());
mazePlayer.moveToGrid(1, 1);
// Create exit
mazeExit = game.addChild(LK.getAsset('mazeExit', {
anchorX: 0.5,
anchorY: 0.5
}));
mazeExit.x = (cols - 2) * cellSize + cellSize / 2;
mazeExit.y = (rows - 2) * cellSize + cellSize / 2 + 200;
}
function updateScoreDisplay() {
if (currentScoreText) {
currentScoreText.setText('Score: ' + LK.getScore());
}
}
function endCurrentGame() {
var currentScore = LK.getScore();
var gameData = null;
// Find current game data
for (var i = 0; i < gameInfo.length; i++) {
if (gameInfo[i].id === currentGame) {
gameData = gameInfo[i];
break;
}
}
if (gameData && currentScore > gameData.bestScore) {
gameData.bestScore = currentScore;
// Update storage using individual property assignments
if (currentGame === 'tapCircles') {
storage.tapCirclesBest = currentScore;
} else if (currentGame === 'snakeRunner') {
storage.snakeRunnerBest = currentScore;
} else if (currentGame === 'blockBreaker') {
storage.blockBreakerBest = currentScore;
} else if (currentGame === 'maze') {
storage.mazeBest = currentScore;
}
// Check for unlocks
if (currentGame === 'tapCircles' && currentScore >= 100 && !storage.snakeRunnerUnlocked) {
storage.snakeRunnerUnlocked = true;
gameInfo[1].locked = false;
}
if (currentGame === 'snakeRunner' && currentScore >= 50 && !storage.blockBreakerUnlocked) {
storage.blockBreakerUnlocked = true;
gameInfo[2].locked = false;
}
if (currentGame === 'blockBreaker' && currentScore >= 100 && !storage.mazeUnlocked) {
storage.mazeUnlocked = true;
gameInfo[3].locked = false;
}
}
// Return to hub after a delay
LK.setTimeout(function () {
currentGame = 'hub';
initializeHub();
// Update card scores
for (var i = 0; i < gameCards.length; i++) {
gameCards[i].updateScore(gameInfo[i].bestScore);
if (!gameInfo[i].locked) {
gameCards[i].unlock();
}
}
}, 2000);
LK.showGameOver();
}
// Event handlers
game.down = function (x, y, obj) {
if (currentGame === 'hub') {
return;
}
// Check back button - use direct coordinates instead of transformation
if (x >= 120 && x <= 400 && y >= 80 && y <= 130) {
currentGame = 'hub';
initializeHub();
return;
}
};
game.move = function (x, y, obj) {
if (currentGame === 'blockBreaker' && paddle) {
paddle.x = x;
if (paddle.x < 100) paddle.x = 100;
if (paddle.x > 1948) paddle.x = 1948;
} else if (currentGame === 'snakeRunner' && snake) {
var deltaX = x - snake.x;
var deltaY = y - snake.y;
if (Math.abs(deltaX) > Math.abs(deltaY)) {
snake.direction = deltaX > 0 ? {
x: 1,
y: 0
} : {
x: -1,
y: 0
};
} else {
snake.direction = deltaY > 0 ? {
x: 0,
y: 1
} : {
x: 0,
y: -1
};
}
} else if (currentGame === 'maze' && mazePlayer) {
var cellSize = 80;
var newGridX = Math.floor((x - 40) / cellSize);
var newGridY = Math.floor((y - 240) / cellSize);
// Check bounds and walls
if (newGridX >= 0 && newGridX < 25 && newGridY >= 0 && newGridY < 28) {
if (mazeGrid[newGridY] && mazeGrid[newGridY][newGridX] === 0) {
mazePlayer.moveToGrid(newGridX, newGridY);
}
}
}
};
game.update = function () {
if (currentGame === 'hub') {
return;
}
if (currentGame === 'tapCircles') {
spawnTimer++;
if (spawnTimer >= 60) {
// Spawn every second
spawnTimer = 0;
var circle = game.addChild(new Circle());
circle.x = 100 + Math.random() * 1848;
circle.y = 200 + Math.random() * 2332;
circles.push(circle);
}
// Update circles
for (var i = circles.length - 1; i >= 0; i--) {
if (circles[i].shouldRemove) {
circles[i].destroy();
circles.splice(i, 1);
}
}
gameTimer++;
if (gameTimer >= 1800) {
// 30 seconds
endCurrentGame();
}
} else if (currentGame === 'snakeRunner') {
// Check food collection
for (var i = foods.length - 1; i >= 0; i--) {
if (snake.intersects(foods[i])) {
LK.getSound('collect').play();
LK.setScore(LK.getScore() + 10);
updateScoreDisplay();
foods[i].destroy();
foods.splice(i, 1);
// Spawn new food
var food = game.addChild(new Food());
foods.push(food);
}
}
gameTimer++;
if (gameTimer >= 3600) {
// 60 seconds
endCurrentGame();
}
} else if (currentGame === 'blockBreaker') {
// Check ball-brick collisions
for (var i = bricks.length - 1; i >= 0; i--) {
if (ball.intersects(bricks[i])) {
ball.speedY = -ball.speedY;
LK.getSound('bounce').play();
LK.setScore(LK.getScore() + 10);
updateScoreDisplay();
bricks[i].destroy();
bricks.splice(i, 1);
}
}
// Check win condition
if (bricks.length === 0) {
LK.setScore(LK.getScore() + 100);
endCurrentGame();
}
} else if (currentGame === 'maze') {
// Check if player reached exit
if (mazePlayer && mazeExit && mazePlayer.intersects(mazeExit)) {
LK.setScore(LK.getScore() + 200);
updateScoreDisplay();
endCurrentGame();
}
gameTimer++;
// Time bonus decreases over time
if (gameTimer % 60 === 0 && LK.getScore() > 0) {
LK.setScore(LK.getScore() - 1);
updateScoreDisplay();
}
}
};
// Initialize the hub
initializeHub();
LK.playMusic('bgMusic'); ===================================================================
--- original.js
+++ change.js
@@ -159,8 +159,33 @@
}
};
return self;
});
+var MazePlayer = Container.expand(function () {
+ var self = Container.call(this);
+ var graphic = self.attachAsset('mazePlayer', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.gridX = 0;
+ self.gridY = 0;
+ self.cellSize = 80;
+ self.moveToGrid = function (gridX, gridY) {
+ self.gridX = gridX;
+ self.gridY = gridY;
+ self.x = gridX * self.cellSize + self.cellSize / 2;
+ self.y = gridY * self.cellSize + self.cellSize / 2 + 200;
+ };
+ return self;
+});
+var MazeWall = Container.expand(function () {
+ var self = Container.call(this);
+ var graphic = self.attachAsset('mazeWall', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ return self;
+});
var Paddle = Container.expand(function () {
var self = Container.call(this);
var graphic = self.attachAsset('paddle', {
anchorX: 0.5,
@@ -202,25 +227,28 @@
/****
* Game Code
****/
-// Game 3: Block Breaker
-// Game 2: Snake-like Runner
-// Game 1: Tap the Circles
// Game state management
+// Game 1: Tap the Circles
+// Game 2: Snake-like Runner
+// Game 3: Block Breaker
var currentGame = 'hub';
var gameStates = {
hub: 'hub',
tapCircles: 'tapCircles',
snakeRunner: 'snakeRunner',
- blockBreaker: 'blockBreaker'
+ blockBreaker: 'blockBreaker',
+ maze: 'maze'
};
// Load saved data using individual storage properties
var tapCirclesBest = storage.tapCirclesBest || 0;
var snakeRunnerBest = storage.snakeRunnerBest || 0;
var blockBreakerBest = storage.blockBreakerBest || 0;
+var mazeBest = storage.mazeBest || 0;
var snakeRunnerUnlocked = storage.snakeRunnerUnlocked || false;
var blockBreakerUnlocked = storage.blockBreakerUnlocked || false;
+var mazeUnlocked = storage.mazeUnlocked || false;
// Game definitions
var gameInfo = [{
id: 'tapCircles',
title: 'Tap Circles',
@@ -235,8 +263,13 @@
id: 'blockBreaker',
title: 'Block Breaker',
bestScore: blockBreakerBest,
locked: !blockBreakerUnlocked
+}, {
+ id: 'maze',
+ title: 'Maze Runner',
+ bestScore: mazeBest,
+ locked: !mazeUnlocked
}];
// Hub elements
var hubBackground;
var gameCards = [];
@@ -247,8 +280,12 @@
var foods = [];
var paddle;
var ball;
var bricks = [];
+var mazePlayer;
+var mazeWalls = [];
+var mazeExit;
+var mazeGrid = [];
// UI elements
var currentScoreText;
var backButton;
// Game timers
@@ -333,8 +370,10 @@
} else if (gameId === 'snakeRunner') {
initializeSnakeRunner();
} else if (gameId === 'blockBreaker') {
initializeBlockBreaker();
+ } else if (gameId === 'maze') {
+ initializeMaze();
}
}
function initializeTapCircles() {
var bg = game.addChild(LK.getAsset('gameBackground1', {
@@ -384,8 +423,65 @@
bricks.push(brick);
}
}
}
+function initializeMaze() {
+ var bg = game.addChild(LK.getAsset('gameBackground4', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 0,
+ y: 0
+ }));
+ mazeWalls = [];
+ mazeGrid = [];
+ var cols = 25;
+ var rows = 28;
+ var cellSize = 80;
+ // Initialize grid
+ for (var row = 0; row < rows; row++) {
+ mazeGrid[row] = [];
+ for (var col = 0; col < cols; col++) {
+ mazeGrid[row][col] = 1; // 1 = wall, 0 = path
+ }
+ }
+ // Create simple maze pattern
+ for (var row = 1; row < rows - 1; row += 2) {
+ for (var col = 1; col < cols - 1; col += 2) {
+ mazeGrid[row][col] = 0; // Create path
+ // Randomly create connections
+ if (Math.random() > 0.5 && col < cols - 2) {
+ mazeGrid[row][col + 1] = 0;
+ }
+ if (Math.random() > 0.5 && row < rows - 2) {
+ mazeGrid[row + 1][col] = 0;
+ }
+ }
+ }
+ // Ensure start and end are paths
+ mazeGrid[1][1] = 0; // Start
+ mazeGrid[rows - 2][cols - 2] = 0; // End
+ // Create walls based on grid
+ for (var row = 0; row < rows; row++) {
+ for (var col = 0; col < cols; col++) {
+ if (mazeGrid[row][col] === 1) {
+ var wall = game.addChild(new MazeWall());
+ wall.x = col * cellSize + cellSize / 2;
+ wall.y = row * cellSize + cellSize / 2 + 200;
+ mazeWalls.push(wall);
+ }
+ }
+ }
+ // Create player
+ mazePlayer = game.addChild(new MazePlayer());
+ mazePlayer.moveToGrid(1, 1);
+ // Create exit
+ mazeExit = game.addChild(LK.getAsset('mazeExit', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ }));
+ mazeExit.x = (cols - 2) * cellSize + cellSize / 2;
+ mazeExit.y = (rows - 2) * cellSize + cellSize / 2 + 200;
+}
function updateScoreDisplay() {
if (currentScoreText) {
currentScoreText.setText('Score: ' + LK.getScore());
}
@@ -408,8 +504,10 @@
} else if (currentGame === 'snakeRunner') {
storage.snakeRunnerBest = currentScore;
} else if (currentGame === 'blockBreaker') {
storage.blockBreakerBest = currentScore;
+ } else if (currentGame === 'maze') {
+ storage.mazeBest = currentScore;
}
// Check for unlocks
if (currentGame === 'tapCircles' && currentScore >= 100 && !storage.snakeRunnerUnlocked) {
storage.snakeRunnerUnlocked = true;
@@ -418,8 +516,12 @@
if (currentGame === 'snakeRunner' && currentScore >= 50 && !storage.blockBreakerUnlocked) {
storage.blockBreakerUnlocked = true;
gameInfo[2].locked = false;
}
+ if (currentGame === 'blockBreaker' && currentScore >= 100 && !storage.mazeUnlocked) {
+ storage.mazeUnlocked = true;
+ gameInfo[3].locked = false;
+ }
}
// Return to hub after a delay
LK.setTimeout(function () {
currentGame = 'hub';
@@ -470,8 +572,18 @@
x: 0,
y: -1
};
}
+ } else if (currentGame === 'maze' && mazePlayer) {
+ var cellSize = 80;
+ var newGridX = Math.floor((x - 40) / cellSize);
+ var newGridY = Math.floor((y - 240) / cellSize);
+ // Check bounds and walls
+ if (newGridX >= 0 && newGridX < 25 && newGridY >= 0 && newGridY < 28) {
+ if (mazeGrid[newGridY] && mazeGrid[newGridY][newGridX] === 0) {
+ mazePlayer.moveToGrid(newGridX, newGridY);
+ }
+ }
}
};
game.update = function () {
if (currentGame === 'hub') {
@@ -534,8 +646,21 @@
if (bricks.length === 0) {
LK.setScore(LK.getScore() + 100);
endCurrentGame();
}
+ } else if (currentGame === 'maze') {
+ // Check if player reached exit
+ if (mazePlayer && mazeExit && mazePlayer.intersects(mazeExit)) {
+ LK.setScore(LK.getScore() + 200);
+ updateScoreDisplay();
+ endCurrentGame();
+ }
+ gameTimer++;
+ // Time bonus decreases over time
+ if (gameTimer % 60 === 0 && LK.getScore() > 0) {
+ LK.setScore(LK.getScore() - 1);
+ updateScoreDisplay();
+ }
}
};
// Initialize the hub
initializeHub();
Lock. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Bricks and sky. In-Game asset. 2d. High contrast. No shadows
Stars. In-Game asset. 2d. High contrast. No shadows
Paddle. In-Game asset. 2d. High contrast. No shadows
Brick. In-Game asset. 2d. High contrast. No shadows
A Roblox noob. In-Game asset. 2d. High contrast. No shadows
Platform. In-Game asset. 2d. High contrast. No shadows
Coin. In-Game asset. 2d. High contrast. No shadows
Wall. In-Game asset. 2d. High contrast. No shadows
Game hub. In-Game asset. 2d. High contrast. No shadows
Snake. In-Game asset. 2d. High contrast. No shadows
Ball. In-Game asset. 2d. High contrast. No shadows
Paint brush. In-Game asset. 2d. High contrast. No shadows
Dash. In-Game asset. 2d. High contrast. No shadows
Robot. In-Game asset. 2d. High contrast. No shadows
Game hub with a black background. In-Game asset. 2d. High contrast. No shadows
Flappy bird. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Enemy. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat