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 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
****/
// Basic game initialization
LK.setScore(0);
// Simple welcome message
var welcomeText = new Text2('Welcome to FRVR Games!', {
size: 64,
fill: 0xFFFFFF
});
welcomeText.anchor.set(0.5, 0.5);
welcomeText.x = 1024;
welcomeText.y = 1366;
game.addChild(welcomeText);
// Basic event handlers
game.down = function (x, y, obj) {
LK.getSound('tap').play();
};
game.up = function (x, y, obj) {
// Handle up events
};
game.move = function (x, y, obj) {
// Handle move events
};
game.update = function () {
// Game update loop
};
LK.playMusic('bgMusic'); ===================================================================
--- original.js
+++ change.js
@@ -666,102 +666,8 @@
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,
@@ -1060,363 +966,29 @@
/****
* 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 back to hub button
- var backButton = new Text2('← HUB', {
- size: 36,
- fill: 0x74b9ff
- });
- backButton.anchor.set(1, 0);
- backButton.x = LK.gui.topRight.x - 20;
- backButton.y = 20;
- LK.gui.topRight.addChild(backButton);
- // Add click handler for back button
- 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
- });
- // Return to game hub (restart the game)
- initializeJumper();
- };
- // 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
+// Basic game initialization
+LK.setScore(0);
+// Simple welcome message
+var welcomeText = new Text2('Welcome to FRVR Games!', {
+ size: 64,
+ fill: 0xFFFFFF
+});
+welcomeText.anchor.set(0.5, 0.5);
+welcomeText.x = 1024;
+welcomeText.y = 1366;
+game.addChild(welcomeText);
+// Basic 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();
- }
- }
+ LK.getSound('tap').play();
};
game.up = function (x, y, obj) {
- // No specific up actions for jumper
+ // Handle up events
};
game.move = function (x, y, obj) {
- // No move actions for jumper (using tap for movement)
+ // Handle move events
};
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;
- // Store reference to coin before removing from array
- var coinToDestroy = coins[i];
- coins.splice(i, 1);
- // Visual feedback - make coin disappear
- tween(coinToDestroy, {
- alpha: 0,
- scaleX: 2,
- scaleY: 2
- }, {
- duration: 300,
- onFinish: function onFinish() {
- coinToDestroy.destroy();
- }
- });
- }
- }
- // 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();
- }
- }
+ // Game update loop
};
-// 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