User prompt
I meant actual cities
User prompt
Now make each level name a increasingly populous city
User prompt
No, by popup i meant Store where you buy groceries. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Make a grocery store popup start when biedronka activates
User prompt
Make Biedronkas interactable
User prompt
Add the Biedronka grocery shop
User prompt
Make a different asset for them
User prompt
Add Soviet guards who are the same size as obstacles but oscillate cirularly ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Eastern European City Navigator
Initial prompt
Make a game where you have to navigate Eastern Europe, though cities, blocks and res
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Building = Container.expand(function () { var self = Container.call(this); var buildingGraphics = self.attachAsset('building', { anchorX: 0, anchorY: 0 }); return self; }); var Destination = Container.expand(function () { var self = Container.call(this); var destinationGraphics = self.attachAsset('destination', { anchorX: 0.5, anchorY: 0.5 }); self.pulse = function () { tween(self, { scaleX: 1.2, scaleY: 1.2 }, { duration: 500, easing: tween.easeInOut, onFinish: function onFinish() { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 500, easing: tween.easeInOut, onFinish: function onFinish() { self.pulse(); } }); } }); }; return self; }); var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.gridX = 0; self.gridY = 0; self.isMoving = false; self.moveToGrid = function (newGridX, newGridY) { if (self.isMoving) return false; var targetX = newGridX * GRID_SIZE + GRID_SIZE / 2; var targetY = newGridY * GRID_SIZE + GRID_SIZE / 2; self.isMoving = true; self.gridX = newGridX; self.gridY = newGridY; tween(self, { x: targetX, y: targetY }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { self.isMoving = false; LK.getSound('move').play(); } }); return true; }; return self; }); var Road = Container.expand(function () { var self = Container.call(this); var roadGraphics = self.attachAsset('road', { anchorX: 0, anchorY: 0 }); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x263238 }); /**** * Game Code ****/ var GRID_SIZE = 120; var GRID_WIDTH = 17; var GRID_HEIGHT = 22; var currentLevel = 1; var timeLeft = 60; var isGameActive = true; var gameStarted = false; var cityGrid = []; var player; var destination; var obstacles = []; var buildings = []; var scoreTxt = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var timeTxt = new Text2('Time: 60', { size: 60, fill: 0xFFFFFF }); timeTxt.anchor.set(0.5, 0); timeTxt.y = 80; LK.gui.top.addChild(timeTxt); var levelTxt = new Text2('Level: 1', { size: 50, fill: 0xFFFFFF }); levelTxt.anchor.set(1, 0); LK.gui.topRight.addChild(levelTxt); levelTxt.x = -20; levelTxt.y = 20; function initializeGrid() { cityGrid = []; for (var x = 0; x < GRID_WIDTH; x++) { cityGrid[x] = []; for (var y = 0; y < GRID_HEIGHT; y++) { cityGrid[x][y] = 'road'; } } } function createBuildings() { buildings = []; var buildingCount = Math.min(8 + currentLevel * 2, 20); for (var i = 0; i < buildingCount; i++) { var building = new Building(); var gridX = Math.floor(Math.random() * (GRID_WIDTH - 2)) + 1; var gridY = Math.floor(Math.random() * (GRID_HEIGHT - 2)) + 1; building.x = gridX * GRID_SIZE; building.y = gridY * GRID_SIZE; game.addChild(building); buildings.push(building); cityGrid[gridX][gridY] = 'building'; if (gridX + 1 < GRID_WIDTH) cityGrid[gridX + 1][gridY] = 'building'; } } function createObstacles() { obstacles = []; var obstacleCount = Math.min(3 + currentLevel, 12); for (var i = 0; i < obstacleCount; i++) { var attempts = 0; var gridX, gridY; do { gridX = Math.floor(Math.random() * GRID_WIDTH); gridY = Math.floor(Math.random() * GRID_HEIGHT); attempts++; } while (cityGrid[gridX][gridY] !== 'road' && attempts < 50); if (attempts < 50) { var obstacle = new Obstacle(); obstacle.x = gridX * GRID_SIZE + GRID_SIZE / 2; obstacle.y = gridY * GRID_SIZE + GRID_SIZE / 2; game.addChild(obstacle); obstacles.push(obstacle); cityGrid[gridX][gridY] = 'obstacle'; } } } function createDestination() { var attempts = 0; var gridX, gridY; do { gridX = Math.floor(Math.random() * GRID_WIDTH); gridY = Math.floor(Math.random() * GRID_HEIGHT); attempts++; } while (cityGrid[gridX][gridY] !== 'road' && attempts < 100); destination = new Destination(); destination.x = gridX * GRID_SIZE + GRID_SIZE / 2; destination.y = gridY * GRID_SIZE + GRID_SIZE / 2; destination.gridX = gridX; destination.gridY = gridY; game.addChild(destination); destination.pulse(); cityGrid[gridX][gridY] = 'destination'; } function createPlayer() { var attempts = 0; var gridX, gridY; do { gridX = Math.floor(Math.random() * GRID_WIDTH); gridY = Math.floor(Math.random() * GRID_HEIGHT); attempts++; } while (cityGrid[gridX][gridY] !== 'road' && attempts < 100); player = new Player(); player.gridX = gridX; player.gridY = gridY; player.x = gridX * GRID_SIZE + GRID_SIZE / 2; player.y = gridY * GRID_SIZE + GRID_SIZE / 2; game.addChild(player); } function isValidMove(gridX, gridY) { if (gridX < 0 || gridX >= GRID_WIDTH || gridY < 0 || gridY >= GRID_HEIGHT) { return false; } var cellType = cityGrid[gridX][gridY]; return cellType === 'road' || cellType === 'destination'; } function checkWin() { if (player.gridX === destination.gridX && player.gridY === destination.gridY) { var timeBonus = Math.floor(timeLeft * 10); var levelBonus = currentLevel * 100; LK.setScore(LK.getScore() + timeBonus + levelBonus); LK.getSound('complete').play(); LK.effects.flashScreen(0x4CAF50, 500); currentLevel++; if (currentLevel > 10) { LK.showYouWin(); } else { initializeLevel(); } } } function initializeLevel() { for (var i = buildings.length - 1; i >= 0; i--) { buildings[i].destroy(); } for (var i = obstacles.length - 1; i >= 0; i--) { obstacles[i].destroy(); } if (destination) destination.destroy(); if (player) player.destroy(); buildings = []; obstacles = []; initializeGrid(); createBuildings(); createObstacles(); createDestination(); createPlayer(); timeLeft = Math.max(30, 80 - currentLevel * 3); levelTxt.setText('Level: ' + currentLevel); scoreTxt.setText('Score: ' + LK.getScore()); timeTxt.setText('Time: ' + timeLeft); } function handleMovement(deltaX, deltaY) { if (!isGameActive || !gameStarted || player.isMoving) return; var newGridX = player.gridX + deltaX; var newGridY = player.gridY + deltaY; if (isValidMove(newGridX, newGridY)) { if (player.moveToGrid(newGridX, newGridY)) { checkWin(); } } else { LK.getSound('blocked').play(); } } var lastTouchX = 0; var lastTouchY = 0; var minSwipeDistance = 50; game.down = function (x, y, obj) { if (!gameStarted) { gameStarted = true; initializeLevel(); } lastTouchX = x; lastTouchY = y; }; game.up = function (x, y, obj) { if (!gameStarted || !isGameActive) return; var deltaX = x - lastTouchX; var deltaY = y - lastTouchY; if (Math.abs(deltaX) > minSwipeDistance || Math.abs(deltaY) > minSwipeDistance) { if (Math.abs(deltaX) > Math.abs(deltaY)) { handleMovement(deltaX > 0 ? 1 : -1, 0); } else { handleMovement(0, deltaY > 0 ? 1 : -1); } } }; var gameTimer = null; game.update = function () { if (!gameStarted || !isGameActive) return; if (LK.ticks % 60 === 0 && timeLeft > 0) { timeLeft--; timeTxt.setText('Time: ' + timeLeft); if (timeLeft <= 0) { isGameActive = false; LK.showGameOver(); } } }; var instructionTxt = new Text2('Swipe to navigate through the city\nReach the golden destination!\nTap to start', { size: 50, fill: 0xFFFFFF }); instructionTxt.anchor.set(0.5, 0.5); instructionTxt.x = 1024; instructionTxt.y = 1366; game.addChild(instructionTxt);
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,311 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Building = Container.expand(function () {
+ var self = Container.call(this);
+ var buildingGraphics = self.attachAsset('building', {
+ anchorX: 0,
+ anchorY: 0
+ });
+ return self;
+});
+var Destination = Container.expand(function () {
+ var self = Container.call(this);
+ var destinationGraphics = self.attachAsset('destination', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.pulse = function () {
+ tween(self, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 500,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 500,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ self.pulse();
+ }
+ });
+ }
+ });
+ };
+ return self;
+});
+var Obstacle = Container.expand(function () {
+ var self = Container.call(this);
+ var obstacleGraphics = self.attachAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ return self;
+});
+var Player = Container.expand(function () {
+ var self = Container.call(this);
+ var playerGraphics = self.attachAsset('player', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.gridX = 0;
+ self.gridY = 0;
+ self.isMoving = false;
+ self.moveToGrid = function (newGridX, newGridY) {
+ if (self.isMoving) return false;
+ var targetX = newGridX * GRID_SIZE + GRID_SIZE / 2;
+ var targetY = newGridY * GRID_SIZE + GRID_SIZE / 2;
+ self.isMoving = true;
+ self.gridX = newGridX;
+ self.gridY = newGridY;
+ tween(self, {
+ x: targetX,
+ y: targetY
+ }, {
+ duration: 200,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ self.isMoving = false;
+ LK.getSound('move').play();
+ }
+ });
+ return true;
+ };
+ return self;
+});
+var Road = Container.expand(function () {
+ var self = Container.call(this);
+ var roadGraphics = self.attachAsset('road', {
+ anchorX: 0,
+ anchorY: 0
+ });
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x263238
+});
+
+/****
+* Game Code
+****/
+var GRID_SIZE = 120;
+var GRID_WIDTH = 17;
+var GRID_HEIGHT = 22;
+var currentLevel = 1;
+var timeLeft = 60;
+var isGameActive = true;
+var gameStarted = false;
+var cityGrid = [];
+var player;
+var destination;
+var obstacles = [];
+var buildings = [];
+var scoreTxt = new Text2('Score: 0', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+var timeTxt = new Text2('Time: 60', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+timeTxt.anchor.set(0.5, 0);
+timeTxt.y = 80;
+LK.gui.top.addChild(timeTxt);
+var levelTxt = new Text2('Level: 1', {
+ size: 50,
+ fill: 0xFFFFFF
+});
+levelTxt.anchor.set(1, 0);
+LK.gui.topRight.addChild(levelTxt);
+levelTxt.x = -20;
+levelTxt.y = 20;
+function initializeGrid() {
+ cityGrid = [];
+ for (var x = 0; x < GRID_WIDTH; x++) {
+ cityGrid[x] = [];
+ for (var y = 0; y < GRID_HEIGHT; y++) {
+ cityGrid[x][y] = 'road';
+ }
+ }
+}
+function createBuildings() {
+ buildings = [];
+ var buildingCount = Math.min(8 + currentLevel * 2, 20);
+ for (var i = 0; i < buildingCount; i++) {
+ var building = new Building();
+ var gridX = Math.floor(Math.random() * (GRID_WIDTH - 2)) + 1;
+ var gridY = Math.floor(Math.random() * (GRID_HEIGHT - 2)) + 1;
+ building.x = gridX * GRID_SIZE;
+ building.y = gridY * GRID_SIZE;
+ game.addChild(building);
+ buildings.push(building);
+ cityGrid[gridX][gridY] = 'building';
+ if (gridX + 1 < GRID_WIDTH) cityGrid[gridX + 1][gridY] = 'building';
+ }
+}
+function createObstacles() {
+ obstacles = [];
+ var obstacleCount = Math.min(3 + currentLevel, 12);
+ for (var i = 0; i < obstacleCount; i++) {
+ var attempts = 0;
+ var gridX, gridY;
+ do {
+ gridX = Math.floor(Math.random() * GRID_WIDTH);
+ gridY = Math.floor(Math.random() * GRID_HEIGHT);
+ attempts++;
+ } while (cityGrid[gridX][gridY] !== 'road' && attempts < 50);
+ if (attempts < 50) {
+ var obstacle = new Obstacle();
+ obstacle.x = gridX * GRID_SIZE + GRID_SIZE / 2;
+ obstacle.y = gridY * GRID_SIZE + GRID_SIZE / 2;
+ game.addChild(obstacle);
+ obstacles.push(obstacle);
+ cityGrid[gridX][gridY] = 'obstacle';
+ }
+ }
+}
+function createDestination() {
+ var attempts = 0;
+ var gridX, gridY;
+ do {
+ gridX = Math.floor(Math.random() * GRID_WIDTH);
+ gridY = Math.floor(Math.random() * GRID_HEIGHT);
+ attempts++;
+ } while (cityGrid[gridX][gridY] !== 'road' && attempts < 100);
+ destination = new Destination();
+ destination.x = gridX * GRID_SIZE + GRID_SIZE / 2;
+ destination.y = gridY * GRID_SIZE + GRID_SIZE / 2;
+ destination.gridX = gridX;
+ destination.gridY = gridY;
+ game.addChild(destination);
+ destination.pulse();
+ cityGrid[gridX][gridY] = 'destination';
+}
+function createPlayer() {
+ var attempts = 0;
+ var gridX, gridY;
+ do {
+ gridX = Math.floor(Math.random() * GRID_WIDTH);
+ gridY = Math.floor(Math.random() * GRID_HEIGHT);
+ attempts++;
+ } while (cityGrid[gridX][gridY] !== 'road' && attempts < 100);
+ player = new Player();
+ player.gridX = gridX;
+ player.gridY = gridY;
+ player.x = gridX * GRID_SIZE + GRID_SIZE / 2;
+ player.y = gridY * GRID_SIZE + GRID_SIZE / 2;
+ game.addChild(player);
+}
+function isValidMove(gridX, gridY) {
+ if (gridX < 0 || gridX >= GRID_WIDTH || gridY < 0 || gridY >= GRID_HEIGHT) {
+ return false;
+ }
+ var cellType = cityGrid[gridX][gridY];
+ return cellType === 'road' || cellType === 'destination';
+}
+function checkWin() {
+ if (player.gridX === destination.gridX && player.gridY === destination.gridY) {
+ var timeBonus = Math.floor(timeLeft * 10);
+ var levelBonus = currentLevel * 100;
+ LK.setScore(LK.getScore() + timeBonus + levelBonus);
+ LK.getSound('complete').play();
+ LK.effects.flashScreen(0x4CAF50, 500);
+ currentLevel++;
+ if (currentLevel > 10) {
+ LK.showYouWin();
+ } else {
+ initializeLevel();
+ }
+ }
+}
+function initializeLevel() {
+ for (var i = buildings.length - 1; i >= 0; i--) {
+ buildings[i].destroy();
+ }
+ for (var i = obstacles.length - 1; i >= 0; i--) {
+ obstacles[i].destroy();
+ }
+ if (destination) destination.destroy();
+ if (player) player.destroy();
+ buildings = [];
+ obstacles = [];
+ initializeGrid();
+ createBuildings();
+ createObstacles();
+ createDestination();
+ createPlayer();
+ timeLeft = Math.max(30, 80 - currentLevel * 3);
+ levelTxt.setText('Level: ' + currentLevel);
+ scoreTxt.setText('Score: ' + LK.getScore());
+ timeTxt.setText('Time: ' + timeLeft);
+}
+function handleMovement(deltaX, deltaY) {
+ if (!isGameActive || !gameStarted || player.isMoving) return;
+ var newGridX = player.gridX + deltaX;
+ var newGridY = player.gridY + deltaY;
+ if (isValidMove(newGridX, newGridY)) {
+ if (player.moveToGrid(newGridX, newGridY)) {
+ checkWin();
+ }
+ } else {
+ LK.getSound('blocked').play();
+ }
+}
+var lastTouchX = 0;
+var lastTouchY = 0;
+var minSwipeDistance = 50;
+game.down = function (x, y, obj) {
+ if (!gameStarted) {
+ gameStarted = true;
+ initializeLevel();
+ }
+ lastTouchX = x;
+ lastTouchY = y;
+};
+game.up = function (x, y, obj) {
+ if (!gameStarted || !isGameActive) return;
+ var deltaX = x - lastTouchX;
+ var deltaY = y - lastTouchY;
+ if (Math.abs(deltaX) > minSwipeDistance || Math.abs(deltaY) > minSwipeDistance) {
+ if (Math.abs(deltaX) > Math.abs(deltaY)) {
+ handleMovement(deltaX > 0 ? 1 : -1, 0);
+ } else {
+ handleMovement(0, deltaY > 0 ? 1 : -1);
+ }
+ }
+};
+var gameTimer = null;
+game.update = function () {
+ if (!gameStarted || !isGameActive) return;
+ if (LK.ticks % 60 === 0 && timeLeft > 0) {
+ timeLeft--;
+ timeTxt.setText('Time: ' + timeLeft);
+ if (timeLeft <= 0) {
+ isGameActive = false;
+ LK.showGameOver();
+ }
+ }
+};
+var instructionTxt = new Text2('Swipe to navigate through the city\nReach the golden destination!\nTap to start', {
+ size: 50,
+ fill: 0xFFFFFF
+});
+instructionTxt.anchor.set(0.5, 0.5);
+instructionTxt.x = 1024;
+instructionTxt.y = 1366;
+game.addChild(instructionTxt);
\ No newline at end of file