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', 'resize', 'copy'
self.currentColor = 0x00b894;
self.currentObjectType = 'box'; // 'box', 'circle', 'platform', 'spike', 'goal', 'enemy'
self.gridSize = 40;
self.snapToGrid = true;
self.createdObjects = [];
self.clipboard = null;
self.selectedObject = null;
self.createToolbar = function () {
var toolbar = new Container();
// Row 1 - Main tools
var tools = [{
name: 'Place',
x: 150,
y: 80
}, {
name: 'Delete',
x: 300,
y: 80
}, {
name: 'Copy',
x: 450,
y: 80
}, {
name: 'Resize',
x: 600,
y: 80
}, {
name: 'Grid',
x: 750,
y: 80
}, {
name: 'Color',
x: 900,
y: 80
}, {
name: 'Play',
x: 1200,
y: 80
}, {
name: 'Save',
x: 1350,
y: 80
}, {
name: 'Load',
x: 1500,
y: 80
}, {
name: 'Clear',
x: 1650,
y: 80
}];
for (var i = 0; i < tools.length; i++) {
var tool = tools[i];
var btn = toolbar.addChild(LK.getAsset('toolButton', {
anchorX: 0.5,
anchorY: 0.5,
x: tool.x,
y: tool.y,
scaleX: 0.7,
scaleY: 0.7
}));
var text = new Text2(tool.name, {
size: 24,
fill: 0xFFFFFF
});
text.anchor.set(0.5, 0.5);
text.x = tool.x;
text.y = tool.y;
toolbar.addChild(text);
}
// Row 2 - Object types
var objectTypes = [{
name: 'Box',
type: 'box',
x: 150,
y: 150
}, {
name: 'Circle',
type: 'circle',
x: 300,
y: 150
}, {
name: 'Platform',
type: 'platform',
x: 450,
y: 150
}, {
name: 'Spike',
type: 'spike',
x: 600,
y: 150
}, {
name: 'Goal',
type: 'goal',
x: 750,
y: 150
}, {
name: 'Enemy',
type: 'enemy',
x: 900,
y: 150
}];
for (var i = 0; i < objectTypes.length; i++) {
var objType = objectTypes[i];
var btn = toolbar.addChild(LK.getAsset('categoryButton', {
anchorX: 0.5,
anchorY: 0.5,
x: objType.x,
y: objType.y,
scaleX: 0.6,
scaleY: 0.6
}));
var text = new Text2(objType.name, {
size: 20,
fill: 0xFFFFFF
});
text.anchor.set(0.5, 0.5);
text.x = objType.x;
text.y = objType.y;
toolbar.addChild(text);
}
// Create grid overlay
self.createGrid();
return toolbar;
};
self.createGrid = function () {
self.gridContainer = new Container();
game.addChild(self.gridContainer);
// Create grid dots
for (var x = 0; x < 2048; x += self.gridSize) {
for (var y = 200; y < 2732; y += self.gridSize) {
var dot = self.gridContainer.addChild(LK.getAsset('gridDot', {
anchorX: 0.5,
anchorY: 0.5,
x: x,
y: y
}));
dot.alpha = 0.3;
}
}
self.gridContainer.visible = self.snapToGrid;
};
self.snapToGridPosition = function (x, y) {
if (!self.snapToGrid) return {
x: x,
y: y
};
return {
x: Math.round(x / self.gridSize) * self.gridSize,
y: Math.round(y / self.gridSize) * self.gridSize
};
};
self.getAssetNameForType = function (type) {
switch (type) {
case 'circle':
return 'customCircle';
case 'platform':
return 'customPlatform';
case 'spike':
return 'customSpike';
case 'goal':
return 'customGoal';
case 'enemy':
return 'customEnemy';
default:
return 'customShape';
}
};
self.handleToolClick = function (x, y) {
// Row 1 - Main tools
if (y >= 50 && y <= 110) {
if (x >= 100 && x <= 200) self.mode = 'place';else if (x >= 250 && x <= 350) self.mode = 'delete';else if (x >= 400 && x <= 500) self.mode = 'copy';else if (x >= 550 && x <= 650) self.mode = 'resize';else if (x >= 700 && x <= 800) {
self.snapToGrid = !self.snapToGrid;
if (self.gridContainer) self.gridContainer.visible = self.snapToGrid;
} else if (x >= 850 && x <= 950) {
self.mode = 'color';
self.currentColor = [0xff7675, 0x74b9ff, 0x00b894, 0xfdcb6e, 0xe17055, 0x6c5ce7][Math.floor(Math.random() * 6)];
} else if (x >= 1150 && x <= 1250) {
self.mode = 'play';
self.startCustomGame();
} else if (x >= 1300 && x <= 1400) self.saveLevel();else if (x >= 1450 && x <= 1550) self.loadLevel();else if (x >= 1600 && x <= 1700) self.clearAll();
}
// Row 2 - Object types
else if (y >= 120 && y <= 180) {
if (x >= 100 && x <= 200) self.currentObjectType = 'box';else if (x >= 250 && x <= 350) self.currentObjectType = 'circle';else if (x >= 400 && x <= 500) self.currentObjectType = 'platform';else if (x >= 550 && x <= 650) self.currentObjectType = 'spike';else if (x >= 700 && x <= 800) self.currentObjectType = 'goal';else if (x >= 850 && x <= 950) self.currentObjectType = 'enemy';
}
};
self.handleCanvasClick = function (x, y) {
if (y < 200) return; // Don't place in toolbar area
var snappedPos = self.snapToGridPosition(x, y);
x = snappedPos.x;
y = snappedPos.y;
if (self.mode === 'place') {
var assetName = self.getAssetNameForType(self.currentObjectType);
var newObj = game.addChild(LK.getAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5,
x: x,
y: y
}));
newObj.tint = self.currentColor;
newObj.isCustomObject = true;
newObj.objectType = self.currentObjectType;
newObj.customSize = 1.0;
self.createdObjects.push(newObj);
LK.getSound('tap').play();
} else if (self.mode === 'delete') {
self.deleteObjectAt(x, y);
} else if (self.mode === 'copy') {
var foundObj = self.findObjectAt(x, y);
if (foundObj) {
self.clipboard = {
type: foundObj.objectType,
color: foundObj.tint,
size: foundObj.customSize
};
LK.getSound('tap').play();
}
} else if (self.mode === 'resize') {
var foundObj = self.findObjectAt(x, y);
if (foundObj) {
foundObj.customSize = foundObj.customSize === 1.0 ? 1.5 : foundObj.customSize === 1.5 ? 0.5 : 1.0;
foundObj.scaleX = foundObj.customSize;
foundObj.scaleY = foundObj.customSize;
LK.getSound('tap').play();
}
} else if (self.mode === 'color') {
var foundObj = self.findObjectAt(x, y);
if (foundObj) {
foundObj.tint = self.currentColor;
LK.getSound('tap').play();
}
}
};
self.findObjectAt = function (x, y) {
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;
var size = (obj.width || 80) * (obj.customSize || 1.0) / 2;
if (Math.sqrt(dx * dx + dy * dy) < size) {
return obj;
}
}
return null;
};
self.deleteObjectAt = function (x, y) {
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;
var size = (obj.width || 80) * (obj.customSize || 1.0) / 2;
if (Math.sqrt(dx * dx + dy * dy) < size) {
obj.destroy();
self.createdObjects.splice(i, 1);
LK.getSound('tap').play();
break;
}
}
};
self.saveLevel = function () {
var levelData = [];
for (var i = 0; i < self.createdObjects.length; i++) {
var obj = self.createdObjects[i];
levelData.push({
type: obj.objectType,
x: obj.x,
y: obj.y,
color: obj.tint,
size: obj.customSize || 1.0
});
}
storage.customLevel = levelData;
LK.getSound('collect').play();
};
self.loadLevel = function () {
if (storage.customLevel) {
self.clearAll();
var levelData = storage.customLevel;
for (var i = 0; i < levelData.length; i++) {
var data = levelData[i];
var assetName = self.getAssetNameForType(data.type);
var newObj = game.addChild(LK.getAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5,
x: data.x,
y: data.y
}));
newObj.tint = data.color;
newObj.isCustomObject = true;
newObj.objectType = data.type;
newObj.customSize = data.size;
newObj.scaleX = data.size;
newObj.scaleY = data.size;
self.createdObjects.push(newObj);
}
LK.getSound('collect').play();
}
};
self.clearAll = function () {
for (var i = 0; i < self.createdObjects.length; i++) {
self.createdObjects[i].destroy();
}
self.createdObjects = [];
if (self.gridContainer) {
self.gridContainer.destroy();
self.createGrid();
}
};
self.startCustomGame = function () {
if (self.createdObjects.length === 0) return;
currentGame = 'customGame';
customGameObjects = self.createdObjects.slice(); // Copy array
LK.setScore(0);
updateScoreDisplay();
};
return self;
});
var JumperCoin = 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.collected = false;
self.update = function () {
if (!self.collected) {
self.y = self.startY + Math.sin(LK.ticks * 0.1 + self.bobOffset) * 10;
graphic.rotation += 0.05;
}
};
return self;
});
var JumperPlatform = Container.expand(function (width) {
var self = Container.call(this);
var graphic = self.attachAsset('platform', {
anchorX: 0.5,
anchorY: 0.5
});
if (width) {
graphic.scaleX = width / 200;
}
return self;
});
var JumperPlayer = 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 = 1.2;
self.jumpPower = -20;
self.speed = 8;
self.maxSpeed = 12;
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 > 25) self.velocityY = 25; // Terminal velocity
// Apply horizontal velocity
self.x += self.velocityX;
// Apply vertical velocity
self.y += self.velocityY;
// Friction
self.velocityX *= 0.9;
// 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 > 2900) {
self.x = 200;
self.y = 2000;
self.velocityX = 0;
self.velocityY = 0;
LK.setScore(Math.max(0, LK.getScore() - 50));
updateScoreDisplay();
}
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 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 MovingPlatform = Container.expand(function (width, startX, endX) {
var self = Container.call(this);
var graphic = self.attachAsset('platform', {
anchorX: 0.5,
anchorY: 0.5
});
if (width) {
graphic.scaleX = width / 200;
}
graphic.tint = 0x74b9ff; // Blue tint for moving platforms
self.startX = startX;
self.endX = endX;
self.speed = 2;
self.direction = 1;
self.update = function () {
self.x += self.speed * self.direction;
if (self.x >= self.endX || self.x <= self.startX) {
self.direction *= -1;
}
};
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.bodySegments = []; // Array to store body segments
self.segmentSize = 80; // Size of each body segment
self.moveCounter = 0; // Counter to control movement timing
self.update = function () {
self.moveCounter++;
// Only move every few frames to make it more manageable
if (self.moveCounter >= 15) {
self.moveCounter = 0;
// Store previous position for body segments to follow
var previousPositions = [{
x: self.x,
y: self.y
}];
for (var i = 0; i < self.bodySegments.length; i++) {
previousPositions.push({
x: self.bodySegments[i].x,
y: self.bodySegments[i].y
});
}
// Move head
self.x += self.direction.x * self.segmentSize;
self.y += self.direction.y * self.segmentSize;
// Move body segments to follow the segment in front
for (var i = 0; i < self.bodySegments.length; i++) {
self.bodySegments[i].x = previousPositions[i].x;
self.bodySegments[i].y = previousPositions[i].y;
}
}
// 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;
};
self.grow = function () {
// Create a new body segment
var newSegment = game.addChild(LK.getAsset('snake', {
anchorX: 0.5,
anchorY: 0.5
}));
// Position it at the tail (or at head if no body exists)
if (self.bodySegments.length > 0) {
var lastSegment = self.bodySegments[self.bodySegments.length - 1];
newSegment.x = lastSegment.x;
newSegment.y = lastSegment.y;
} else {
newSegment.x = self.x;
newSegment.y = self.y;
}
// Make it slightly different color to distinguish from head
newSegment.tint = 0x95a5a6;
self.bodySegments.push(newSegment);
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a2e
});
/****
* Game Code
****/
// Jumper Game - A platformer jumping game
// Game state management
var currentGame = 'jumper';
var gameStates = {
jumper: 'jumper'
};
// Load saved data
var jumperBest = storage.jumperBest || 0;
// Game definitions
var gameInfo = [{
id: 'jumper',
title: 'Jumper',
bestScore: jumperBest,
locked: false,
category: 'Action'
}];
// Game elements
var jumperPlayer;
var platforms = [];
var movingPlatforms = [];
var coins = [];
var gameTimer = 0;
// UI elements
var currentScoreText;
function initializeJumper() {
// 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]);
}
// Create background
var bg = game.addChild(LK.getAsset('gameBackground1', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
// Reset game variables
platforms = [];
movingPlatforms = [];
coins = [];
gameTimer = 0;
LK.setScore(0);
// Create score display
currentScoreText = new Text2('Score: 0', {
size: 48,
fill: 0xFFFFFF
});
currentScoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(currentScoreText);
// Create static platforms
var platformData = [{
x: 1024,
y: 2650,
width: 800
}, {
x: 300,
y: 2400,
width: 200
}, {
x: 800,
y: 2200,
width: 150
}, {
x: 1400,
y: 2000,
width: 200
}, {
x: 600,
y: 1800,
width: 180
}, {
x: 1200,
y: 1600,
width: 160
}, {
x: 400,
y: 1400,
width: 140
}, {
x: 1000,
y: 1200,
width: 120
}, {
x: 1600,
y: 1000,
width: 100
}, {
x: 700,
y: 800,
width: 150
}, {
x: 300,
y: 600,
width: 180
}, {
x: 1400,
y: 400,
width: 200
}];
for (var i = 0; i < platformData.length; i++) {
var platform = game.addChild(new JumperPlatform(platformData[i].width));
platform.x = platformData[i].x;
platform.y = platformData[i].y;
platforms.push(platform);
}
// Create moving platforms
var movingPlatformData = [{
startX: 200,
endX: 600,
y: 1500,
width: 120
}, {
startX: 1200,
endX: 1700,
y: 1100,
width: 100
}, {
startX: 500,
endX: 900,
y: 700,
width: 140
}];
for (var i = 0; i < movingPlatformData.length; i++) {
var data = movingPlatformData[i];
var movingPlatform = game.addChild(new MovingPlatform(data.width, data.startX, data.endX));
movingPlatform.x = data.startX;
movingPlatform.y = data.y;
movingPlatforms.push(movingPlatform);
}
// Create coins
var coinPositions = [{
x: 300,
y: 2350
}, {
x: 800,
y: 2150
}, {
x: 1400,
y: 1950
}, {
x: 600,
y: 1750
}, {
x: 1200,
y: 1550
}, {
x: 400,
y: 1350
}, {
x: 1000,
y: 1150
}, {
x: 1600,
y: 950
}, {
x: 700,
y: 750
}, {
x: 300,
y: 550
}, {
x: 1400,
y: 350
}];
for (var i = 0; i < coinPositions.length; i++) {
var coin = game.addChild(new JumperCoin());
coin.x = coinPositions[i].x;
coin.y = coinPositions[i].y;
coin.startY = coin.y;
coins.push(coin);
}
// Create player
jumperPlayer = game.addChild(new JumperPlayer());
jumperPlayer.x = 1024;
jumperPlayer.y = 2500;
// Create instructions
var instructions = new Text2('Tap to jump! Use left/right areas to move. Collect all coins to win!', {
size: 36,
fill: 0xFFFFFF
});
instructions.anchor.set(0.5, 0.5);
instructions.x = 1024;
instructions.y = 200;
game.addChild(instructions);
}
function updateScoreDisplay() {
if (currentScoreText) {
currentScoreText.setText('Score: ' + LK.getScore());
}
}
function endCurrentGame() {
var currentScore = LK.getScore();
if (currentScore > jumperBest) {
jumperBest = currentScore;
storage.jumperBest = currentScore;
}
// Return to start after a delay
LK.setTimeout(function () {
initializeJumper();
}, 2000);
LK.showGameOver();
}
// Event handlers
game.down = function (x, y, obj) {
if (currentGame === 'jumper' && jumperPlayer) {
// Jump action
jumperPlayer.jump();
// Movement based on tap position
if (x < 1024) {
// Left side - move left
jumperPlayer.moveLeft();
} else {
// Right side - move right
jumperPlayer.moveRight();
}
}
};
game.up = function (x, y, obj) {
// No specific up actions for jumper
};
game.move = function (x, y, obj) {
// No move actions for jumper (using tap for movement)
};
game.update = function () {
if (currentGame === 'jumper') {
// Platform collision detection for static platforms
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 (jumperPlayer.intersects(platform)) {
var playerBottom = jumperPlayer.y + jumperPlayer.height / 2;
var playerTop = jumperPlayer.y - jumperPlayer.height / 2;
var platformTop = platform.y - platformHeight / 2;
var platformBottom = platform.y + platformHeight / 2;
// Check if player is landing on top of platform
if (jumperPlayer.velocityY > 0 && jumperPlayer.lastY + jumperPlayer.height / 2 <= platformTop + 5) {
// Landing on top
jumperPlayer.y = platformTop - jumperPlayer.height / 2;
jumperPlayer.velocityY = 0;
jumperPlayer.onGround = true;
} else if (jumperPlayer.velocityY < 0 && jumperPlayer.lastY - jumperPlayer.height / 2 >= platformBottom - 5) {
// Hitting from below
jumperPlayer.y = platformBottom + jumperPlayer.height / 2;
jumperPlayer.velocityY = 0;
}
}
}
// Platform collision detection for moving platforms
for (var i = 0; i < movingPlatforms.length; i++) {
var platform = movingPlatforms[i];
var platformWidth = platform.width * platform.scaleX;
var platformHeight = platform.height;
// Check if player is overlapping with platform
if (jumperPlayer.intersects(platform)) {
var playerBottom = jumperPlayer.y + jumperPlayer.height / 2;
var playerTop = jumperPlayer.y - jumperPlayer.height / 2;
var platformTop = platform.y - platformHeight / 2;
var platformBottom = platform.y + platformHeight / 2;
// Check if player is landing on top of platform
if (jumperPlayer.velocityY > 0 && jumperPlayer.lastY + jumperPlayer.height / 2 <= platformTop + 5) {
// Landing on top
jumperPlayer.y = platformTop - jumperPlayer.height / 2;
jumperPlayer.velocityY = 0;
jumperPlayer.onGround = true;
// Move player with platform
jumperPlayer.x += platform.speed * platform.direction;
} else if (jumperPlayer.velocityY < 0 && jumperPlayer.lastY - jumperPlayer.height / 2 >= platformBottom - 5) {
// Hitting from below
jumperPlayer.y = platformBottom + jumperPlayer.height / 2;
jumperPlayer.velocityY = 0;
}
}
}
// Coin collection
for (var i = coins.length - 1; i >= 0; i--) {
if (!coins[i].collected && jumperPlayer.intersects(coins[i])) {
LK.getSound('collect').play();
LK.setScore(LK.getScore() + 100);
updateScoreDisplay();
coins[i].collected = true;
// Visual feedback - make coin disappear
tween(coins[i], {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 300,
onFinish: function onFinish() {
coins[i].destroy();
}
});
coins.splice(i, 1);
}
}
// Win condition - collect all coins
if (coins.length === 0) {
LK.setScore(LK.getScore() + 500);
updateScoreDisplay();
LK.setTimeout(function () {
LK.showYouWin();
}, 500);
}
// Award points for height achieved
var currentHeight = 2732 - jumperPlayer.y;
var heightScore = Math.floor(currentHeight / 100) * 5;
if (heightScore > 0 && LK.ticks % 60 === 0) {
LK.setScore(LK.getScore() + heightScore);
updateScoreDisplay();
}
gameTimer++;
// Time limit - 3 minutes
if (gameTimer >= 10800) {
endCurrentGame();
}
}
};
// Initialize the jumper game
initializeJumper();
LK.playMusic('bgMusic'); ===================================================================
--- original.js
+++ change.js
@@ -666,8 +666,102 @@
updateScoreDisplay();
};
return self;
});
+var JumperCoin = 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.collected = false;
+ self.update = function () {
+ if (!self.collected) {
+ self.y = self.startY + Math.sin(LK.ticks * 0.1 + self.bobOffset) * 10;
+ graphic.rotation += 0.05;
+ }
+ };
+ return self;
+});
+var JumperPlatform = Container.expand(function (width) {
+ var self = Container.call(this);
+ var graphic = self.attachAsset('platform', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ if (width) {
+ graphic.scaleX = width / 200;
+ }
+ return self;
+});
+var JumperPlayer = 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 = 1.2;
+ self.jumpPower = -20;
+ self.speed = 8;
+ self.maxSpeed = 12;
+ 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 > 25) self.velocityY = 25; // Terminal velocity
+ // Apply horizontal velocity
+ self.x += self.velocityX;
+ // Apply vertical velocity
+ self.y += self.velocityY;
+ // Friction
+ self.velocityX *= 0.9;
+ // 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 > 2900) {
+ self.x = 200;
+ self.y = 2000;
+ self.velocityX = 0;
+ self.velocityY = 0;
+ LK.setScore(Math.max(0, LK.getScore() - 50));
+ updateScoreDisplay();
+ }
+ 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 MazePlayer = Container.expand(function () {
var self = Container.call(this);
var graphic = self.attachAsset('mazePlayer', {
anchorX: 0.5,
@@ -691,8 +785,30 @@
anchorY: 0.5
});
return self;
});
+var MovingPlatform = Container.expand(function (width, startX, endX) {
+ var self = Container.call(this);
+ var graphic = self.attachAsset('platform', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ if (width) {
+ graphic.scaleX = width / 200;
+ }
+ graphic.tint = 0x74b9ff; // Blue tint for moving platforms
+ self.startX = startX;
+ self.endX = endX;
+ self.speed = 2;
+ self.direction = 1;
+ self.update = function () {
+ self.x += self.speed * self.direction;
+ if (self.x >= self.endX || self.x <= self.startX) {
+ self.direction *= -1;
+ }
+ };
+ return self;
+});
var Paddle = Container.expand(function () {
var self = Container.call(this);
var graphic = self.attachAsset('paddle', {
anchorX: 0.5,
@@ -944,1042 +1060,332 @@
/****
* Game Code
****/
-// Game 3: Block Breaker
-// Game 2: Snake-like Runner
-// Game 1: Tap the Circles
+// Jumper Game - A platformer jumping game
// Game state management
-var currentGame = 'hub';
+var currentGame = 'jumper';
var gameStates = {
- hub: 'hub',
- tapCircles: 'tapCircles',
- snakeRunner: 'snakeRunner',
- blockBreaker: 'blockBreaker',
- maze: 'maze',
- platformer: 'platformer'
+ jumper: 'jumper'
};
-// 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;
+// Load saved data
+var jumperBest = storage.jumperBest || 0;
// Game definitions
-var geometryDashBest = storage.geometryDashBest || 0;
var gameInfo = [{
- id: 'tapCircles',
- title: 'Tap Circles',
- bestScore: tapCirclesBest,
+ id: 'jumper',
+ title: 'Jumper',
+ bestScore: jumperBest,
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 jumperPlayer;
var platforms = [];
+var movingPlatforms = [];
var coins = [];
-var dashPlayer;
-var dashObstacles = [];
-var dashPortals = [];
-var dashGroundPieces = [];
-var dashSpawnTimer = 0;
-var dashDistance = 0;
-var dashDifficulty = 1;
+var gameTimer = 0;
// UI elements
var currentScoreText;
-var backButton;
-// Game timers
-var spawnTimer = 0;
-var gameTimer = 0;
-function initializeHub() {
+function initializeJumper() {
// Clear game
while (game.children.length > 0) {
game.removeChild(game.children[0]);
}
- // Clear GUI
+ // 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', {
+ // Create background
+ var bg = game.addChild(LK.getAsset('gameBackground1', {
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;
+ platforms = [];
+ movingPlatforms = [];
+ coins = [];
gameTimer = 0;
LK.setScore(0);
- // Create back button
- backButton = new Text2('← Back to Hub', {
- size: 48,
- fill: 0xFFFFFF
- });
- backButton.anchor.set(1, 0);
- backButton.x = 1950;
- backButton.y = 50;
- 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 back button
- backButton = new Text2('← Back to Hub', {
- size: 48,
- fill: 0xFFFFFF
- });
- backButton.anchor.set(1, 0);
- backButton.x = 1950;
- backButton.y = 50;
- 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
+ // Create static platforms
var platformData = [{
- x: 200,
- y: 2600,
- width: 400
+ x: 1024,
+ y: 2650,
+ width: 800
}, {
- x: 700,
+ x: 300,
y: 2400,
width: 200
}, {
- x: 1200,
+ x: 800,
y: 2200,
- width: 200
+ width: 150
}, {
- x: 1600,
+ x: 1400,
y: 2000,
width: 200
}, {
- x: 1000,
+ x: 600,
y: 1800,
- width: 300
+ width: 180
}, {
- x: 400,
+ x: 1200,
y: 1600,
- width: 250
+ width: 160
}, {
- x: 1400,
+ x: 400,
y: 1400,
- width: 200
+ width: 140
}, {
- x: 800,
+ x: 1000,
y: 1200,
- width: 300
+ width: 120
}, {
- x: 200,
+ x: 1600,
y: 1000,
- width: 200
+ width: 100
}, {
- x: 1600,
+ x: 700,
y: 800,
- width: 200
+ width: 150
}, {
- x: 1000,
+ x: 300,
y: 600,
- width: 400
+ width: 180
+ }, {
+ x: 1400,
+ y: 400,
+ width: 200
}];
for (var i = 0; i < platformData.length; i++) {
- var platform = game.addChild(new Platform());
+ var platform = game.addChild(new JumperPlatform(platformData[i].width));
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
+ // Create moving platforms
+ var movingPlatformData = [{
+ startX: 200,
+ endX: 600,
+ y: 1500,
+ width: 120
+ }, {
+ startX: 1200,
+ endX: 1700,
+ y: 1100,
+ width: 100
+ }, {
+ startX: 500,
+ endX: 900,
+ y: 700,
+ width: 140
+ }];
+ for (var i = 0; i < movingPlatformData.length; i++) {
+ var data = movingPlatformData[i];
+ var movingPlatform = game.addChild(new MovingPlatform(data.width, data.startX, data.endX));
+ movingPlatform.x = data.startX;
+ movingPlatform.y = data.y;
+ movingPlatforms.push(movingPlatform);
+ }
+ // Create coins
var coinPositions = [{
- x: 700,
+ x: 300,
y: 2350
}, {
- x: 1200,
+ x: 800,
y: 2150
}, {
- x: 1600,
+ x: 1400,
y: 1950
}, {
- x: 1000,
+ x: 600,
y: 1750
}, {
- x: 400,
+ x: 1200,
y: 1550
}, {
- x: 1400,
+ x: 400,
y: 1350
}, {
- x: 800,
+ x: 1000,
y: 1150
}, {
- x: 200,
+ x: 1600,
y: 950
}, {
- x: 1600,
+ x: 700,
y: 750
}, {
- x: 1000,
+ x: 300,
y: 550
+ }, {
+ x: 1400,
+ y: 350
}];
for (var i = 0; i < coinPositions.length; i++) {
- var coin = game.addChild(new Coin());
+ var coin = game.addChild(new JumperCoin());
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!', {
+ // Create player
+ jumperPlayer = game.addChild(new JumperPlayer());
+ jumperPlayer.x = 1024;
+ jumperPlayer.y = 2500;
+ // Create instructions
+ var instructions = new Text2('Tap to jump! Use left/right areas to move. Collect all coins to win!', {
size: 36,
fill: 0xFFFFFF
});
instructions.anchor.set(0.5, 0.5);
instructions.x = 1024;
- instructions.y = 300;
+ instructions.y = 200;
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('Enhanced Creator: Place objects, resize, copy, use grid snap, save/load levels!', {
- size: 32,
- fill: 0xFFFFFF
- });
- instructions.anchor.set(0.5, 0.5);
- instructions.x = 1024;
- instructions.y = 220;
- game.addChild(instructions);
- var modeText = new Text2('Mode: Place | Object: Box | Grid: ON', {
- size: 28,
- fill: 0x74b9ff
- });
- modeText.anchor.set(0, 0);
- modeText.x = 50;
- modeText.y = 250;
- game.addChild(modeText);
- gameCreator.modeText = modeText;
-}
-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 (currentScore > jumperBest) {
+ jumperBest = currentScore;
+ storage.jumperBest = currentScore;
}
- 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
+ // Return to start 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();
- }
- }
+ initializeJumper();
}, 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 <= 180) {
- gameCreator.handleToolClick(x, y);
- // Update mode display
- if (gameCreator.modeText) {
- var modeStr = 'Mode: ' + gameCreator.mode.charAt(0).toUpperCase() + gameCreator.mode.slice(1);
- var objStr = ' | Object: ' + gameCreator.currentObjectType.charAt(0).toUpperCase() + gameCreator.currentObjectType.slice(1);
- var gridStr = ' | Grid: ' + (gameCreator.snapToGrid ? 'ON' : 'OFF');
- gameCreator.modeText.setText(modeStr + objStr + gridStr);
- }
+ if (currentGame === 'jumper' && jumperPlayer) {
+ // Jump action
+ jumperPlayer.jump();
+ // Movement based on tap position
+ if (x < 1024) {
+ // Left side - move left
+ jumperPlayer.moveLeft();
} else {
- gameCreator.handleCanvasClick(x, y);
+ // Right side - move right
+ jumperPlayer.moveRight();
}
- } 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();
- }
+ // No specific up actions for jumper
};
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();
- }
- }
- }
- }
+ // No move actions for jumper (using tap for movement)
};
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();
- // Grow the snake body
- snake.grow();
- 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
+ if (currentGame === 'jumper') {
+ // Platform collision detection for static platforms
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;
+ if (jumperPlayer.intersects(platform)) {
+ var playerBottom = jumperPlayer.y + jumperPlayer.height / 2;
+ var playerTop = jumperPlayer.y - jumperPlayer.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) {
+ if (jumperPlayer.velocityY > 0 && jumperPlayer.lastY + jumperPlayer.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) {
+ jumperPlayer.y = platformTop - jumperPlayer.height / 2;
+ jumperPlayer.velocityY = 0;
+ jumperPlayer.onGround = true;
+ } else if (jumperPlayer.velocityY < 0 && jumperPlayer.lastY - jumperPlayer.height / 2 >= platformBottom - 5) {
// Hitting from below
- platformPlayer.y = platformBottom + platformPlayer.height / 2;
- platformPlayer.velocityY = 0;
+ jumperPlayer.y = platformBottom + jumperPlayer.height / 2;
+ jumperPlayer.velocityY = 0;
}
}
}
+ // Platform collision detection for moving platforms
+ for (var i = 0; i < movingPlatforms.length; i++) {
+ var platform = movingPlatforms[i];
+ var platformWidth = platform.width * platform.scaleX;
+ var platformHeight = platform.height;
+ // Check if player is overlapping with platform
+ if (jumperPlayer.intersects(platform)) {
+ var playerBottom = jumperPlayer.y + jumperPlayer.height / 2;
+ var playerTop = jumperPlayer.y - jumperPlayer.height / 2;
+ var platformTop = platform.y - platformHeight / 2;
+ var platformBottom = platform.y + platformHeight / 2;
+ // Check if player is landing on top of platform
+ if (jumperPlayer.velocityY > 0 && jumperPlayer.lastY + jumperPlayer.height / 2 <= platformTop + 5) {
+ // Landing on top
+ jumperPlayer.y = platformTop - jumperPlayer.height / 2;
+ jumperPlayer.velocityY = 0;
+ jumperPlayer.onGround = true;
+ // Move player with platform
+ jumperPlayer.x += platform.speed * platform.direction;
+ } else if (jumperPlayer.velocityY < 0 && jumperPlayer.lastY - jumperPlayer.height / 2 >= platformBottom - 5) {
+ // Hitting from below
+ jumperPlayer.y = platformBottom + jumperPlayer.height / 2;
+ jumperPlayer.velocityY = 0;
+ }
+ }
+ }
// Coin collection
for (var i = coins.length - 1; i >= 0; i--) {
- if (platformPlayer.intersects(coins[i])) {
+ if (!coins[i].collected && jumperPlayer.intersects(coins[i])) {
LK.getSound('collect').play();
- LK.setScore(LK.getScore() + 20);
+ LK.setScore(LK.getScore() + 100);
updateScoreDisplay();
- coins[i].destroy();
+ coins[i].collected = true;
+ // Visual feedback - make coin disappear
+ tween(coins[i], {
+ alpha: 0,
+ scaleX: 2,
+ scaleY: 2
+ }, {
+ duration: 300,
+ onFinish: function onFinish() {
+ coins[i].destroy();
+ }
+ });
coins.splice(i, 1);
}
}
// Win condition - collect all coins
if (coins.length === 0) {
- LK.setScore(LK.getScore() + 100);
+ LK.setScore(LK.getScore() + 500);
updateScoreDisplay();
- endCurrentGame();
+ LK.setTimeout(function () {
+ LK.showYouWin();
+ }, 500);
}
- 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));
+ // Award points for height achieved
+ var currentHeight = 2732 - jumperPlayer.y;
+ var heightScore = Math.floor(currentHeight / 100) * 5;
+ if (heightScore > 0 && LK.ticks % 60 === 0) {
+ LK.setScore(LK.getScore() + heightScore);
updateScoreDisplay();
}
- // Auto end after very long play
gameTimer++;
- if (gameTimer >= 18000) {
- // 5 minutes
+ // Time limit - 3 minutes
+ if (gameTimer >= 10800) {
endCurrentGame();
}
}
};
-// Initialize the hub
-initializeHub();
+// Initialize the jumper game
+initializeJumper();
LK.playMusic('bgMusic');
\ No newline at end of file
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