User prompt
Now add grilled sausages
User prompt
You can't swipe after you visit a Biedronka
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 BiedronkaShop = Container.expand(function () {
var self = Container.call(this);
var shopGraphics = self.attachAsset('biedronka', {
anchorX: 0,
anchorY: 0
});
return self;
});
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;
});
var SovietGuard = Container.expand(function () {
var self = Container.call(this);
var guardGraphics = self.attachAsset('guard', {
anchorX: 0.5,
anchorY: 0.5
});
self.centerX = 0;
self.centerY = 0;
self.radius = 60;
self.angle = 0;
self.speed = 0.05;
self.startCircularMovement = function () {
self.angle = 0;
self.circularTween();
};
self.circularTween = function () {
tween(self, {
angle: self.angle + Math.PI * 2
}, {
duration: 4000,
easing: tween.linear,
onFinish: function onFinish() {
self.circularTween();
}
});
};
self.update = function () {
self.x = self.centerX + Math.cos(self.angle) * self.radius;
self.y = self.centerY + Math.sin(self.angle) * self.radius;
};
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 guards = [];
var biedronkas = [];
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 createGuards() {
guards = [];
var guardCount = Math.min(2 + Math.floor(currentLevel / 2), 6);
for (var i = 0; i < guardCount; 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 guard = new SovietGuard();
guard.centerX = gridX * GRID_SIZE + GRID_SIZE / 2;
guard.centerY = gridY * GRID_SIZE + GRID_SIZE / 2;
guard.x = guard.centerX;
guard.y = guard.centerY;
game.addChild(guard);
guards.push(guard);
guard.startCircularMovement();
}
}
}
function showGroceryStorePopup() {
// Pause game activity
var wasGameActive = isGameActive;
isGameActive = false;
// Create popup background
var popupBg = LK.getAsset('road', {
scaleX: 12,
scaleY: 8,
x: 1024,
y: 1366,
anchorX: 0.5,
anchorY: 0.5
});
popupBg.alpha = 0.9;
game.addChild(popupBg);
// Create popup title
var popupTitle = new Text2('Biedronka Grocery Store', {
size: 80,
fill: 0xFFFFFF
});
popupTitle.anchor.set(0.5, 0.5);
popupTitle.x = 1024;
popupTitle.y = 1100;
game.addChild(popupTitle);
// Create popup text
var popupText = new Text2('Welcome to Biedronka!\n\nYou found some supplies:\n+50 Points\n\nTap to continue', {
size: 60,
fill: 0xFFFFFF
});
popupText.anchor.set(0.5, 0.5);
popupText.x = 1024;
popupText.y = 1366;
game.addChild(popupText);
// Create close function
var _closePopup = function closePopup() {
popupBg.destroy();
popupTitle.destroy();
popupText.destroy();
isGameActive = wasGameActive;
game.off('down', _closePopup);
};
// Add close handler
game.on('down', _closePopup);
}
function createBiedronkas() {
biedronkas = [];
var biedronkaCount = Math.min(1 + Math.floor(currentLevel / 3), 4);
for (var i = 0; i < biedronkaCount; i++) {
var attempts = 0;
var gridX, gridY;
do {
gridX = Math.floor(Math.random() * (GRID_WIDTH - 2)) + 1;
gridY = Math.floor(Math.random() * (GRID_HEIGHT - 2)) + 1;
attempts++;
} while (cityGrid[gridX][gridY] !== 'road' && attempts < 50);
if (attempts < 50) {
var biedronka = new BiedronkaShop();
biedronka.x = gridX * GRID_SIZE;
biedronka.y = gridY * GRID_SIZE;
game.addChild(biedronka);
biedronkas.push(biedronka);
cityGrid[gridX][gridY] = 'biedronka';
if (gridX + 1 < GRID_WIDTH) cityGrid[gridX + 1][gridY] = 'biedronka';
}
}
}
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' || cellType === 'biedronka';
}
function checkWin() {
// Check collision with guards
for (var i = 0; i < guards.length; i++) {
if (player.intersects(guards[i])) {
LK.getSound('blocked').play();
LK.effects.flashScreen(0xff0000, 500);
isGameActive = false;
LK.showGameOver();
return;
}
}
// Check interaction with Biedronka shops
for (var i = 0; i < biedronkas.length; i++) {
if (player.intersects(biedronkas[i])) {
// Show grocery store popup
showGroceryStorePopup();
// Give bonus points for visiting Biedronka
LK.setScore(LK.getScore() + 50);
scoreTxt.setText('Score: ' + LK.getScore());
// Flash green to show successful interaction
LK.effects.flashScreen(0x00ff00, 300);
// Remove the visited Biedronka
biedronkas[i].destroy();
biedronkas.splice(i, 1);
break;
}
}
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();
}
for (var i = guards.length - 1; i >= 0; i--) {
guards[i].destroy();
}
for (var i = biedronkas.length - 1; i >= 0; i--) {
biedronkas[i].destroy();
}
if (destination) destination.destroy();
if (player) player.destroy();
buildings = [];
obstacles = [];
guards = [];
biedronkas = [];
initializeGrid();
createBuildings();
createObstacles();
createGuards();
createBiedronkas();
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
@@ -243,8 +243,52 @@
guard.startCircularMovement();
}
}
}
+function showGroceryStorePopup() {
+ // Pause game activity
+ var wasGameActive = isGameActive;
+ isGameActive = false;
+ // Create popup background
+ var popupBg = LK.getAsset('road', {
+ scaleX: 12,
+ scaleY: 8,
+ x: 1024,
+ y: 1366,
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ popupBg.alpha = 0.9;
+ game.addChild(popupBg);
+ // Create popup title
+ var popupTitle = new Text2('Biedronka Grocery Store', {
+ size: 80,
+ fill: 0xFFFFFF
+ });
+ popupTitle.anchor.set(0.5, 0.5);
+ popupTitle.x = 1024;
+ popupTitle.y = 1100;
+ game.addChild(popupTitle);
+ // Create popup text
+ var popupText = new Text2('Welcome to Biedronka!\n\nYou found some supplies:\n+50 Points\n\nTap to continue', {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ popupText.anchor.set(0.5, 0.5);
+ popupText.x = 1024;
+ popupText.y = 1366;
+ game.addChild(popupText);
+ // Create close function
+ var _closePopup = function closePopup() {
+ popupBg.destroy();
+ popupTitle.destroy();
+ popupText.destroy();
+ isGameActive = wasGameActive;
+ game.off('down', _closePopup);
+ };
+ // Add close handler
+ game.on('down', _closePopup);
+}
function createBiedronkas() {
biedronkas = [];
var biedronkaCount = Math.min(1 + Math.floor(currentLevel / 3), 4);
for (var i = 0; i < biedronkaCount; i++) {
@@ -318,8 +362,10 @@
}
// Check interaction with Biedronka shops
for (var i = 0; i < biedronkas.length; i++) {
if (player.intersects(biedronkas[i])) {
+ // Show grocery store popup
+ showGroceryStorePopup();
// Give bonus points for visiting Biedronka
LK.setScore(LK.getScore() + 50);
scoreTxt.setText('Score: ' + LK.getScore());
// Flash green to show successful interaction