User prompt
I can't buy travel to Czechoslovakia
User prompt
Add a different asset for Zabka
User prompt
If you're in Czechoslovakia or Romania, the Biedronka shoule change into a Zabka
User prompt
I can't click countries without my character moving down
User prompt
No, add a seperste button and not added to Biedronka
User prompt
Add a button where you can travel to different Eastern Bloc countries.
User prompt
Biedronkas should only spawn in WW3 and modern day but in incredible numerosities
User prompt
Change the names into POLISH time moments.
User prompt
Now the swiping is awkward
User prompt
I meant as a button, not as a first popup
User prompt
I meant the players choose the place in Poland's history themselves
User prompt
Now add historical periods to travel to (
User prompt
You did not help, you just made the text darker
User prompt
It's hard to click
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.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 GroceryStore = Container.expand(function () {
var self = Container.call(this);
self.items = [{
name: 'Bread',
price: 10,
health: 5
}, {
name: 'Milk',
price: 15,
health: 8
}, {
name: 'Apples',
price: 12,
health: 6
}, {
name: 'Cheese',
price: 20,
health: 10
}, {
name: 'Water',
price: 5,
health: 3
}, {
name: 'Grilled Sausages',
price: 30,
health: 15
}];
self.show = function () {
// Create store background
var storeBg = LK.getAsset('road', {
scaleX: 15,
scaleY: 18,
x: 1024,
y: 1366,
anchorX: 0.5,
anchorY: 0.5
});
storeBg.alpha = 0.95;
game.addChild(storeBg);
// Store title
var storeTitle = new Text2('Biedronka Grocery Store', {
size: 70,
fill: 0x00ff00
});
storeTitle.anchor.set(0.5, 0);
storeTitle.x = 1024;
storeTitle.y = 800;
game.addChild(storeTitle);
// Player stats
var playerCoins = storage.coins || 0;
var playerHealth = storage.health || 100;
var statsText = new Text2('Coins: ' + playerCoins + ' | Health: ' + playerHealth, {
size: 50,
fill: 0xffffff
});
statsText.anchor.set(0.5, 0);
statsText.x = 1024;
statsText.y = 900;
game.addChild(statsText);
// Items display
var itemsContainer = new Container();
itemsContainer.x = 1024;
itemsContainer.y = 1100;
game.addChild(itemsContainer);
for (var i = 0; i < self.items.length; i++) {
var item = self.items[i];
var itemBg = LK.getAsset('road', {
scaleX: 12,
scaleY: 2.5,
x: 0,
y: i * 140,
anchorX: 0.5,
anchorY: 0.5
});
itemBg.alpha = 0.7;
itemsContainer.addChild(itemBg);
var itemText = new Text2(item.name + ' - ' + item.price + ' coins (+' + item.health + ' health)', {
size: 45,
fill: playerCoins >= item.price ? 0x00ffaa : 0xff4444
});
itemText.anchor.set(0.5, 0.5);
itemText.x = 0;
itemText.y = i * 140;
itemsContainer.addChild(itemText);
// Store item data for click detection
itemBg.itemData = item;
itemBg.itemIndex = i;
}
// Close button
var closeButton = LK.getAsset('road', {
scaleX: 8,
scaleY: 2.5,
x: 1024,
y: 1900,
anchorX: 0.5,
anchorY: 0.5
});
closeButton.alpha = 0.8;
game.addChild(closeButton);
var closeText = new Text2('Close Shop', {
size: 50,
fill: 0xffffff
});
closeText.anchor.set(0.5, 0.5);
closeText.x = 1024;
closeText.y = 1900;
game.addChild(closeText);
// Store references for cleanup
self.storeElements = [storeBg, storeTitle, statsText, itemsContainer, closeButton, closeText];
// Handle purchases
var handlePurchase = function handlePurchase(x, y, obj) {
// Check if clicking on items
var localPos = itemsContainer.toLocal({
x: x,
y: y
});
var itemIndex = Math.floor((localPos.y + 70) / 140);
if (itemIndex >= 0 && itemIndex < self.items.length) {
var item = self.items[itemIndex];
var currentCoins = storage.coins || 0;
if (currentCoins >= item.price) {
// Purchase item
storage.coins = currentCoins - item.price;
storage.health = Math.min(100, (storage.health || 100) + item.health);
// Update score
LK.setScore(LK.getScore() + item.health * 2);
scoreTxt.setText('Score: ' + LK.getScore());
// Flash green for successful purchase
LK.effects.flashScreen(0x00ff00, 300);
// Close and reopen to refresh display
self.close();
LK.setTimeout(function () {
self.show();
}, 100);
} else {
// Not enough coins
LK.effects.flashScreen(0xff0000, 300);
}
return;
}
// Check if clicking close button
if (Math.abs(x - 1024) < 480 && Math.abs(y - 1900) < 150) {
self.close();
}
};
game.down = handlePurchase;
};
self.close = function () {
if (self.storeElements) {
for (var i = 0; i < self.storeElements.length; i++) {
self.storeElements[i].destroy();
}
self.storeElements = null;
}
// Restore game activity and normal game controls
isGameActive = true;
game.down = function (x, y, obj) {
// Check if clicking period selection button
if (x >= 20 && x <= 20 + 200 && y >= 150 && y <= 200) {
showPeriodSelection();
return;
}
if (!gameStarted) {
gameStarted = true;
initializeLevel();
}
lastTouchX = x;
lastTouchY = y;
};
game.up = function (x, y, obj) {
if (!gameStarted || !isGameActive) return;
// Calculate player center position on screen
var playerCenterX = player.x;
var playerCenterY = player.y;
// Calculate direction from player to tap position
var deltaX = x - playerCenterX;
var deltaY = y - playerCenterY;
// Only move if tap is far enough from player center
if (Math.abs(deltaX) > 30 || Math.abs(deltaY) > 30) {
if (Math.abs(deltaX) > Math.abs(deltaY)) {
handleMovement(deltaX > 0 ? 1 : -1, 0);
} else {
handleMovement(0, deltaY > 0 ? 1 : -1);
}
}
};
};
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 historicalPeriods = ['Stone Age', 'Bronze Age', 'Iron Age', 'Roman Era', 'Medieval', 'Renaissance', 'Industrial Age', 'Modern Era', 'Space Age', 'Future'];
// Initialize storage with defaults
if (storage.coins === undefined) storage.coins = 50;
if (storage.health === undefined) storage.health = 100;
var groceryStore = new GroceryStore();
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('Stone Age', {
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
isGameActive = false;
// Show the grocery store
groceryStore.show();
}
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])) {
// Add coins for visiting Biedronka
storage.coins = (storage.coins || 0) + 25;
// Show grocery store
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);
var historicalPeriod = historicalPeriods[Math.min(currentLevel - 1, historicalPeriods.length - 1)];
levelTxt.setText(historicalPeriod);
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 = 20;
game.down = function (x, y, obj) {
// Check if clicking period selection button
if (x >= 20 && x <= 20 + 200 && y >= 150 && y <= 200) {
showPeriodSelection();
return;
}
if (!gameStarted) {
gameStarted = true;
initializeLevel();
}
lastTouchX = x;
lastTouchY = y;
};
game.up = function (x, y, obj) {
if (!gameStarted || !isGameActive) return;
// Calculate player center position on screen
var playerCenterX = player.x;
var playerCenterY = player.y;
// Calculate direction from player to tap position
var deltaX = x - playerCenterX;
var deltaY = y - playerCenterY;
// Only move if tap is far enough from player center
if (Math.abs(deltaX) > 30 || Math.abs(deltaY) > 30) {
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 isPeriodSelectionActive = false;
var periodSelectionElements = [];
function showPeriodSelection() {
isPeriodSelectionActive = true;
// Create background
var selectionBg = LK.getAsset('road', {
scaleX: 15,
scaleY: 20,
x: 1024,
y: 1366,
anchorX: 0.5,
anchorY: 0.5
});
selectionBg.alpha = 0.95;
game.addChild(selectionBg);
// Title
var titleText = new Text2('Choose Your Historical Period', {
size: 70,
fill: 0xffd700
});
titleText.anchor.set(0.5, 0);
titleText.x = 1024;
titleText.y = 400;
game.addChild(titleText);
// Create period buttons
var periodsContainer = new Container();
periodsContainer.x = 1024;
periodsContainer.y = 800;
game.addChild(periodsContainer);
for (var i = 0; i < historicalPeriods.length; i++) {
var period = historicalPeriods[i];
var row = Math.floor(i / 2);
var col = i % 2;
var buttonBg = LK.getAsset('road', {
scaleX: 8,
scaleY: 2,
x: (col - 0.5) * 600,
y: row * 120,
anchorX: 0.5,
anchorY: 0.5
});
buttonBg.alpha = 0.8;
buttonBg.periodIndex = i;
periodsContainer.addChild(buttonBg);
var buttonText = new Text2(period, {
size: 45,
fill: 0xffffff
});
buttonText.anchor.set(0.5, 0.5);
buttonText.x = (col - 0.5) * 600;
buttonText.y = row * 120;
periodsContainer.addChild(buttonText);
}
// Store elements for cleanup
periodSelectionElements = [selectionBg, titleText, periodsContainer];
// Handle period selection
game.down = function (x, y, obj) {
if (!isPeriodSelectionActive) return;
var localPos = periodsContainer.toLocal({
x: x,
y: y
});
var col = Math.round((localPos.x + 300) / 600);
var row = Math.round(localPos.y / 120);
var periodIndex = row * 2 + col;
if (periodIndex >= 0 && periodIndex < historicalPeriods.length) {
// Set selected period as target
currentLevel = periodIndex + 1;
closePeriodSelection();
startGame();
}
};
}
function closePeriodSelection() {
isPeriodSelectionActive = false;
if (periodSelectionElements) {
for (var i = 0; i < periodSelectionElements.length; i++) {
periodSelectionElements[i].destroy();
}
periodSelectionElements = [];
}
}
function startGame() {
gameStarted = true;
initializeLevel();
// Restore normal game controls
game.down = function (x, y, obj) {
// Check if clicking period selection button
if (x >= 20 && x <= 20 + 200 && y >= 150 && y <= 200) {
showPeriodSelection();
return;
}
if (!gameStarted) {
gameStarted = true;
initializeLevel();
}
lastTouchX = x;
lastTouchY = y;
};
game.up = function (x, y, obj) {
if (!gameStarted || !isGameActive) return;
// Calculate player center position on screen
var playerCenterX = player.x;
var playerCenterY = player.y;
// Calculate direction from player to tap position
var deltaX = x - playerCenterX;
var deltaY = y - playerCenterY;
// Only move if tap is far enough from player center
if (Math.abs(deltaX) > 30 || Math.abs(deltaY) > 30) {
if (Math.abs(deltaX) > Math.abs(deltaY)) {
handleMovement(deltaX > 0 ? 1 : -1, 0);
} else {
handleMovement(0, deltaY > 0 ? 1 : -1);
}
}
};
}
var instructionTxt = new Text2('Swipe to move through time\nTap to begin', {
size: 50,
fill: 0xFFFFFF
});
instructionTxt.anchor.set(0.5, 0.5);
instructionTxt.x = 1024;
instructionTxt.y = 1366;
game.addChild(instructionTxt);
// Create period selection button
var periodButton = new Text2('Choose Period', {
size: 45,
fill: 0xffd700
});
periodButton.anchor.set(0, 0);
periodButton.x = 20;
periodButton.y = 150;
LK.gui.topLeft.addChild(periodButton);
// Initial game setup
game.down = function (x, y, obj) {
if (!gameStarted && !isPeriodSelectionActive) {
instructionTxt.destroy();
gameStarted = true;
initializeLevel();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -222,11 +222,16 @@
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) {
+ // Calculate player center position on screen
+ var playerCenterX = player.x;
+ var playerCenterY = player.y;
+ // Calculate direction from player to tap position
+ var deltaX = x - playerCenterX;
+ var deltaY = y - playerCenterY;
+ // Only move if tap is far enough from player center
+ if (Math.abs(deltaX) > 30 || Math.abs(deltaY) > 30) {
if (Math.abs(deltaX) > Math.abs(deltaY)) {
handleMovement(deltaX > 0 ? 1 : -1, 0);
} else {
handleMovement(0, deltaY > 0 ? 1 : -1);
@@ -589,9 +594,9 @@
}
}
var lastTouchX = 0;
var lastTouchY = 0;
-var minSwipeDistance = 50;
+var minSwipeDistance = 20;
game.down = function (x, y, obj) {
// Check if clicking period selection button
if (x >= 20 && x <= 20 + 200 && y >= 150 && y <= 200) {
showPeriodSelection();
@@ -605,11 +610,16 @@
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) {
+ // Calculate player center position on screen
+ var playerCenterX = player.x;
+ var playerCenterY = player.y;
+ // Calculate direction from player to tap position
+ var deltaX = x - playerCenterX;
+ var deltaY = y - playerCenterY;
+ // Only move if tap is far enough from player center
+ if (Math.abs(deltaX) > 30 || Math.abs(deltaY) > 30) {
if (Math.abs(deltaX) > Math.abs(deltaY)) {
handleMovement(deltaX > 0 ? 1 : -1, 0);
} else {
handleMovement(0, deltaY > 0 ? 1 : -1);
@@ -726,8 +736,25 @@
}
lastTouchX = x;
lastTouchY = y;
};
+ game.up = function (x, y, obj) {
+ if (!gameStarted || !isGameActive) return;
+ // Calculate player center position on screen
+ var playerCenterX = player.x;
+ var playerCenterY = player.y;
+ // Calculate direction from player to tap position
+ var deltaX = x - playerCenterX;
+ var deltaY = y - playerCenterY;
+ // Only move if tap is far enough from player center
+ if (Math.abs(deltaX) > 30 || Math.abs(deltaY) > 30) {
+ if (Math.abs(deltaX) > Math.abs(deltaY)) {
+ handleMovement(deltaX > 0 ? 1 : -1, 0);
+ } else {
+ handleMovement(0, deltaY > 0 ? 1 : -1);
+ }
+ }
+ };
}
var instructionTxt = new Text2('Swipe to move through time\nTap to begin', {
size: 50,
fill: 0xFFFFFF