User prompt
Add 2 dead bodies
User prompt
Arka planı Dosyalardaki backgroundGround dosyası ike değiştir
User prompt
Remove timer
User prompt
Bitiş çizgisinin arkası gökyüzü olsun
User prompt
Red Light Yazısınu Kırmızı Yap
User prompt
Doll dont turn around
User prompt
Remove doll head
User prompt
Add 2 dead bodies
User prompt
Arka plan ekle
User prompt
Arka plana ten rengi ekle
User prompt
Arka plana kum ekle
User prompt
Add Realistic sand background
User prompt
Add Backdground a realistic sand
User prompt
Ad 2 deadPersons
User prompt
Remove blood
User prompt
Ölmüş kişilerin altına kan ekle
User prompt
Yere 2 tane ölü kişi ekle
User prompt
Make background sand
User prompt
Bebeğin 2 yanınada 1 asker ekle
User prompt
Add a timer
User prompt
Please fix the bug: 'Timeout.tick error: Cannot set properties of undefined (setting 'fill')' in or related to this line: 'phaseText.style.fill = '#FF0000';' Line Number: 130
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var DeadPerson = Container.expand(function () {
var self = Container.call(this);
var deadPersonGraphics = self.attachAsset('deadPerson', {
anchorX: 0.5,
anchorY: 1.0
});
return self;
});
var Doll = Container.expand(function () {
var self = Container.call(this);
var dollBody = self.attachAsset('dollBody', {
anchorX: 0.5,
anchorY: 1.0
});
var dollHead = self.attachAsset('dollHead', {
anchorX: 0.5,
anchorY: 0.5,
y: -250
});
self.isWatching = false;
self.turnAround = function () {
self.isWatching = !self.isWatching;
var targetRotation = self.isWatching ? Math.PI : 0;
tween(self, {
rotation: targetRotation
}, {
duration: 500,
easing: tween.easeInOut
});
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 1.0
});
self.isMoving = false;
self.moveSpeed = 3;
self.lastPosition = 0;
self.update = function () {
if (self.isMoving && currentPhase === 'green') {
self.y -= self.moveSpeed;
}
};
return self;
});
var Soldier = Container.expand(function () {
var self = Container.call(this);
var soldierGraphics = self.attachAsset('soldier', {
anchorX: 0.5,
anchorY: 1.0
});
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xF4A460
});
/****
* Game Code
****/
// Game state variables
var currentPhase = 'green'; // 'green' or 'red'
var phaseTimer = 0;
var nextPhaseChange = 3000; // Initial green phase duration
var gameStarted = false;
var gameEnded = false;
var isPlayerMoving = false;
var playerLastY = 0;
var phaseStartTime = 0;
var currentPhaseDuration = 3000;
// Create finish line
var finishLine = game.addChild(LK.getAsset('finishLine', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 300
}));
// Create start line
var startLine = game.addChild(LK.getAsset('startLine', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2400
}));
// Create player
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2400;
playerLastY = player.y;
// Create doll
var doll = game.addChild(new Doll());
doll.x = 2048 / 2;
doll.y = 600;
// Create left soldier
var leftSoldier = game.addChild(new Soldier());
leftSoldier.x = 2048 / 2 - 200;
leftSoldier.y = 600;
// Create right soldier
var rightSoldier = game.addChild(new Soldier());
rightSoldier.x = 2048 / 2 + 200;
rightSoldier.y = 600;
// Create first dead person
var deadPerson1 = game.addChild(new DeadPerson());
deadPerson1.x = 2048 / 2 - 400;
deadPerson1.y = 1500;
// Create second dead person
var deadPerson2 = game.addChild(new DeadPerson());
deadPerson2.x = 2048 / 2 + 400;
deadPerson2.y = 1800;
// Create phase indicator text
var phaseText = new Text2('GREEN LIGHT', {
size: 100,
fill: '#00FF00'
});
phaseText.anchor.set(0.5, 0);
LK.gui.top.addChild(phaseText);
// Create instruction text
var instructionText = new Text2('Hold to move, release to stop', {
size: 60,
fill: '#FFFFFF'
});
instructionText.anchor.set(0.5, 1);
LK.gui.bottom.addChild(instructionText);
// Create timer text
var timerText = new Text2('3.0s', {
size: 80,
fill: '#FFFFFF'
});
timerText.anchor.set(0.5, 0);
timerText.y = 150;
LK.gui.top.addChild(timerText);
// Initialize timer tracking
phaseStartTime = LK.ticks;
currentPhaseDuration = nextPhaseChange;
// Timer for random phase changes
var phaseChangeTimer = LK.setInterval(function () {
if (gameEnded) return;
changePhase();
}, nextPhaseChange);
function changePhase() {
if (currentPhase === 'green') {
// Change to red light
currentPhase = 'red';
phaseText.setText('RED LIGHT');
phaseText.fill = '#FF0000';
doll.turnAround();
LK.getSound('redLight').play();
// Red light duration: 1-3 seconds
nextPhaseChange = 1000 + Math.random() * 2000;
} else {
// Change to green light
currentPhase = 'green';
phaseText.setText('GREEN LIGHT');
phaseText.fill = '#00FF00';
doll.turnAround();
LK.getSound('greenLight').play();
// Green light duration: 2-4 seconds, gets shorter over time
var baseDuration = Math.max(1000, 4000 - LK.getScore() * 100);
nextPhaseChange = baseDuration + Math.random() * 2000;
}
// Update timer tracking variables
phaseStartTime = LK.ticks;
currentPhaseDuration = nextPhaseChange;
// Clear old timer and set new one
LK.clearInterval(phaseChangeTimer);
phaseChangeTimer = LK.setInterval(changePhase, nextPhaseChange);
}
function checkMovement() {
var currentY = player.y;
var hasMovedUp = currentY < playerLastY - 2; // Small threshold to account for floating point precision
if (currentPhase === 'red' && hasMovedUp) {
// Player caught moving during red light
eliminatePlayer();
}
playerLastY = currentY;
}
function eliminatePlayer() {
gameEnded = true;
LK.clearInterval(phaseChangeTimer);
LK.effects.flashScreen(0xFF0000, 1000);
LK.getSound('elimination').play();
LK.setTimeout(function () {
LK.showGameOver();
}, 1000);
}
function checkVictory() {
if (player.y <= finishLine.y + 50) {
gameEnded = true;
LK.clearInterval(phaseChangeTimer);
LK.getSound('victory').play();
LK.setScore(100);
LK.setTimeout(function () {
LK.showYouWin();
}, 500);
}
}
// Touch controls
game.down = function (x, y, obj) {
if (gameEnded) return;
player.isMoving = true;
isPlayerMoving = true;
};
game.up = function (x, y, obj) {
if (gameEnded) return;
player.isMoving = false;
isPlayerMoving = false;
};
// Main game loop
game.update = function () {
if (gameEnded) return;
// Check for movement violations
checkMovement();
// Check for victory condition
checkVictory();
// Update timer display
var elapsedTime = (LK.ticks - phaseStartTime) * (1000 / 60); // Convert ticks to milliseconds
var remainingTime = Math.max(0, currentPhaseDuration - elapsedTime);
var remainingSeconds = (remainingTime / 1000).toFixed(1);
timerText.setText(remainingSeconds + 's');
// Update timer color based on phase
if (currentPhase === 'red') {
timerText.fill = '#FF0000';
} else {
timerText.fill = '#00FF00';
}
// Update score based on progress
var progress = Math.max(0, startLine.y - player.y);
var maxProgress = startLine.y - finishLine.y;
var scoreProgress = Math.floor(progress / maxProgress * 50);
LK.setScore(scoreProgress);
}; ===================================================================
--- original.js
+++ change.js
@@ -5,8 +5,16 @@
/****
* Classes
****/
+var DeadPerson = Container.expand(function () {
+ var self = Container.call(this);
+ var deadPersonGraphics = self.attachAsset('deadPerson', {
+ anchorX: 0.5,
+ anchorY: 1.0
+ });
+ return self;
+});
var Doll = Container.expand(function () {
var self = Container.call(this);
var dollBody = self.attachAsset('dollBody', {
anchorX: 0.5,
@@ -105,8 +113,16 @@
// Create right soldier
var rightSoldier = game.addChild(new Soldier());
rightSoldier.x = 2048 / 2 + 200;
rightSoldier.y = 600;
+// Create first dead person
+var deadPerson1 = game.addChild(new DeadPerson());
+deadPerson1.x = 2048 / 2 - 400;
+deadPerson1.y = 1500;
+// Create second dead person
+var deadPerson2 = game.addChild(new DeadPerson());
+deadPerson2.x = 2048 / 2 + 400;
+deadPerson2.y = 1800;
// Create phase indicator text
var phaseText = new Text2('GREEN LIGHT', {
size: 100,
fill: '#00FF00'