User prompt
Make the shield texture an asset named shield
User prompt
hey bro The code is not working properly and we want to at least have an asset (new) effect on it.
Code edit (4 edits merged)
Please save this source code
User prompt
When we start the game, we cannot move, use our abilities and take damage for the first 1.5 seconds, we have a shield effect on us. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
HEYYYY??????!!!!.?There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.There is an asset called bullet, use it on the texture of the bullet fired by the player, and there is another asset called button, use it on the small texture inside the buttons.
Code edit (1 edits merged)
Please save this source code
User prompt
When time slows down, enemies move as well, but at 0.25x speed. It doesn't damage enemies. When you damage them, enemies move and others come. And make it harder to get the purple thing to win the game
User prompt
They do not redirect when you click on the buttons
User prompt
Add 4 buttons that direct right, left, up and down instead of joystick
User prompt
Move the joystick correctly so that we can use it left, right, up and down.
User prompt
The joystick should be bigger and when you use the joystick, the game should not get a bug and time should not slow down. Also, time should not stop but slow down to 0.25x speed, meaning the player's bullets and the enemy bullets should slow down only
User prompt
Let's have a gun so we can move, let's shoot a bullet every 1.5 seconds, let the enemies shoot bullets at 2-second intervals and there will be a movement joystick on the screen to move the character and the screen When we click, time will slow down instead of stopping, our bullets, enemies and bullets will slow down. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Time Freeze
Initial prompt
Pause the game
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
level: 1,
highScore: 0
});
/****
* Classes
****/
var Collectible = Container.expand(function () {
var self = Container.call(this);
var sprite = self.attachAsset('collectible', {
anchorX: 0.5,
anchorY: 0.5
});
self.value = 1;
self.type = "standard"; // can be "standard" or "timeRecharge"
self.setValue = function (value) {
self.value = value;
};
self.setType = function (type) {
self.type = type;
if (type === "timeRecharge") {
sprite.tint = 0x3498db; // Blue for time recharge
}
};
self.update = function () {
// Animate collectible
if (!timeIsFrozen) {
sprite.rotation += 0.02;
}
};
return self;
});
var Enemy = Container.expand(function () {
var self = Container.call(this);
var sprite = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 4;
self.target = null;
self.movementPattern = "chase"; // can be "chase", "patrol", or "random"
self.patrolPoints = [];
self.currentPatrolIndex = 0;
self.randomMoveCounter = 0;
self.setTarget = function (target) {
self.target = target;
};
self.setPatrolPoints = function (points) {
self.patrolPoints = points;
};
self.setMovementPattern = function (pattern) {
self.movementPattern = pattern;
};
self.update = function () {
if (!timeIsFrozen) {
if (self.movementPattern === "chase" && self.target) {
// Chase player
var dx = self.target.x - self.x;
var dy = self.target.y - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist > 0) {
self.x += dx / dist * self.speed;
self.y += dy / dist * self.speed;
}
} else if (self.movementPattern === "patrol" && self.patrolPoints.length > 0) {
// Patrol between points
var targetPoint = self.patrolPoints[self.currentPatrolIndex];
var dx = targetPoint.x - self.x;
var dy = targetPoint.y - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 10) {
// Reached the point, move to next patrol point
self.currentPatrolIndex = (self.currentPatrolIndex + 1) % self.patrolPoints.length;
} else {
self.x += dx / dist * self.speed;
self.y += dy / dist * self.speed;
}
} else if (self.movementPattern === "random") {
// Random movement
self.randomMoveCounter--;
if (self.randomMoveCounter <= 0) {
self.vx = Math.random() * self.speed * 2 - self.speed;
self.vy = Math.random() * self.speed * 2 - self.speed;
self.randomMoveCounter = Math.floor(Math.random() * 60) + 30;
}
self.x += self.vx;
self.y += self.vy;
// Bounce off walls
if (self.x <= sprite.width / 2 || self.x >= 2048 - sprite.width / 2) {
self.vx *= -1;
}
if (self.y <= sprite.height / 2 || self.y >= 2732 - sprite.height / 2) {
self.vy *= -1;
}
}
}
};
return self;
});
var LevelEnd = Container.expand(function () {
var self = Container.call(this);
var sprite = self.attachAsset('levelEnd', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Animate the level end gate
if (!timeIsFrozen) {
sprite.rotation += 0.01;
}
};
return self;
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var sprite = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.vx = 0;
self.vy = 0;
self.update = function () {
if (!timeIsFrozen) {
self.x += self.vx;
self.y += self.vy;
// Bounce off walls
if (self.x <= sprite.width / 2 || self.x >= 2048 - sprite.width / 2) {
self.vx *= -1;
}
if (self.y <= sprite.height / 2 || self.y >= 2732 - sprite.height / 2) {
self.vy *= -1;
}
}
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var sprite = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.isDragging = false;
self.lastPosition = {
x: 0,
y: 0
};
self.setDragging = function (isDragging) {
self.isDragging = isDragging;
};
self.move = function (x, y) {
if (self.isDragging && !timeIsFrozen) {
self.x = x;
self.y = y;
}
};
self.update = function () {
// Constrain player to game boundaries
if (self.x < sprite.width / 2) self.x = sprite.width / 2;
if (self.x > 2048 - sprite.width / 2) self.x = 2048 - sprite.width / 2;
if (self.y < sprite.height / 2) self.y = sprite.height / 2;
if (self.y > 2732 - sprite.height / 2) self.y = 2732 - sprite.height / 2;
// Store last position
self.lastPosition.x = self.x;
self.lastPosition.y = self.y;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x34495e
});
/****
* Game Code
****/
// Game state variables
var currentLevel = storage.level || 1;
var score = 0;
var timeIsFrozen = false;
var pauseEnergy = 100;
var pauseEnergyMax = 100;
var pauseEnergyDrainRate = 0.5;
var levelComplete = false;
var player;
var obstacles = [];
var enemies = [];
var collectibles = [];
var levelEnd;
var freezeEffect;
// UI elements
var scoreTxt;
var levelTxt;
var pauseBarBg;
var pauseBar;
var instructionsTxt;
function initGame() {
// Clear existing objects if any
obstacles = [];
enemies = [];
collectibles = [];
// Reset game state
pauseEnergy = pauseEnergyMax;
timeIsFrozen = false;
levelComplete = false;
score = LK.getScore();
// Create UI
createUI();
// Create player
player = new Player();
player.x = 200;
player.y = 300;
game.addChild(player);
// Create freeze effect (initially invisible)
freezeEffect = LK.getAsset('freezeEffect', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0
});
freezeEffect.x = 2048 / 2;
freezeEffect.y = 2732 / 2;
game.addChild(freezeEffect);
// Create level based on current level
createLevel(currentLevel);
// Start background music
LK.playMusic('bgmusic');
}
function createUI() {
// Score text
scoreTxt = new Text2('Score: 0', {
size: 70,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0, 0);
scoreTxt.x = 120;
scoreTxt.y = 30;
LK.gui.addChild(scoreTxt);
// Level text
levelTxt = new Text2('Level: ' + currentLevel, {
size: 70,
fill: 0xFFFFFF
});
levelTxt.anchor.set(1, 0);
levelTxt.x = 2048 - 120;
levelTxt.y = 30;
LK.gui.addChild(levelTxt);
// Pause energy bar background
pauseBarBg = LK.getAsset('pauseBarBackground', {
anchorX: 0.5,
anchorY: 0.5
});
pauseBarBg.x = 2048 / 2;
pauseBarBg.y = 100;
LK.gui.addChild(pauseBarBg);
// Pause energy bar
pauseBar = LK.getAsset('pauseBar', {
anchorX: 0,
anchorY: 0.5
});
pauseBar.x = pauseBarBg.x - pauseBarBg.width / 2;
pauseBar.y = pauseBarBg.y;
pauseBar.width = pauseBarBg.width * (pauseEnergy / pauseEnergyMax);
LK.gui.addChild(pauseBar);
// Instructions
instructionsTxt = new Text2('Tap and hold player to move. Tap anywhere else to freeze time.\nFreeze time to avoid obstacles and enemies!', {
size: 50,
fill: 0xFFFFFF
});
instructionsTxt.anchor.set(0.5, 0);
instructionsTxt.x = 2048 / 2;
instructionsTxt.y = 150;
LK.gui.addChild(instructionsTxt);
// Auto-hide instructions after 5 seconds
LK.setTimeout(function () {
tween(instructionsTxt, {
alpha: 0
}, {
duration: 1000
});
}, 5000);
}
function createLevel(level) {
// Each level has a different configuration
switch (level) {
case 1:
// Level 1: Simple introduction
createObstacle(600, 500, 3, 0);
createObstacle(1200, 800, -2, 2);
createObstacle(1600, 1200, 0, 4);
createCollectible(800, 600);
createCollectible(1400, 1000);
createCollectible(1700, 1800);
createCollectible(500, 1500, "timeRecharge");
// Level end
levelEnd = new LevelEnd();
levelEnd.x = 1800;
levelEnd.y = 2400;
game.addChild(levelEnd);
break;
case 2:
// Level 2: Introduce enemies
createObstacle(600, 500, 4, 0);
createObstacle(1200, 800, -3, 3);
createObstacle(1600, 1200, 0, 5);
createObstacle(900, 1600, 4, -2);
var enemy = createEnemy(1000, 1000, "chase");
enemy.setTarget(player);
createCollectible(800, 600);
createCollectible(1400, 1000);
createCollectible(1700, 1800);
createCollectible(500, 1500);
createCollectible(1200, 2200, "timeRecharge");
// Level end
levelEnd = new LevelEnd();
levelEnd.x = 1800;
levelEnd.y = 2400;
game.addChild(levelEnd);
break;
case 3:
// Level 3: More complex with patrol enemies
createObstacle(600, 500, 5, 0);
createObstacle(1200, 800, -4, 3);
createObstacle(1600, 1200, 0, 6);
createObstacle(900, 1600, 5, -3);
createObstacle(1400, 2000, -3, -3);
var enemy1 = createEnemy(1000, 1000, "chase");
enemy1.setTarget(player);
var enemy2 = createEnemy(1500, 1500, "patrol");
enemy2.setPatrolPoints([{
x: 1500,
y: 1500
}, {
x: 1500,
y: 2000
}, {
x: 1000,
y: 2000
}, {
x: 1000,
y: 1500
}]);
createCollectible(800, 600);
createCollectible(1400, 1000);
createCollectible(1700, 1800);
createCollectible(500, 1500);
createCollectible(1200, 2200);
createCollectible(1800, 1300, "timeRecharge");
// Level end
levelEnd = new LevelEnd();
levelEnd.x = 1800;
levelEnd.y = 2400;
game.addChild(levelEnd);
break;
default:
// Higher levels: Procedurally generate increasingly difficult layouts
var obstacleCount = 3 + Math.min(level, 7);
var enemyCount = 1 + Math.min(level - 2, 5);
var collectibleCount = 4 + Math.min(level, 6);
// Create obstacles
for (var i = 0; i < obstacleCount; i++) {
var x = 400 + Math.random() * 1600;
var y = 400 + Math.random() * 1800;
var vx = (Math.random() * 6 + 2) * (Math.random() > 0.5 ? 1 : -1);
var vy = (Math.random() * 6 + 2) * (Math.random() > 0.5 ? 1 : -1);
createObstacle(x, y, vx, vy);
}
// Create enemies
for (var i = 0; i < enemyCount; i++) {
var x = 400 + Math.random() * 1600;
var y = 400 + Math.random() * 1800;
var patternType = Math.random();
if (patternType < 0.4) {
var enemy = createEnemy(x, y, "chase");
enemy.setTarget(player);
} else if (patternType < 0.7) {
var enemy = createEnemy(x, y, "patrol");
var patrolRadius = 300 + Math.random() * 300;
var patrolPoints = [];
var patrolPointCount = 3 + Math.floor(Math.random() * 3);
for (var j = 0; j < patrolPointCount; j++) {
var angle = j / patrolPointCount * Math.PI * 2;
patrolPoints.push({
x: x + Math.cos(angle) * patrolRadius,
y: y + Math.sin(angle) * patrolRadius
});
}
enemy.setPatrolPoints(patrolPoints);
} else {
createEnemy(x, y, "random");
}
}
// Create collectibles
for (var i = 0; i < collectibleCount; i++) {
var x = 300 + Math.random() * 1700;
var y = 300 + Math.random() * 2000;
if (i === collectibleCount - 1) {
createCollectible(x, y, "timeRecharge");
} else {
createCollectible(x, y);
}
}
// Level end
levelEnd = new LevelEnd();
levelEnd.x = 1700 + Math.random() * 200;
levelEnd.y = 2200 + Math.random() * 300;
game.addChild(levelEnd);
break;
}
}
function createObstacle(x, y, vx, vy) {
var obstacle = new Obstacle();
obstacle.x = x;
obstacle.y = y;
obstacle.vx = vx;
obstacle.vy = vy;
obstacles.push(obstacle);
game.addChild(obstacle);
return obstacle;
}
function createEnemy(x, y, movementPattern) {
var enemy = new Enemy();
enemy.x = x;
enemy.y = y;
enemy.setMovementPattern(movementPattern);
enemies.push(enemy);
game.addChild(enemy);
return enemy;
}
function createCollectible(x, y, type) {
var collectible = new Collectible();
collectible.x = x;
collectible.y = y;
if (type === "timeRecharge") {
collectible.setType("timeRecharge");
}
collectibles.push(collectible);
game.addChild(collectible);
return collectible;
}
function toggleFreezeTime() {
if (pauseEnergy <= 0 && timeIsFrozen) {
// Can't stay frozen with no energy
unfreezeTime();
return;
}
if (!timeIsFrozen && pauseEnergy > 0) {
// Freeze time
timeIsFrozen = true;
tween(freezeEffect, {
alpha: 0.3
}, {
duration: 300
});
LK.getSound('freeze').play();
} else if (timeIsFrozen) {
// Unfreeze time
unfreezeTime();
}
}
function unfreezeTime() {
timeIsFrozen = false;
tween(freezeEffect, {
alpha: 0
}, {
duration: 300
});
LK.getSound('unfreeze').play();
}
function updatePauseEnergyBar() {
pauseBar.width = pauseBarBg.width * (pauseEnergy / pauseEnergyMax);
}
function checkCollisions() {
// Check player-obstacle collisions
for (var i = 0; i < obstacles.length; i++) {
if (player.intersects(obstacles[i])) {
handlePlayerHit();
return;
}
}
// Check player-enemy collisions
for (var i = 0; i < enemies.length; i++) {
if (player.intersects(enemies[i])) {
handlePlayerHit();
return;
}
}
// Check player-collectible collisions
for (var i = collectibles.length - 1; i >= 0; i--) {
if (player.intersects(collectibles[i])) {
// Collect the item
if (collectibles[i].type === "timeRecharge") {
pauseEnergy = Math.min(pauseEnergyMax, pauseEnergy + 50);
updatePauseEnergyBar();
} else {
score += collectibles[i].value;
LK.setScore(score);
scoreTxt.setText('Score: ' + score);
}
LK.getSound('collect').play();
collectibles[i].destroy();
collectibles.splice(i, 1);
}
}
// Check if player reached the level end
if (levelEnd && player.intersects(levelEnd)) {
completeLevel();
}
}
function handlePlayerHit() {
if (!timeIsFrozen) {
// Flash the screen red
LK.effects.flashScreen(0xff0000, 500);
LK.getSound('hit').play();
// Show game over
LK.showGameOver();
}
}
function completeLevel() {
if (!levelComplete) {
levelComplete = true;
// Save progress
currentLevel++;
storage.level = currentLevel;
// Save high score
if (score > storage.highScore) {
storage.highScore = score;
}
// Play win sound
LK.getSound('win').play();
// Show level complete
LK.showYouWin();
}
}
// Game event handlers
game.down = function (x, y, obj) {
// Check if player was clicked
if (player.getBounds().contains(x, y)) {
player.setDragging(true);
} else if (!timeIsFrozen && pauseEnergy > 0) {
// Freeze time when clicking anywhere else (if we have energy)
toggleFreezeTime();
} else if (timeIsFrozen) {
// Unfreeze time when clicking anywhere else if already frozen
toggleFreezeTime();
}
};
game.up = function (x, y, obj) {
player.setDragging(false);
};
game.move = function (x, y, obj) {
player.move(x, y);
};
// Game update loop
game.update = function () {
// Check if game is initialized
if (!player) {
initGame();
return;
}
// Drain pause energy when time is frozen
if (timeIsFrozen) {
pauseEnergy = Math.max(0, pauseEnergy - pauseEnergyDrainRate);
updatePauseEnergyBar();
// Automatically unfreeze when energy is depleted
if (pauseEnergy <= 0) {
unfreezeTime();
}
} else if (pauseEnergy < pauseEnergyMax) {
// Slowly recharge when not frozen
pauseEnergy = Math.min(pauseEnergyMax, pauseEnergy + 0.1);
updatePauseEnergyBar();
}
// Update game objects
player.update();
for (var i = 0; i < obstacles.length; i++) {
obstacles[i].update();
}
for (var i = 0; i < enemies.length; i++) {
enemies[i].update();
}
for (var i = 0; i < collectibles.length; i++) {
collectibles[i].update();
}
if (levelEnd) {
levelEnd.update();
}
// Check for collisions
checkCollisions();
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,598 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1", {
+ level: 1,
+ highScore: 0
+});
+
+/****
+* Classes
+****/
+var Collectible = Container.expand(function () {
+ var self = Container.call(this);
+ var sprite = self.attachAsset('collectible', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.value = 1;
+ self.type = "standard"; // can be "standard" or "timeRecharge"
+ self.setValue = function (value) {
+ self.value = value;
+ };
+ self.setType = function (type) {
+ self.type = type;
+ if (type === "timeRecharge") {
+ sprite.tint = 0x3498db; // Blue for time recharge
+ }
+ };
+ self.update = function () {
+ // Animate collectible
+ if (!timeIsFrozen) {
+ sprite.rotation += 0.02;
+ }
+ };
+ return self;
+});
+var Enemy = Container.expand(function () {
+ var self = Container.call(this);
+ var sprite = self.attachAsset('enemy', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 4;
+ self.target = null;
+ self.movementPattern = "chase"; // can be "chase", "patrol", or "random"
+ self.patrolPoints = [];
+ self.currentPatrolIndex = 0;
+ self.randomMoveCounter = 0;
+ self.setTarget = function (target) {
+ self.target = target;
+ };
+ self.setPatrolPoints = function (points) {
+ self.patrolPoints = points;
+ };
+ self.setMovementPattern = function (pattern) {
+ self.movementPattern = pattern;
+ };
+ self.update = function () {
+ if (!timeIsFrozen) {
+ if (self.movementPattern === "chase" && self.target) {
+ // Chase player
+ var dx = self.target.x - self.x;
+ var dy = self.target.y - self.y;
+ var dist = Math.sqrt(dx * dx + dy * dy);
+ if (dist > 0) {
+ self.x += dx / dist * self.speed;
+ self.y += dy / dist * self.speed;
+ }
+ } else if (self.movementPattern === "patrol" && self.patrolPoints.length > 0) {
+ // Patrol between points
+ var targetPoint = self.patrolPoints[self.currentPatrolIndex];
+ var dx = targetPoint.x - self.x;
+ var dy = targetPoint.y - self.y;
+ var dist = Math.sqrt(dx * dx + dy * dy);
+ if (dist < 10) {
+ // Reached the point, move to next patrol point
+ self.currentPatrolIndex = (self.currentPatrolIndex + 1) % self.patrolPoints.length;
+ } else {
+ self.x += dx / dist * self.speed;
+ self.y += dy / dist * self.speed;
+ }
+ } else if (self.movementPattern === "random") {
+ // Random movement
+ self.randomMoveCounter--;
+ if (self.randomMoveCounter <= 0) {
+ self.vx = Math.random() * self.speed * 2 - self.speed;
+ self.vy = Math.random() * self.speed * 2 - self.speed;
+ self.randomMoveCounter = Math.floor(Math.random() * 60) + 30;
+ }
+ self.x += self.vx;
+ self.y += self.vy;
+ // Bounce off walls
+ if (self.x <= sprite.width / 2 || self.x >= 2048 - sprite.width / 2) {
+ self.vx *= -1;
+ }
+ if (self.y <= sprite.height / 2 || self.y >= 2732 - sprite.height / 2) {
+ self.vy *= -1;
+ }
+ }
+ }
+ };
+ return self;
+});
+var LevelEnd = Container.expand(function () {
+ var self = Container.call(this);
+ var sprite = self.attachAsset('levelEnd', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.update = function () {
+ // Animate the level end gate
+ if (!timeIsFrozen) {
+ sprite.rotation += 0.01;
+ }
+ };
+ return self;
+});
+var Obstacle = Container.expand(function () {
+ var self = Container.call(this);
+ var sprite = self.attachAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.vx = 0;
+ self.vy = 0;
+ self.update = function () {
+ if (!timeIsFrozen) {
+ self.x += self.vx;
+ self.y += self.vy;
+ // Bounce off walls
+ if (self.x <= sprite.width / 2 || self.x >= 2048 - sprite.width / 2) {
+ self.vx *= -1;
+ }
+ if (self.y <= sprite.height / 2 || self.y >= 2732 - sprite.height / 2) {
+ self.vy *= -1;
+ }
+ }
+ };
+ return self;
+});
+var Player = Container.expand(function () {
+ var self = Container.call(this);
+ var sprite = self.attachAsset('player', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 8;
+ self.isDragging = false;
+ self.lastPosition = {
+ x: 0,
+ y: 0
+ };
+ self.setDragging = function (isDragging) {
+ self.isDragging = isDragging;
+ };
+ self.move = function (x, y) {
+ if (self.isDragging && !timeIsFrozen) {
+ self.x = x;
+ self.y = y;
+ }
+ };
+ self.update = function () {
+ // Constrain player to game boundaries
+ if (self.x < sprite.width / 2) self.x = sprite.width / 2;
+ if (self.x > 2048 - sprite.width / 2) self.x = 2048 - sprite.width / 2;
+ if (self.y < sprite.height / 2) self.y = sprite.height / 2;
+ if (self.y > 2732 - sprite.height / 2) self.y = 2732 - sprite.height / 2;
+ // Store last position
+ self.lastPosition.x = self.x;
+ self.lastPosition.y = self.y;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x34495e
+});
+
+/****
+* Game Code
+****/
+// Game state variables
+var currentLevel = storage.level || 1;
+var score = 0;
+var timeIsFrozen = false;
+var pauseEnergy = 100;
+var pauseEnergyMax = 100;
+var pauseEnergyDrainRate = 0.5;
+var levelComplete = false;
+var player;
+var obstacles = [];
+var enemies = [];
+var collectibles = [];
+var levelEnd;
+var freezeEffect;
+// UI elements
+var scoreTxt;
+var levelTxt;
+var pauseBarBg;
+var pauseBar;
+var instructionsTxt;
+function initGame() {
+ // Clear existing objects if any
+ obstacles = [];
+ enemies = [];
+ collectibles = [];
+ // Reset game state
+ pauseEnergy = pauseEnergyMax;
+ timeIsFrozen = false;
+ levelComplete = false;
+ score = LK.getScore();
+ // Create UI
+ createUI();
+ // Create player
+ player = new Player();
+ player.x = 200;
+ player.y = 300;
+ game.addChild(player);
+ // Create freeze effect (initially invisible)
+ freezeEffect = LK.getAsset('freezeEffect', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ alpha: 0
+ });
+ freezeEffect.x = 2048 / 2;
+ freezeEffect.y = 2732 / 2;
+ game.addChild(freezeEffect);
+ // Create level based on current level
+ createLevel(currentLevel);
+ // Start background music
+ LK.playMusic('bgmusic');
+}
+function createUI() {
+ // Score text
+ scoreTxt = new Text2('Score: 0', {
+ size: 70,
+ fill: 0xFFFFFF
+ });
+ scoreTxt.anchor.set(0, 0);
+ scoreTxt.x = 120;
+ scoreTxt.y = 30;
+ LK.gui.addChild(scoreTxt);
+ // Level text
+ levelTxt = new Text2('Level: ' + currentLevel, {
+ size: 70,
+ fill: 0xFFFFFF
+ });
+ levelTxt.anchor.set(1, 0);
+ levelTxt.x = 2048 - 120;
+ levelTxt.y = 30;
+ LK.gui.addChild(levelTxt);
+ // Pause energy bar background
+ pauseBarBg = LK.getAsset('pauseBarBackground', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ pauseBarBg.x = 2048 / 2;
+ pauseBarBg.y = 100;
+ LK.gui.addChild(pauseBarBg);
+ // Pause energy bar
+ pauseBar = LK.getAsset('pauseBar', {
+ anchorX: 0,
+ anchorY: 0.5
+ });
+ pauseBar.x = pauseBarBg.x - pauseBarBg.width / 2;
+ pauseBar.y = pauseBarBg.y;
+ pauseBar.width = pauseBarBg.width * (pauseEnergy / pauseEnergyMax);
+ LK.gui.addChild(pauseBar);
+ // Instructions
+ instructionsTxt = new Text2('Tap and hold player to move. Tap anywhere else to freeze time.\nFreeze time to avoid obstacles and enemies!', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ instructionsTxt.anchor.set(0.5, 0);
+ instructionsTxt.x = 2048 / 2;
+ instructionsTxt.y = 150;
+ LK.gui.addChild(instructionsTxt);
+ // Auto-hide instructions after 5 seconds
+ LK.setTimeout(function () {
+ tween(instructionsTxt, {
+ alpha: 0
+ }, {
+ duration: 1000
+ });
+ }, 5000);
+}
+function createLevel(level) {
+ // Each level has a different configuration
+ switch (level) {
+ case 1:
+ // Level 1: Simple introduction
+ createObstacle(600, 500, 3, 0);
+ createObstacle(1200, 800, -2, 2);
+ createObstacle(1600, 1200, 0, 4);
+ createCollectible(800, 600);
+ createCollectible(1400, 1000);
+ createCollectible(1700, 1800);
+ createCollectible(500, 1500, "timeRecharge");
+ // Level end
+ levelEnd = new LevelEnd();
+ levelEnd.x = 1800;
+ levelEnd.y = 2400;
+ game.addChild(levelEnd);
+ break;
+ case 2:
+ // Level 2: Introduce enemies
+ createObstacle(600, 500, 4, 0);
+ createObstacle(1200, 800, -3, 3);
+ createObstacle(1600, 1200, 0, 5);
+ createObstacle(900, 1600, 4, -2);
+ var enemy = createEnemy(1000, 1000, "chase");
+ enemy.setTarget(player);
+ createCollectible(800, 600);
+ createCollectible(1400, 1000);
+ createCollectible(1700, 1800);
+ createCollectible(500, 1500);
+ createCollectible(1200, 2200, "timeRecharge");
+ // Level end
+ levelEnd = new LevelEnd();
+ levelEnd.x = 1800;
+ levelEnd.y = 2400;
+ game.addChild(levelEnd);
+ break;
+ case 3:
+ // Level 3: More complex with patrol enemies
+ createObstacle(600, 500, 5, 0);
+ createObstacle(1200, 800, -4, 3);
+ createObstacle(1600, 1200, 0, 6);
+ createObstacle(900, 1600, 5, -3);
+ createObstacle(1400, 2000, -3, -3);
+ var enemy1 = createEnemy(1000, 1000, "chase");
+ enemy1.setTarget(player);
+ var enemy2 = createEnemy(1500, 1500, "patrol");
+ enemy2.setPatrolPoints([{
+ x: 1500,
+ y: 1500
+ }, {
+ x: 1500,
+ y: 2000
+ }, {
+ x: 1000,
+ y: 2000
+ }, {
+ x: 1000,
+ y: 1500
+ }]);
+ createCollectible(800, 600);
+ createCollectible(1400, 1000);
+ createCollectible(1700, 1800);
+ createCollectible(500, 1500);
+ createCollectible(1200, 2200);
+ createCollectible(1800, 1300, "timeRecharge");
+ // Level end
+ levelEnd = new LevelEnd();
+ levelEnd.x = 1800;
+ levelEnd.y = 2400;
+ game.addChild(levelEnd);
+ break;
+ default:
+ // Higher levels: Procedurally generate increasingly difficult layouts
+ var obstacleCount = 3 + Math.min(level, 7);
+ var enemyCount = 1 + Math.min(level - 2, 5);
+ var collectibleCount = 4 + Math.min(level, 6);
+ // Create obstacles
+ for (var i = 0; i < obstacleCount; i++) {
+ var x = 400 + Math.random() * 1600;
+ var y = 400 + Math.random() * 1800;
+ var vx = (Math.random() * 6 + 2) * (Math.random() > 0.5 ? 1 : -1);
+ var vy = (Math.random() * 6 + 2) * (Math.random() > 0.5 ? 1 : -1);
+ createObstacle(x, y, vx, vy);
+ }
+ // Create enemies
+ for (var i = 0; i < enemyCount; i++) {
+ var x = 400 + Math.random() * 1600;
+ var y = 400 + Math.random() * 1800;
+ var patternType = Math.random();
+ if (patternType < 0.4) {
+ var enemy = createEnemy(x, y, "chase");
+ enemy.setTarget(player);
+ } else if (patternType < 0.7) {
+ var enemy = createEnemy(x, y, "patrol");
+ var patrolRadius = 300 + Math.random() * 300;
+ var patrolPoints = [];
+ var patrolPointCount = 3 + Math.floor(Math.random() * 3);
+ for (var j = 0; j < patrolPointCount; j++) {
+ var angle = j / patrolPointCount * Math.PI * 2;
+ patrolPoints.push({
+ x: x + Math.cos(angle) * patrolRadius,
+ y: y + Math.sin(angle) * patrolRadius
+ });
+ }
+ enemy.setPatrolPoints(patrolPoints);
+ } else {
+ createEnemy(x, y, "random");
+ }
+ }
+ // Create collectibles
+ for (var i = 0; i < collectibleCount; i++) {
+ var x = 300 + Math.random() * 1700;
+ var y = 300 + Math.random() * 2000;
+ if (i === collectibleCount - 1) {
+ createCollectible(x, y, "timeRecharge");
+ } else {
+ createCollectible(x, y);
+ }
+ }
+ // Level end
+ levelEnd = new LevelEnd();
+ levelEnd.x = 1700 + Math.random() * 200;
+ levelEnd.y = 2200 + Math.random() * 300;
+ game.addChild(levelEnd);
+ break;
+ }
+}
+function createObstacle(x, y, vx, vy) {
+ var obstacle = new Obstacle();
+ obstacle.x = x;
+ obstacle.y = y;
+ obstacle.vx = vx;
+ obstacle.vy = vy;
+ obstacles.push(obstacle);
+ game.addChild(obstacle);
+ return obstacle;
+}
+function createEnemy(x, y, movementPattern) {
+ var enemy = new Enemy();
+ enemy.x = x;
+ enemy.y = y;
+ enemy.setMovementPattern(movementPattern);
+ enemies.push(enemy);
+ game.addChild(enemy);
+ return enemy;
+}
+function createCollectible(x, y, type) {
+ var collectible = new Collectible();
+ collectible.x = x;
+ collectible.y = y;
+ if (type === "timeRecharge") {
+ collectible.setType("timeRecharge");
+ }
+ collectibles.push(collectible);
+ game.addChild(collectible);
+ return collectible;
+}
+function toggleFreezeTime() {
+ if (pauseEnergy <= 0 && timeIsFrozen) {
+ // Can't stay frozen with no energy
+ unfreezeTime();
+ return;
+ }
+ if (!timeIsFrozen && pauseEnergy > 0) {
+ // Freeze time
+ timeIsFrozen = true;
+ tween(freezeEffect, {
+ alpha: 0.3
+ }, {
+ duration: 300
+ });
+ LK.getSound('freeze').play();
+ } else if (timeIsFrozen) {
+ // Unfreeze time
+ unfreezeTime();
+ }
+}
+function unfreezeTime() {
+ timeIsFrozen = false;
+ tween(freezeEffect, {
+ alpha: 0
+ }, {
+ duration: 300
+ });
+ LK.getSound('unfreeze').play();
+}
+function updatePauseEnergyBar() {
+ pauseBar.width = pauseBarBg.width * (pauseEnergy / pauseEnergyMax);
+}
+function checkCollisions() {
+ // Check player-obstacle collisions
+ for (var i = 0; i < obstacles.length; i++) {
+ if (player.intersects(obstacles[i])) {
+ handlePlayerHit();
+ return;
+ }
+ }
+ // Check player-enemy collisions
+ for (var i = 0; i < enemies.length; i++) {
+ if (player.intersects(enemies[i])) {
+ handlePlayerHit();
+ return;
+ }
+ }
+ // Check player-collectible collisions
+ for (var i = collectibles.length - 1; i >= 0; i--) {
+ if (player.intersects(collectibles[i])) {
+ // Collect the item
+ if (collectibles[i].type === "timeRecharge") {
+ pauseEnergy = Math.min(pauseEnergyMax, pauseEnergy + 50);
+ updatePauseEnergyBar();
+ } else {
+ score += collectibles[i].value;
+ LK.setScore(score);
+ scoreTxt.setText('Score: ' + score);
+ }
+ LK.getSound('collect').play();
+ collectibles[i].destroy();
+ collectibles.splice(i, 1);
+ }
+ }
+ // Check if player reached the level end
+ if (levelEnd && player.intersects(levelEnd)) {
+ completeLevel();
+ }
+}
+function handlePlayerHit() {
+ if (!timeIsFrozen) {
+ // Flash the screen red
+ LK.effects.flashScreen(0xff0000, 500);
+ LK.getSound('hit').play();
+ // Show game over
+ LK.showGameOver();
+ }
+}
+function completeLevel() {
+ if (!levelComplete) {
+ levelComplete = true;
+ // Save progress
+ currentLevel++;
+ storage.level = currentLevel;
+ // Save high score
+ if (score > storage.highScore) {
+ storage.highScore = score;
+ }
+ // Play win sound
+ LK.getSound('win').play();
+ // Show level complete
+ LK.showYouWin();
+ }
+}
+// Game event handlers
+game.down = function (x, y, obj) {
+ // Check if player was clicked
+ if (player.getBounds().contains(x, y)) {
+ player.setDragging(true);
+ } else if (!timeIsFrozen && pauseEnergy > 0) {
+ // Freeze time when clicking anywhere else (if we have energy)
+ toggleFreezeTime();
+ } else if (timeIsFrozen) {
+ // Unfreeze time when clicking anywhere else if already frozen
+ toggleFreezeTime();
+ }
+};
+game.up = function (x, y, obj) {
+ player.setDragging(false);
+};
+game.move = function (x, y, obj) {
+ player.move(x, y);
+};
+// Game update loop
+game.update = function () {
+ // Check if game is initialized
+ if (!player) {
+ initGame();
+ return;
+ }
+ // Drain pause energy when time is frozen
+ if (timeIsFrozen) {
+ pauseEnergy = Math.max(0, pauseEnergy - pauseEnergyDrainRate);
+ updatePauseEnergyBar();
+ // Automatically unfreeze when energy is depleted
+ if (pauseEnergy <= 0) {
+ unfreezeTime();
+ }
+ } else if (pauseEnergy < pauseEnergyMax) {
+ // Slowly recharge when not frozen
+ pauseEnergy = Math.min(pauseEnergyMax, pauseEnergy + 0.1);
+ updatePauseEnergyBar();
+ }
+ // Update game objects
+ player.update();
+ for (var i = 0; i < obstacles.length; i++) {
+ obstacles[i].update();
+ }
+ for (var i = 0; i < enemies.length; i++) {
+ enemies[i].update();
+ }
+ for (var i = 0; i < collectibles.length; i++) {
+ collectibles[i].update();
+ }
+ if (levelEnd) {
+ levelEnd.update();
+ }
+ // Check for collisions
+ checkCollisions();
+};
\ No newline at end of file
Modern App Store icon, high definition, square with rounded corners, for a game titled "Time Freeze" and with the description "A puzzle-action game where pausing is a superpower. Strategically freeze time to navigate hazards, avoid enemies, and collect items while managing your limited pause energy. Plan your moves carefully in this time-bending adventure where stopping the clock is your greatest tool for success.". No text on icon!
Monster 2d
A big red flag with the word end on it. In-Game asset. 2d. High contrast. No shadows
2d electronic visible coin. In-Game asset. 2d. High contrast. No shadows
2d dangerous robot bomb. In-Game asset. 2d. High contrast. No shadows
2d beam bullet. In-Game asset. 2d. High contrast. No shadows
2d shield magic. In-Game asset. 2d. High contrast. No shadows