User prompt
Blokları ve enkazları azalt
User prompt
Herşeyi büyüt
User prompt
Blokları büyüt
User prompt
Arka plana karartı efekti ekle
User prompt
Kurtulanın bir hız sınırı olsun ve elinde silah olsun
User prompt
Engellerden geçemeyelim
User prompt
Zombilere silahla sıkalım ve engeller olsun
Code edit (1 edits merged)
Please save this source code
User prompt
The Last of Us: Survival Run
Initial prompt
Make to the last of us
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Debris = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('debris', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
var Supply = Container.expand(function (type) {
var self = Container.call(this);
self.type = type;
var assetName = type;
var graphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.value = type === 'medicine' ? 25 : type === 'food' ? 15 : 3;
return self;
});
var Survivor = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('survivor', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 100;
self.ammoCount = 5;
self.speed = 3;
self.isMoving = false;
self.detectionRadius = 120;
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health < 0) self.health = 0;
LK.effects.flashObject(self, 0xff0000, 500);
LK.getSound('damage').play();
};
self.heal = function (amount) {
self.health += amount;
if (self.health > 100) self.health = 100;
LK.effects.flashObject(self, 0x00ff00, 300);
};
self.addAmmo = function (amount) {
self.ammoCount += amount;
};
self.shoot = function () {
if (self.ammoCount > 0) {
self.ammoCount--;
LK.getSound('shoot').play();
return true;
}
return false;
};
return self;
});
var Zombie = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('zombie', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1;
self.detectionRadius = 100;
self.isAlerted = false;
self.targetX = self.x;
self.targetY = self.y;
self.patrolDistance = 150;
self.originalX = 0;
self.originalY = 0;
self.patrolDirection = 1;
self.alert = function () {
if (!self.isAlerted) {
self.isAlerted = true;
self.speed = 2.5;
tween(graphics, {
tint: 0xff4444
}, {
duration: 300
});
}
};
self.update = function () {
if (self.isAlerted) {
// Chase player
var dx = survivor.x - self.x;
var dy = survivor.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 5) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
} else {
// Patrol behavior
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 10) {
// Reached patrol point, set new target
self.targetX = self.originalX + (Math.random() - 0.5) * self.patrolDistance;
self.targetY = self.originalY + (Math.random() - 0.5) * self.patrolDistance;
// Keep within bounds
self.targetX = Math.max(100, Math.min(1948, self.targetX));
self.targetY = Math.max(300, Math.min(2432, self.targetY));
} else {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2d3748
});
/****
* Game Code
****/
// Game variables
var survivor;
var zombies = [];
var supplies = [];
var debris = [];
var dragNode = null;
var gameTime = 0;
var lastHealthDecrease = 0;
var lastSupplySpawn = 0;
var lastZombieSpawn = 0;
var difficultyLevel = 1;
// UI Elements
var healthText = new Text2('Health: 100', {
size: 40,
fill: '#ff0000'
});
healthText.anchor.set(0, 0);
LK.gui.topLeft.addChild(healthText);
healthText.x = 120;
healthText.y = 20;
var ammoText = new Text2('Ammo: 5', {
size: 40,
fill: '#ffff00'
});
ammoText.anchor.set(0, 0);
LK.gui.topLeft.addChild(ammoText);
ammoText.x = 120;
ammoText.y = 70;
var scoreText = new Text2('Score: 0', {
size: 50,
fill: '#ffffff'
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
// Initialize survivor
survivor = game.addChild(new Survivor());
survivor.x = 1024;
survivor.y = 2000;
// Spawn initial debris
for (var i = 0; i < 8; i++) {
var debrisItem = game.addChild(new Debris());
debrisItem.x = 200 + Math.random() * 1648;
debrisItem.y = 400 + Math.random() * 1800;
debris.push(debrisItem);
}
// Spawn initial zombies
for (var i = 0; i < 3; i++) {
var zombie = game.addChild(new Zombie());
zombie.x = 300 + Math.random() * 1448;
zombie.y = 300 + Math.random() * 1500;
zombie.originalX = zombie.x;
zombie.originalY = zombie.y;
zombie.targetX = zombie.x;
zombie.targetY = zombie.y;
zombies.push(zombie);
}
// Spawn initial supplies
for (var i = 0; i < 5; i++) {
spawnSupply();
}
function spawnSupply() {
var types = ['medicine', 'food', 'ammo'];
var type = types[Math.floor(Math.random() * types.length)];
var supply = game.addChild(new Supply(type));
// Spawn away from debris and zombies
var validPosition = false;
var attempts = 0;
while (!validPosition && attempts < 10) {
supply.x = 100 + Math.random() * 1848;
supply.y = 300 + Math.random() * 2132;
validPosition = true;
// Check distance from debris
for (var j = 0; j < debris.length; j++) {
var dist = Math.sqrt(Math.pow(supply.x - debris[j].x, 2) + Math.pow(supply.y - debris[j].y, 2));
if (dist < 80) {
validPosition = false;
break;
}
}
attempts++;
}
supplies.push(supply);
}
function spawnZombie() {
var zombie = game.addChild(new Zombie());
// Spawn at edges of screen
var side = Math.floor(Math.random() * 4);
if (side === 0) {
// top
zombie.x = Math.random() * 2048;
zombie.y = 200;
} else if (side === 1) {
// right
zombie.x = 1900;
zombie.y = Math.random() * 2732;
} else if (side === 2) {
// bottom
zombie.x = Math.random() * 2048;
zombie.y = 2500;
} else {
// left
zombie.x = 150;
zombie.y = Math.random() * 2732;
}
zombie.originalX = zombie.x;
zombie.originalY = zombie.y;
zombie.targetX = zombie.x;
zombie.targetY = zombie.y;
zombies.push(zombie);
}
function updateUI() {
healthText.setText('Health: ' + Math.floor(survivor.health));
ammoText.setText('Ammo: ' + survivor.ammoCount);
scoreText.setText('Score: ' + LK.getScore());
}
// Event handlers
game.down = function (x, y, obj) {
dragNode = survivor;
survivor.isMoving = true;
// Check if clicking near zombie to shoot
var nearestZombie = null;
var nearestDistance = Infinity;
for (var i = 0; i < zombies.length; i++) {
var zombie = zombies[i];
var dist = Math.sqrt(Math.pow(x - zombie.x, 2) + Math.pow(y - zombie.y, 2));
if (dist < 100 && dist < nearestDistance) {
nearestDistance = dist;
nearestZombie = zombie;
}
}
if (nearestZombie && survivor.shoot()) {
// Remove zombie
var index = zombies.indexOf(nearestZombie);
if (index > -1) {
nearestZombie.destroy();
zombies.splice(index, 1);
LK.setScore(LK.getScore() + 50);
}
}
};
game.up = function (x, y, obj) {
dragNode = null;
survivor.isMoving = false;
};
game.move = function (x, y, obj) {
if (dragNode) {
// Keep survivor within bounds
dragNode.x = Math.max(50, Math.min(1998, x));
dragNode.y = Math.max(300, Math.min(2682, y));
survivor.isMoving = true;
}
};
game.update = function () {
gameTime += 16; // Approximately 16ms per frame at 60fps
// Health decreases over time
if (gameTime - lastHealthDecrease > 3000) {
// Every 3 seconds
survivor.health -= 2;
lastHealthDecrease = gameTime;
}
// Check game over
if (survivor.health <= 0) {
LK.showGameOver();
return;
}
// Spawn supplies
if (gameTime - lastSupplySpawn > 8000) {
// Every 8 seconds
spawnSupply();
lastSupplySpawn = gameTime;
}
// Spawn zombies (increasing difficulty)
difficultyLevel = Math.floor(gameTime / 30000) + 1; // Increase difficulty every 30 seconds
var zombieSpawnRate = Math.max(5000 - difficultyLevel * 500, 2000); // Faster spawning over time
if (gameTime - lastZombieSpawn > zombieSpawnRate) {
spawnZombie();
lastZombieSpawn = gameTime;
}
// Check zombie detection
for (var i = 0; i < zombies.length; i++) {
var zombie = zombies[i];
var dist = Math.sqrt(Math.pow(survivor.x - zombie.x, 2) + Math.pow(survivor.y - zombie.y, 2));
if (dist < zombie.detectionRadius) {
if (survivor.isMoving) {
// Fast movement alerts zombies
zombie.alert();
} else if (dist < 60) {
// Very close detection even when stationary
zombie.alert();
}
}
// Check collision with survivor
if (survivor.intersects(zombie)) {
survivor.takeDamage(10);
}
}
// Check supply collection
for (var i = supplies.length - 1; i >= 0; i--) {
var supply = supplies[i];
if (survivor.intersects(supply)) {
LK.getSound('collect').play();
if (supply.type === 'medicine') {
survivor.heal(supply.value);
LK.setScore(LK.getScore() + 20);
} else if (supply.type === 'food') {
survivor.heal(supply.value);
LK.setScore(LK.getScore() + 15);
} else if (supply.type === 'ammo') {
survivor.addAmmo(supply.value);
LK.setScore(LK.getScore() + 10);
}
supply.destroy();
supplies.splice(i, 1);
}
}
// Add score for survival time
if (LK.ticks % 60 === 0) {
// Every second
LK.setScore(LK.getScore() + 1);
}
updateUI();
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,351 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Debris = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('debris', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ return self;
+});
+var Supply = Container.expand(function (type) {
+ var self = Container.call(this);
+ self.type = type;
+ var assetName = type;
+ var graphics = self.attachAsset(assetName, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.value = type === 'medicine' ? 25 : type === 'food' ? 15 : 3;
+ return self;
+});
+var Survivor = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('survivor', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.health = 100;
+ self.ammoCount = 5;
+ self.speed = 3;
+ self.isMoving = false;
+ self.detectionRadius = 120;
+ self.takeDamage = function (damage) {
+ self.health -= damage;
+ if (self.health < 0) self.health = 0;
+ LK.effects.flashObject(self, 0xff0000, 500);
+ LK.getSound('damage').play();
+ };
+ self.heal = function (amount) {
+ self.health += amount;
+ if (self.health > 100) self.health = 100;
+ LK.effects.flashObject(self, 0x00ff00, 300);
+ };
+ self.addAmmo = function (amount) {
+ self.ammoCount += amount;
+ };
+ self.shoot = function () {
+ if (self.ammoCount > 0) {
+ self.ammoCount--;
+ LK.getSound('shoot').play();
+ return true;
+ }
+ return false;
+ };
+ return self;
+});
+var Zombie = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('zombie', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 1;
+ self.detectionRadius = 100;
+ self.isAlerted = false;
+ self.targetX = self.x;
+ self.targetY = self.y;
+ self.patrolDistance = 150;
+ self.originalX = 0;
+ self.originalY = 0;
+ self.patrolDirection = 1;
+ self.alert = function () {
+ if (!self.isAlerted) {
+ self.isAlerted = true;
+ self.speed = 2.5;
+ tween(graphics, {
+ tint: 0xff4444
+ }, {
+ duration: 300
+ });
+ }
+ };
+ self.update = function () {
+ if (self.isAlerted) {
+ // Chase player
+ var dx = survivor.x - self.x;
+ var dy = survivor.y - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > 5) {
+ self.x += dx / distance * self.speed;
+ self.y += dy / distance * self.speed;
+ }
+ } else {
+ // Patrol behavior
+ var dx = self.targetX - self.x;
+ var dy = self.targetY - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < 10) {
+ // Reached patrol point, set new target
+ self.targetX = self.originalX + (Math.random() - 0.5) * self.patrolDistance;
+ self.targetY = self.originalY + (Math.random() - 0.5) * self.patrolDistance;
+ // Keep within bounds
+ self.targetX = Math.max(100, Math.min(1948, self.targetX));
+ self.targetY = Math.max(300, Math.min(2432, self.targetY));
+ } else {
+ self.x += dx / distance * self.speed;
+ self.y += dy / distance * self.speed;
+ }
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x2d3748
+});
+
+/****
+* Game Code
+****/
+// Game variables
+var survivor;
+var zombies = [];
+var supplies = [];
+var debris = [];
+var dragNode = null;
+var gameTime = 0;
+var lastHealthDecrease = 0;
+var lastSupplySpawn = 0;
+var lastZombieSpawn = 0;
+var difficultyLevel = 1;
+// UI Elements
+var healthText = new Text2('Health: 100', {
+ size: 40,
+ fill: '#ff0000'
+});
+healthText.anchor.set(0, 0);
+LK.gui.topLeft.addChild(healthText);
+healthText.x = 120;
+healthText.y = 20;
+var ammoText = new Text2('Ammo: 5', {
+ size: 40,
+ fill: '#ffff00'
+});
+ammoText.anchor.set(0, 0);
+LK.gui.topLeft.addChild(ammoText);
+ammoText.x = 120;
+ammoText.y = 70;
+var scoreText = new Text2('Score: 0', {
+ size: 50,
+ fill: '#ffffff'
+});
+scoreText.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreText);
+// Initialize survivor
+survivor = game.addChild(new Survivor());
+survivor.x = 1024;
+survivor.y = 2000;
+// Spawn initial debris
+for (var i = 0; i < 8; i++) {
+ var debrisItem = game.addChild(new Debris());
+ debrisItem.x = 200 + Math.random() * 1648;
+ debrisItem.y = 400 + Math.random() * 1800;
+ debris.push(debrisItem);
+}
+// Spawn initial zombies
+for (var i = 0; i < 3; i++) {
+ var zombie = game.addChild(new Zombie());
+ zombie.x = 300 + Math.random() * 1448;
+ zombie.y = 300 + Math.random() * 1500;
+ zombie.originalX = zombie.x;
+ zombie.originalY = zombie.y;
+ zombie.targetX = zombie.x;
+ zombie.targetY = zombie.y;
+ zombies.push(zombie);
+}
+// Spawn initial supplies
+for (var i = 0; i < 5; i++) {
+ spawnSupply();
+}
+function spawnSupply() {
+ var types = ['medicine', 'food', 'ammo'];
+ var type = types[Math.floor(Math.random() * types.length)];
+ var supply = game.addChild(new Supply(type));
+ // Spawn away from debris and zombies
+ var validPosition = false;
+ var attempts = 0;
+ while (!validPosition && attempts < 10) {
+ supply.x = 100 + Math.random() * 1848;
+ supply.y = 300 + Math.random() * 2132;
+ validPosition = true;
+ // Check distance from debris
+ for (var j = 0; j < debris.length; j++) {
+ var dist = Math.sqrt(Math.pow(supply.x - debris[j].x, 2) + Math.pow(supply.y - debris[j].y, 2));
+ if (dist < 80) {
+ validPosition = false;
+ break;
+ }
+ }
+ attempts++;
+ }
+ supplies.push(supply);
+}
+function spawnZombie() {
+ var zombie = game.addChild(new Zombie());
+ // Spawn at edges of screen
+ var side = Math.floor(Math.random() * 4);
+ if (side === 0) {
+ // top
+ zombie.x = Math.random() * 2048;
+ zombie.y = 200;
+ } else if (side === 1) {
+ // right
+ zombie.x = 1900;
+ zombie.y = Math.random() * 2732;
+ } else if (side === 2) {
+ // bottom
+ zombie.x = Math.random() * 2048;
+ zombie.y = 2500;
+ } else {
+ // left
+ zombie.x = 150;
+ zombie.y = Math.random() * 2732;
+ }
+ zombie.originalX = zombie.x;
+ zombie.originalY = zombie.y;
+ zombie.targetX = zombie.x;
+ zombie.targetY = zombie.y;
+ zombies.push(zombie);
+}
+function updateUI() {
+ healthText.setText('Health: ' + Math.floor(survivor.health));
+ ammoText.setText('Ammo: ' + survivor.ammoCount);
+ scoreText.setText('Score: ' + LK.getScore());
+}
+// Event handlers
+game.down = function (x, y, obj) {
+ dragNode = survivor;
+ survivor.isMoving = true;
+ // Check if clicking near zombie to shoot
+ var nearestZombie = null;
+ var nearestDistance = Infinity;
+ for (var i = 0; i < zombies.length; i++) {
+ var zombie = zombies[i];
+ var dist = Math.sqrt(Math.pow(x - zombie.x, 2) + Math.pow(y - zombie.y, 2));
+ if (dist < 100 && dist < nearestDistance) {
+ nearestDistance = dist;
+ nearestZombie = zombie;
+ }
+ }
+ if (nearestZombie && survivor.shoot()) {
+ // Remove zombie
+ var index = zombies.indexOf(nearestZombie);
+ if (index > -1) {
+ nearestZombie.destroy();
+ zombies.splice(index, 1);
+ LK.setScore(LK.getScore() + 50);
+ }
+ }
+};
+game.up = function (x, y, obj) {
+ dragNode = null;
+ survivor.isMoving = false;
+};
+game.move = function (x, y, obj) {
+ if (dragNode) {
+ // Keep survivor within bounds
+ dragNode.x = Math.max(50, Math.min(1998, x));
+ dragNode.y = Math.max(300, Math.min(2682, y));
+ survivor.isMoving = true;
+ }
+};
+game.update = function () {
+ gameTime += 16; // Approximately 16ms per frame at 60fps
+ // Health decreases over time
+ if (gameTime - lastHealthDecrease > 3000) {
+ // Every 3 seconds
+ survivor.health -= 2;
+ lastHealthDecrease = gameTime;
+ }
+ // Check game over
+ if (survivor.health <= 0) {
+ LK.showGameOver();
+ return;
+ }
+ // Spawn supplies
+ if (gameTime - lastSupplySpawn > 8000) {
+ // Every 8 seconds
+ spawnSupply();
+ lastSupplySpawn = gameTime;
+ }
+ // Spawn zombies (increasing difficulty)
+ difficultyLevel = Math.floor(gameTime / 30000) + 1; // Increase difficulty every 30 seconds
+ var zombieSpawnRate = Math.max(5000 - difficultyLevel * 500, 2000); // Faster spawning over time
+ if (gameTime - lastZombieSpawn > zombieSpawnRate) {
+ spawnZombie();
+ lastZombieSpawn = gameTime;
+ }
+ // Check zombie detection
+ for (var i = 0; i < zombies.length; i++) {
+ var zombie = zombies[i];
+ var dist = Math.sqrt(Math.pow(survivor.x - zombie.x, 2) + Math.pow(survivor.y - zombie.y, 2));
+ if (dist < zombie.detectionRadius) {
+ if (survivor.isMoving) {
+ // Fast movement alerts zombies
+ zombie.alert();
+ } else if (dist < 60) {
+ // Very close detection even when stationary
+ zombie.alert();
+ }
+ }
+ // Check collision with survivor
+ if (survivor.intersects(zombie)) {
+ survivor.takeDamage(10);
+ }
+ }
+ // Check supply collection
+ for (var i = supplies.length - 1; i >= 0; i--) {
+ var supply = supplies[i];
+ if (survivor.intersects(supply)) {
+ LK.getSound('collect').play();
+ if (supply.type === 'medicine') {
+ survivor.heal(supply.value);
+ LK.setScore(LK.getScore() + 20);
+ } else if (supply.type === 'food') {
+ survivor.heal(supply.value);
+ LK.setScore(LK.getScore() + 15);
+ } else if (supply.type === 'ammo') {
+ survivor.addAmmo(supply.value);
+ LK.setScore(LK.getScore() + 10);
+ }
+ supply.destroy();
+ supplies.splice(i, 1);
+ }
+ }
+ // Add score for survival time
+ if (LK.ticks % 60 === 0) {
+ // Every second
+ LK.setScore(LK.getScore() + 1);
+ }
+ updateUI();
+};
\ No newline at end of file
Kutu. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Mermi . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Ekmek . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
İlaç . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Zombi. In-Game asset. 2d. High contrast. No shadows
Kurtulan. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat