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 CategoryButton = Container.expand(function (categoryName, isActive) {
var self = Container.call(this);
var buttonBg = self.attachAsset('categoryButton', {
anchorX: 0.5,
anchorY: 0.5
});
if (isActive) {
buttonBg.tint = 0x0984e3; // Darker blue for active state
}
var buttonText = new Text2(categoryName, {
size: 32,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.categoryName = categoryName;
self.isActive = isActive;
self.setActive = function (active) {
self.isActive = active;
buttonBg.tint = active ? 0x0984e3 : 0x74b9ff;
};
self.down = function (x, y, obj) {
tween(buttonBg, {
scaleX: 0.95,
scaleY: 0.95
}, {
duration: 100
});
LK.getSound('tap').play();
};
self.up = function (x, y, obj) {
tween(buttonBg, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
filterGamesByCategory(self.categoryName);
};
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 Coin = Container.expand(function () {
var self = Container.call(this);
var graphic = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
self.bobOffset = Math.random() * Math.PI * 2;
self.startY = 0;
self.update = function () {
self.y = self.startY + Math.sin(LK.ticks * 0.1 + self.bobOffset) * 10;
};
return self;
});
var DashObstacle = Container.expand(function (type) {
var self = Container.call(this);
self.obstacleType = type || 'block';
var assetName = 'dashObstacle';
if (type === 'spike') assetName = 'dashSpike';else if (type === 'ground') assetName = 'dashGround';
var graphic = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -8;
self.update = function () {
self.x += self.speed;
if (self.x < -100) {
self.shouldRemove = true;
}
};
return self;
});
var DashPlayer = Container.expand(function () {
var self = Container.call(this);
var graphic = self.attachAsset('dashPlayer', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityY = 0;
self.gravity = 1.2;
self.jumpPower = -18;
self.isGrounded = false;
self.isDead = false;
self.lastY = 0;
self.gameMode = 'cube'; // cube, ship, ball, wave
self.update = function () {
if (self.isDead) return;
self.lastY = self.y;
// Apply gravity for cube mode
if (self.gameMode === 'cube') {
self.velocityY += self.gravity;
if (self.velocityY > 15) self.velocityY = 15;
} else if (self.gameMode === 'ship') {
// Ship mode - controlled flight
if (self.isHolding) {
self.velocityY -= 1.5;
if (self.velocityY < -12) self.velocityY = -12;
} else {
self.velocityY += 1.2;
if (self.velocityY > 12) self.velocityY = 12;
}
}
self.y += self.velocityY;
self.isGrounded = false;
// Simple rotation based on velocity
if (self.gameMode === 'cube') {
graphic.rotation = 0;
} else if (self.gameMode === 'ship') {
graphic.rotation = self.velocityY * 0.1;
}
};
self.jump = function () {
if (self.gameMode === 'cube' && self.isGrounded) {
self.velocityY = self.jumpPower;
self.isGrounded = false;
LK.getSound('jump').play();
}
};
self.hold = function () {
self.isHolding = true;
};
self.release = function () {
self.isHolding = false;
};
self.die = function () {
if (self.isDead) return;
self.isDead = true;
// Flash red death effect
tween(graphic, {
tint: 0xff0000
}, {
duration: 200,
onFinish: function onFinish() {
tween(graphic, {
tint: 0xffffff
}, {
duration: 200
});
}
});
LK.setTimeout(function () {
endCurrentGame();
}, 500);
};
self.changeMode = function (newMode) {
self.gameMode = newMode;
if (newMode === 'ship') {
graphic.tint = 0x3498db;
} else if (newMode === 'ball') {
graphic.tint = 0xe67e22;
} else if (newMode === 'wave') {
graphic.tint = 0x9b59b6;
} else {
graphic.tint = 0xf39c12;
}
};
return self;
});
var DashPortal = Container.expand(function (portalType) {
var self = Container.call(this);
var graphic = self.attachAsset('dashPortal', {
anchorX: 0.5,
anchorY: 0.5
});
self.portalType = portalType || 'cube';
self.speed = -8;
// Color portals based on type
if (portalType === 'ship') {
graphic.tint = 0x3498db;
} else if (portalType === 'ball') {
graphic.tint = 0xe67e22;
} else if (portalType === 'wave') {
graphic.tint = 0x9b59b6;
} else {
graphic.tint = 0xf39c12;
}
self.update = function () {
self.x += self.speed;
if (self.x < -100) {
self.shouldRemove = true;
}
// Rotating effect
graphic.rotation += 0.1;
};
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 GameCreator = Container.expand(function () {
var self = Container.call(this);
self.mode = 'place'; // 'place', 'delete', 'color'
self.currentColor = 0x00b894;
self.createdObjects = [];
self.createToolbar = function () {
var toolbar = new Container();
// Place button
var placeBtn = toolbar.addChild(LK.getAsset('toolButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 200,
y: 100
}));
var placeText = new Text2('Place', {
size: 32,
fill: 0xFFFFFF
});
placeText.anchor.set(0.5, 0.5);
placeText.x = 200;
placeText.y = 100;
toolbar.addChild(placeText);
// Delete button
var deleteBtn = toolbar.addChild(LK.getAsset('toolButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 520,
y: 100
}));
var deleteText = new Text2('Delete', {
size: 32,
fill: 0xFFFFFF
});
deleteText.anchor.set(0.5, 0.5);
deleteText.x = 520;
deleteText.y = 100;
toolbar.addChild(deleteText);
// Color picker
var colorBtn = toolbar.addChild(LK.getAsset('colorPicker', {
anchorX: 0.5,
anchorY: 0.5,
x: 840,
y: 100
}));
// Play button
var playBtn = toolbar.addChild(LK.getAsset('toolButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1200,
y: 100
}));
var playText = new Text2('Play', {
size: 32,
fill: 0xFFFFFF
});
playText.anchor.set(0.5, 0.5);
playText.x = 1200;
playText.y = 100;
toolbar.addChild(playText);
// Clear button
var clearBtn = toolbar.addChild(LK.getAsset('toolButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1520,
y: 100
}));
var clearText = new Text2('Clear', {
size: 32,
fill: 0xFFFFFF
});
clearText.anchor.set(0.5, 0.5);
clearText.x = 1520;
clearText.y = 100;
toolbar.addChild(clearText);
return toolbar;
};
self.handleToolClick = function (x, y) {
if (y >= 50 && y <= 150) {
if (x >= 50 && x <= 350) {
self.mode = 'place';
} else if (x >= 370 && x <= 670) {
self.mode = 'delete';
} else if (x >= 790 && x <= 890) {
self.mode = 'color';
self.currentColor = [0xff7675, 0x74b9ff, 0x00b894, 0xfdcb6e, 0xe17055, 0x6c5ce7][Math.floor(Math.random() * 6)];
} else if (x >= 1050 && x <= 1350) {
self.mode = 'play';
self.startCustomGame();
} else if (x >= 1370 && x <= 1670) {
self.clearAll();
}
}
};
self.handleCanvasClick = function (x, y) {
if (y < 200) return; // Don't place in toolbar area
if (self.mode === 'place') {
var newObj = game.addChild(LK.getAsset('customShape', {
anchorX: 0.5,
anchorY: 0.5,
x: x,
y: y
}));
newObj.tint = self.currentColor;
newObj.isCustomObject = true;
self.createdObjects.push(newObj);
} else if (self.mode === 'delete') {
for (var i = self.createdObjects.length - 1; i >= 0; i--) {
var obj = self.createdObjects[i];
var dx = obj.x - x;
var dy = obj.y - y;
if (Math.sqrt(dx * dx + dy * dy) < 50) {
obj.destroy();
self.createdObjects.splice(i, 1);
break;
}
}
}
};
self.clearAll = function () {
for (var i = 0; i < self.createdObjects.length; i++) {
self.createdObjects[i].destroy();
}
self.createdObjects = [];
};
self.startCustomGame = function () {
if (self.createdObjects.length === 0) return;
currentGame = 'customGame';
customGameObjects = self.createdObjects.slice(); // Copy array
LK.setScore(0);
updateScoreDisplay();
};
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 Platform = Container.expand(function () {
var self = Container.call(this);
var graphic = self.attachAsset('platform', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
var PlatformPlayer = Container.expand(function () {
var self = Container.call(this);
var graphic = self.attachAsset('platformPlayer', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = 0;
self.velocityY = 0;
self.gravity = 0.8;
self.jumpPower = -15;
self.speed = 6;
self.maxSpeed = 8;
self.onGround = false;
self.lastY = 0;
self.lastX = 0;
self.width = 60;
self.height = 80;
self.update = function () {
self.lastY = self.y;
self.lastX = self.x;
// Apply gravity
self.velocityY += self.gravity;
if (self.velocityY > 20) self.velocityY = 20; // Terminal velocity
// Apply horizontal velocity
self.x += self.velocityX;
// Check horizontal platform collisions
for (var i = 0; i < platforms.length; i++) {
var platform = platforms[i];
if (self.intersects(platform)) {
// Push player out horizontally
if (self.velocityX > 0) {
// Moving right, hit left side of platform
self.x = platform.x - platform.width * platform.scaleX / 2 - self.width / 2;
} else if (self.velocityX < 0) {
// Moving left, hit right side of platform
self.x = platform.x + platform.width * platform.scaleX / 2 + self.width / 2;
}
self.velocityX = 0;
break;
}
}
// Apply vertical velocity
self.y += self.velocityY;
// Friction
self.velocityX *= 0.85;
// Keep player on screen horizontally
if (self.x < 30) {
self.x = 30;
self.velocityX = 0;
}
if (self.x > 2018) {
self.x = 2018;
self.velocityX = 0;
}
// Reset if player falls off screen
if (self.y > 2800) {
self.x = 200;
self.y = 2000;
self.velocityX = 0;
self.velocityY = 0;
}
self.onGround = false;
};
self.jump = function () {
if (self.onGround) {
self.velocityY = self.jumpPower;
self.onGround = false;
LK.getSound('jump').play();
}
};
self.moveLeft = function () {
self.velocityX -= self.speed;
if (self.velocityX < -self.maxSpeed) self.velocityX = -self.maxSpeed;
};
self.moveRight = function () {
self.velocityX += self.speed;
if (self.velocityX > self.maxSpeed) self.velocityX = self.maxSpeed;
};
return self;
});
var ScrollBar = Container.expand(function () {
var self = Container.call(this);
self.scrollPosition = 0;
self.maxScroll = 0;
self.contentHeight = 0;
self.viewHeight = 2000;
// Create scroll bar background
var scrollBg = self.attachAsset('scrollBar', {
anchorX: 0.5,
anchorY: 0
});
// Create scroll thumb
var scrollThumb = self.attachAsset('scrollThumb', {
anchorX: 0.5,
anchorY: 0
});
// Create up button
var upBtn = self.attachAsset('scrollUpBtn', {
anchorX: 0.5,
anchorY: 0.5,
y: -50
});
// Create down button
var downBtn = self.attachAsset('scrollDownBtn', {
anchorX: 0.5,
anchorY: 0.5,
y: 450
});
// Add up/down arrows as text
var upText = new Text2('▲', {
size: 24,
fill: 0xFFFFFF
});
upText.anchor.set(0.5, 0.5);
upText.y = -50;
self.addChild(upText);
var downText = new Text2('▼', {
size: 24,
fill: 0xFFFFFF
});
downText.anchor.set(0.5, 0.5);
downText.y = 450;
self.addChild(downText);
self.setContentHeight = function (height) {
self.contentHeight = height;
self.maxScroll = Math.max(0, height - self.viewHeight);
self.updateThumb();
};
self.updateThumb = function () {
if (self.maxScroll > 0) {
var thumbRatio = self.viewHeight / self.contentHeight;
var thumbHeight = Math.max(30, scrollBg.height * thumbRatio);
scrollThumb.scaleY = thumbHeight / 60;
var thumbPosition = self.scrollPosition / self.maxScroll * (scrollBg.height - thumbHeight);
scrollThumb.y = thumbPosition;
} else {
scrollThumb.y = 0;
}
};
self.scroll = function (delta) {
self.scrollPosition = Math.max(0, Math.min(self.maxScroll, self.scrollPosition + delta));
self.updateThumb();
return self.scrollPosition;
};
self.down = function (x, y, obj) {
var localY = y - self.y;
if (localY >= -75 && localY <= -25) {
// Up button clicked
self.scroll(-200);
LK.getSound('tap').play();
} else if (localY >= 425 && localY <= 475) {
// Down button clicked
self.scroll(200);
LK.getSound('tap').play();
}
};
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',
platformer: 'platformer'
};
// 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 platformerBest = storage.platformerBest || 0;
var snakeRunnerUnlocked = storage.snakeRunnerUnlocked || false;
var blockBreakerUnlocked = storage.blockBreakerUnlocked || false;
var mazeUnlocked = storage.mazeUnlocked || false;
var platformerUnlocked = storage.platformerUnlocked || false;
// Game definitions
var geometryDashBest = storage.geometryDashBest || 0;
var gameInfo = [{
id: 'tapCircles',
title: 'Tap Circles',
bestScore: tapCirclesBest,
locked: false,
category: 'Action'
}, {
id: 'snakeRunner',
title: 'Snake Runner',
bestScore: snakeRunnerBest,
locked: false,
category: 'Action'
}, {
id: 'blockBreaker',
title: 'Block Breaker',
bestScore: blockBreakerBest,
locked: false,
category: 'Arcade'
}, {
id: 'maze',
title: 'Maze Runner',
bestScore: mazeBest,
locked: false,
category: 'Puzzle'
}, {
id: 'platformer',
title: 'Platformer',
bestScore: platformerBest,
locked: false,
category: 'Adventure'
}, {
id: 'geometryDash',
title: 'Geometry Dash',
bestScore: geometryDashBest,
locked: false,
category: 'Action'
}, {
id: 'gameCreator',
title: 'Game Creator',
bestScore: 0,
locked: false,
category: 'Creative'
}];
// Hub elements
var hubBackground;
var gameCards = [];
var hubTitle;
var scrollBar;
var gameContainer;
var categoryButtons = [];
var categoryContainer;
var currentCategory = 'All';
// Game elements
var circles = [];
var snake;
var foods = [];
var paddle;
var ball;
var bricks = [];
var mazePlayer;
var mazeWalls = [];
var mazeExit;
var mazeGrid = [];
var gameCreator;
var customGameObjects = [];
var customGamePlayer;
var platformPlayer;
var platforms = [];
var coins = [];
var dashPlayer;
var dashObstacles = [];
var dashPortals = [];
var dashGroundPieces = [];
var dashSpawnTimer = 0;
var dashDistance = 0;
var dashDifficulty = 1;
// 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 scrollable container for game cards
gameContainer = new Container();
game.addChild(gameContainer);
// Create category buttons
createCategoryButtons();
// Create game cards
var startY = 1000;
var spacing = 400;
gameCards = [];
for (var i = 0; i < gameInfo.length; i++) {
var card = new GameCard(gameInfo[i]);
card.x = 1024;
card.y = startY + i * spacing;
gameContainer.addChild(card);
gameCards.push(card);
}
// Create scroll bar
scrollBar = game.addChild(new ScrollBar());
scrollBar.x = 1900;
scrollBar.y = 600;
// Calculate content height and setup scrolling
var totalContentHeight = startY + (gameInfo.length - 1) * spacing + 300;
scrollBar.setContentHeight(totalContentHeight);
// Initialize with 'All' category
filterGamesByCategory('All');
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);
// Make back button interactive
backButton.down = function (x, y, obj) {
tween(backButton, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100
});
LK.getSound('tap').play();
};
backButton.up = function (x, y, obj) {
tween(backButton, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
currentGame = 'hub';
initializeHub();
};
// 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();
} else if (gameId === 'platformer') {
initializePlatformer();
} else if (gameId === 'geometryDash') {
initializeGeometryDash();
} else if (gameId === 'gameCreator') {
initializeGameCreator();
} else if (gameId === 'customGame') {
initializeCustomGame();
}
}
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 initializePlatformer() {
var bg = game.addChild(LK.getAsset('gameBackground1', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
platforms = [];
coins = [];
// Create platforms
var platformData = [{
x: 200,
y: 2600,
width: 400
}, {
x: 700,
y: 2400,
width: 200
}, {
x: 1200,
y: 2200,
width: 200
}, {
x: 1600,
y: 2000,
width: 200
}, {
x: 1000,
y: 1800,
width: 300
}, {
x: 400,
y: 1600,
width: 250
}, {
x: 1400,
y: 1400,
width: 200
}, {
x: 800,
y: 1200,
width: 300
}, {
x: 200,
y: 1000,
width: 200
}, {
x: 1600,
y: 800,
width: 200
}, {
x: 1000,
y: 600,
width: 400
}];
for (var i = 0; i < platformData.length; i++) {
var platform = game.addChild(new Platform());
platform.x = platformData[i].x;
platform.y = platformData[i].y;
if (platformData[i].width) {
platform.scaleX = platformData[i].width / 200;
}
platforms.push(platform);
}
// Create coins on platforms
var coinPositions = [{
x: 700,
y: 2350
}, {
x: 1200,
y: 2150
}, {
x: 1600,
y: 1950
}, {
x: 1000,
y: 1750
}, {
x: 400,
y: 1550
}, {
x: 1400,
y: 1350
}, {
x: 800,
y: 1150
}, {
x: 200,
y: 950
}, {
x: 1600,
y: 750
}, {
x: 1000,
y: 550
}];
for (var i = 0; i < coinPositions.length; i++) {
var coin = game.addChild(new Coin());
coin.x = coinPositions[i].x;
coin.y = coinPositions[i].y;
coin.startY = coin.y;
coins.push(coin);
}
// Create player
platformPlayer = game.addChild(new PlatformPlayer());
platformPlayer.x = 200;
platformPlayer.y = 2500;
var instructions = new Text2('Drag bottom half to move left/right, tap top half to jump! Collect all coins!', {
size: 36,
fill: 0xFFFFFF
});
instructions.anchor.set(0.5, 0.5);
instructions.x = 1024;
instructions.y = 300;
game.addChild(instructions);
}
function initializeGameCreator() {
var bg = game.addChild(LK.getAsset('creatorBackground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
gameCreator = new GameCreator();
var toolbar = gameCreator.createToolbar();
game.addChild(toolbar);
var instructions = new Text2('Tap to place objects, use tools to edit, then play your creation!', {
size: 36,
fill: 0xFFFFFF
});
instructions.anchor.set(0.5, 0.5);
instructions.x = 1024;
instructions.y = 250;
game.addChild(instructions);
}
function initializeGeometryDash() {
var bg = game.addChild(LK.getAsset('gameBackground2', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
dashObstacles = [];
dashPortals = [];
dashGroundPieces = [];
dashSpawnTimer = 0;
dashDistance = 0;
dashDifficulty = 1;
// Create player
dashPlayer = game.addChild(new DashPlayer());
dashPlayer.x = 300;
dashPlayer.y = 2400;
// Create initial ground pieces
for (var i = 0; i < 20; i++) {
var ground = game.addChild(new DashObstacle('ground'));
ground.x = i * 120;
ground.y = 2600;
dashGroundPieces.push(ground);
}
var instructions = new Text2('Tap to jump! Avoid obstacles and collect portals!', {
size: 36,
fill: 0xFFFFFF
});
instructions.anchor.set(0.5, 0.5);
instructions.x = 1024;
instructions.y = 300;
game.addChild(instructions);
}
function initializeCustomGame() {
var bg = game.addChild(LK.getAsset('gameBackground1', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
// Create a simple player for the custom game
customGamePlayer = game.addChild(LK.getAsset('customShape', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 2400
}));
customGamePlayer.tint = 0xe74c3c;
customGamePlayer.isPlayer = true;
// Recreate the custom objects
for (var i = 0; i < customGameObjects.length; i++) {
var originalObj = customGameObjects[i];
var newObj = game.addChild(LK.getAsset('customShape', {
anchorX: 0.5,
anchorY: 0.5,
x: originalObj.x,
y: originalObj.y
}));
newObj.tint = originalObj.tint;
newObj.isCustomObject = true;
customGameObjects[i] = newObj;
}
}
function updateScoreDisplay() {
if (currentScoreText) {
currentScoreText.setText('Score: ' + LK.getScore());
}
}
function filterGamesByCategory(category) {
currentCategory = category;
// Update button states
for (var i = 0; i < categoryButtons.length; i++) {
categoryButtons[i].setActive(categoryButtons[i].categoryName === category);
}
// Filter and reposition game cards
var visibleCards = [];
for (var i = 0; i < gameCards.length; i++) {
var card = gameCards[i];
var shouldShow = category === 'All' || card.gameInfo.category === category;
card.visible = shouldShow;
if (shouldShow) {
visibleCards.push(card);
}
}
// Reposition visible cards
var startY = 1000;
var spacing = 400;
for (var i = 0; i < visibleCards.length; i++) {
visibleCards[i].y = startY + i * spacing;
}
// Update scroll bar content height
var totalContentHeight = startY + (visibleCards.length - 1) * spacing + 300;
scrollBar.setContentHeight(totalContentHeight);
scrollBar.scrollPosition = 0;
scrollBar.updateThumb();
}
function createCategoryButtons() {
var categories = ['All', 'Action', 'Arcade', 'Puzzle', 'Adventure', 'Creative'];
categoryContainer = new Container();
game.addChild(categoryContainer);
var buttonWidth = 300;
var buttonSpacing = 20;
var totalWidth = categories.length * buttonWidth + (categories.length - 1) * buttonSpacing;
var startX = (2048 - totalWidth) / 2 + buttonWidth / 2;
for (var i = 0; i < categories.length; i++) {
var button = new CategoryButton(categories[i], categories[i] === 'All');
button.x = startX + i * (buttonWidth + buttonSpacing);
button.y = 650;
categoryContainer.addChild(button);
categoryButtons.push(button);
}
}
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;
} else if (currentGame === 'platformer') {
storage.platformerBest = currentScore;
} else if (currentGame === 'geometryDash') {
storage.geometryDashBest = 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;
}
if (currentGame === 'maze' && currentScore >= 150 && !storage.platformerUnlocked) {
storage.platformerUnlocked = true;
gameInfo[4].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') {
// Handle scroll bar interaction
if (scrollBar && x >= 1850 && x <= 1950) {
// Let scroll bar handle the click
}
return;
}
// Check back button - use direct coordinates instead of transformation
if (x >= 120 && x <= 400 && y >= 80 && y <= 130) {
currentGame = 'hub';
initializeHub();
return;
}
if (currentGame === 'gameCreator' && gameCreator) {
if (y >= 50 && y <= 150) {
gameCreator.handleToolClick(x, y);
} else {
gameCreator.handleCanvasClick(x, y);
}
} else if (currentGame === 'platformer' && platformPlayer) {
// Check if tap is in upper part of screen for jump
if (y < 1366) {
platformPlayer.jump();
}
} else if (currentGame === 'geometryDash' && dashPlayer) {
dashPlayer.jump();
dashPlayer.hold();
}
};
game.up = function (x, y, obj) {
if (currentGame === 'geometryDash' && dashPlayer) {
dashPlayer.release();
}
};
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);
}
}
} else if (currentGame === 'customGame' && customGamePlayer) {
customGamePlayer.x = x;
customGamePlayer.y = y;
if (customGamePlayer.x < 40) customGamePlayer.x = 40;
if (customGamePlayer.x > 2008) customGamePlayer.x = 2008;
if (customGamePlayer.y < 40) customGamePlayer.y = 40;
if (customGamePlayer.y > 2692) customGamePlayer.y = 2692;
} else if (currentGame === 'platformer' && platformPlayer) {
// Only handle horizontal movement in lower part of screen to avoid conflicts with jump
if (y > 1366) {
var deltaX = x - platformPlayer.x;
if (Math.abs(deltaX) > 30) {
if (deltaX > 0) {
platformPlayer.moveRight();
} else {
platformPlayer.moveLeft();
}
}
}
}
};
game.update = function () {
if (currentGame === 'hub') {
// Update scroll position for game cards
if (gameContainer && scrollBar) {
gameContainer.y = -scrollBar.scrollPosition;
}
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();
}
} else if (currentGame === 'customGame') {
// Check collisions with custom objects
for (var i = customGameObjects.length - 1; i >= 0; i--) {
if (customGamePlayer && customGameObjects[i] && customGamePlayer.intersects(customGameObjects[i])) {
LK.getSound('collect').play();
LK.setScore(LK.getScore() + 10);
updateScoreDisplay();
customGameObjects[i].destroy();
customGameObjects.splice(i, 1);
}
}
// Win condition - collect all objects
if (customGameObjects.length === 0) {
LK.setScore(LK.getScore() + 100);
endCurrentGame();
}
gameTimer++;
// Auto end after 60 seconds
if (gameTimer >= 3600) {
endCurrentGame();
}
} else if (currentGame === 'platformer') {
// Platform collision detection for vertical movement
for (var i = 0; i < platforms.length; i++) {
var platform = platforms[i];
var platformWidth = platform.width * platform.scaleX;
var platformHeight = platform.height;
// Check if player is overlapping with platform
if (platformPlayer.intersects(platform)) {
var playerBottom = platformPlayer.y + platformPlayer.height / 2;
var playerTop = platformPlayer.y - platformPlayer.height / 2;
var platformTop = platform.y - platformHeight / 2;
var platformBottom = platform.y + platformHeight / 2;
var playerLeft = platformPlayer.x - platformPlayer.width / 2;
var playerRight = platformPlayer.x + platformPlayer.width / 2;
var platformLeft = platform.x - platformWidth / 2;
var platformRight = platform.x + platformWidth / 2;
// Check if player is landing on top of platform
if (platformPlayer.velocityY > 0 && platformPlayer.lastY + platformPlayer.height / 2 <= platformTop + 5) {
// Landing on top
platformPlayer.y = platformTop - platformPlayer.height / 2;
platformPlayer.velocityY = 0;
platformPlayer.onGround = true;
} else if (platformPlayer.velocityY < 0 && platformPlayer.lastY - platformPlayer.height / 2 >= platformBottom - 5) {
// Hitting from below
platformPlayer.y = platformBottom + platformPlayer.height / 2;
platformPlayer.velocityY = 0;
}
}
}
// Coin collection
for (var i = coins.length - 1; i >= 0; i--) {
if (platformPlayer.intersects(coins[i])) {
LK.getSound('collect').play();
LK.setScore(LK.getScore() + 20);
updateScoreDisplay();
coins[i].destroy();
coins.splice(i, 1);
}
}
// Win condition - collect all coins
if (coins.length === 0) {
LK.setScore(LK.getScore() + 100);
updateScoreDisplay();
endCurrentGame();
}
gameTimer++;
// Time limit - 2 minutes
if (gameTimer >= 7200) {
endCurrentGame();
}
} else if (currentGame === 'geometryDash') {
if (dashPlayer.isDead) return;
dashDistance += 8;
dashSpawnTimer++;
// Increase difficulty over time
dashDifficulty = 1 + Math.floor(dashDistance / 2000) * 0.5;
// Spawn ground pieces
if (dashSpawnTimer % 15 === 0) {
var ground = game.addChild(new DashObstacle('ground'));
ground.x = 2200;
ground.y = 2600;
dashGroundPieces.push(ground);
}
// Spawn obstacles
var spawnChance = Math.max(30, 120 - dashDifficulty * 20);
if (dashSpawnTimer % Math.floor(spawnChance) === 0) {
var obstacleType = Math.random() < 0.7 ? 'block' : 'spike';
var obstacle = game.addChild(new DashObstacle(obstacleType));
obstacle.x = 2200;
if (obstacleType === 'spike') {
obstacle.y = 2570;
} else {
obstacle.y = 2520;
}
dashObstacles.push(obstacle);
}
// Spawn portals occasionally
if (dashSpawnTimer % 300 === 0 && Math.random() < 0.6) {
var portalTypes = ['cube', 'ship', 'ball', 'wave'];
var randomType = portalTypes[Math.floor(Math.random() * portalTypes.length)];
var portal = game.addChild(new DashPortal(randomType));
portal.x = 2200;
portal.y = 2400;
dashPortals.push(portal);
}
// Ground collision detection
for (var i = 0; i < dashGroundPieces.length; i++) {
var ground = dashGroundPieces[i];
if (dashPlayer.intersects(ground) && dashPlayer.velocityY >= 0) {
if (dashPlayer.lastY + 30 <= ground.y - 20) {
dashPlayer.y = ground.y - 30;
dashPlayer.velocityY = 0;
dashPlayer.isGrounded = true;
}
}
}
// Obstacle collision detection
for (var i = dashObstacles.length - 1; i >= 0; i--) {
var obstacle = dashObstacles[i];
if (dashPlayer.intersects(obstacle)) {
dashPlayer.die();
return;
}
if (obstacle.shouldRemove) {
obstacle.destroy();
dashObstacles.splice(i, 1);
}
}
// Portal collision detection
for (var i = dashPortals.length - 1; i >= 0; i--) {
var portal = dashPortals[i];
if (dashPlayer.intersects(portal)) {
dashPlayer.changeMode(portal.portalType);
LK.getSound('collect').play();
LK.setScore(LK.getScore() + 50);
updateScoreDisplay();
portal.destroy();
dashPortals.splice(i, 1);
continue;
}
if (portal.shouldRemove) {
portal.destroy();
dashPortals.splice(i, 1);
}
}
// Clean up ground pieces
for (var i = dashGroundPieces.length - 1; i >= 0; i--) {
var ground = dashGroundPieces[i];
if (ground.shouldRemove) {
ground.destroy();
dashGroundPieces.splice(i, 1);
}
}
// Death conditions
if (dashPlayer.y > 2700 || dashPlayer.y < -100) {
dashPlayer.die();
return;
}
// Score based on distance
if (dashSpawnTimer % 60 === 0) {
LK.setScore(LK.getScore() + Math.floor(dashDifficulty * 5));
updateScoreDisplay();
}
// Auto end after very long play
gameTimer++;
if (gameTimer >= 18000) {
// 5 minutes
endCurrentGame();
}
}
};
// Initialize the hub
initializeHub();
LK.playMusic('bgMusic'); ===================================================================
--- original.js
+++ change.js
@@ -900,8 +900,28 @@
backButton.anchor.set(0, 0);
backButton.x = 120;
backButton.y = 80;
LK.gui.center.addChild(backButton);
+ // Make back button interactive
+ backButton.down = function (x, y, obj) {
+ tween(backButton, {
+ scaleX: 0.9,
+ scaleY: 0.9
+ }, {
+ duration: 100
+ });
+ LK.getSound('tap').play();
+ };
+ backButton.up = function (x, y, obj) {
+ tween(backButton, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 100
+ });
+ currentGame = 'hub';
+ initializeHub();
+ };
// Create score display
currentScoreText = new Text2('Score: 0', {
size: 48,
fill: 0xFFFFFF
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