User prompt
Has que "Theme" suene de fondo siempre
User prompt
Haz que nada más tocar un demogorgon pierdas
User prompt
Haz que la batería de la luz duerme un poco más
User prompt
Añade una barra que indique cuanto me queda de vida y energía y haz que el demogorgon se mueva más rápido ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Haz el código ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Hazlo más difícil. Que el demogorgon ataque más
Code edit (1 edits merged)
Please save this source code
User prompt
Upside Down Survival
Initial prompt
Create a RPG about suriviving in Stranger Things's upside down
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Battery = Container.expand(function () {
var self = Container.call(this);
var batteryGraphics = self.attachAsset('battery', {
anchorX: 0.5,
anchorY: 0.5
});
self.collected = false;
self.update = function () {
if (player && !self.collected) {
var distance = Math.sqrt(Math.pow(self.x - player.x, 2) + Math.pow(self.y - player.y, 2));
if (distance < 50) {
self.collected = true;
player.addBattery(30);
LK.setScore(LK.getScore() + 10);
scoreText.setText(LK.getScore());
tween(batteryGraphics, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0
}, {
duration: 500,
onFinish: function onFinish() {
self.destroy();
}
});
}
}
};
return self;
});
var Demogorgon = Container.expand(function () {
var self = Container.call(this);
var demoGraphics = self.attachAsset('demogorgon', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1;
self.huntingPlayer = false;
self.lastPlayerDistance = 0;
self.patrolAngle = Math.random() * Math.PI * 2;
self.patrolSpeed = 0.5;
self.update = function () {
if (!player) return;
var distanceToPlayer = Math.sqrt(Math.pow(self.x - player.x, 2) + Math.pow(self.y - player.y, 2));
var lightRadius = player.batteryLife / 100 * 300;
// Hunt player if they're in light radius
if (distanceToPlayer < lightRadius && player.batteryLife > 10) {
self.huntingPlayer = true;
// Move towards player
var angle = Math.atan2(player.y - self.y, player.x - self.x);
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
// Check collision with player
if (distanceToPlayer < 60 && !player.isMoving) {
player.takeDamage(20);
// Push demogorgon away after attack
self.x += Math.cos(angle + Math.PI) * 100;
self.y += Math.sin(angle + Math.PI) * 100;
}
} else {
self.huntingPlayer = false;
// Patrol behavior
self.x += Math.cos(self.patrolAngle) * self.patrolSpeed;
self.y += Math.sin(self.patrolAngle) * self.patrolSpeed;
// Change patrol direction randomly
if (Math.random() < 0.02) {
self.patrolAngle = Math.random() * Math.PI * 2;
}
}
// Keep within game bounds
if (self.x < 100) self.x = 100;
if (self.x > 1948) self.x = 1948;
if (self.y < 100) self.y = 100;
if (self.y > 2632) self.y = 2632;
self.lastPlayerDistance = distanceToPlayer;
};
return self;
});
var HealthKit = Container.expand(function () {
var self = Container.call(this);
var healthGraphics = self.attachAsset('healthKit', {
anchorX: 0.5,
anchorY: 0.5
});
self.collected = false;
self.update = function () {
if (player && !self.collected) {
var distance = Math.sqrt(Math.pow(self.x - player.x, 2) + Math.pow(self.y - player.y, 2));
if (distance < 50) {
self.collected = true;
player.heal(25);
LK.setScore(LK.getScore() + 15);
scoreText.setText(LK.getScore());
tween(healthGraphics, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0
}, {
duration: 500,
onFinish: function onFinish() {
self.destroy();
}
});
}
}
};
return self;
});
var HideSpot = Container.expand(function () {
var self = Container.call(this);
var hideGraphics = self.attachAsset('hideSpot', {
anchorX: 0.5,
anchorY: 0.5
});
hideGraphics.alpha = 0.3;
return self;
});
// Game variables
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 100;
self.batteryLife = 100;
self.isMoving = false;
self.targetX = 0;
self.targetY = 0;
self.update = function () {
// Drain battery over time
if (self.batteryLife > 0) {
self.batteryLife -= 0.1;
if (self.batteryLife < 0) self.batteryLife = 0;
}
// Update light circle based on battery
if (lightCircle) {
lightCircle.alpha = self.batteryLife / 100 * 0.8;
lightCircle.x = self.x;
lightCircle.y = self.y;
}
// Check if reached target position
if (self.isMoving) {
var distanceToTarget = Math.sqrt(Math.pow(self.x - self.targetX, 2) + Math.pow(self.y - self.targetY, 2));
if (distanceToTarget < 10) {
self.isMoving = false;
}
}
};
self.moveTo = function (x, y) {
if (!self.isMoving && self.health > 0) {
self.isMoving = true;
self.targetX = x;
self.targetY = y;
var duration = Math.sqrt(Math.pow(x - self.x, 2) + Math.pow(y - self.y, 2)) * 3;
tween(self, {
x: x,
y: y
}, {
duration: duration,
easing: tween.easeOut,
onFinish: function onFinish() {
self.isMoving = false;
}
});
}
};
self.takeDamage = function (amount) {
self.health -= amount;
if (self.health <= 0) {
self.health = 0;
LK.showGameOver();
} else {
tween(playerGraphics, {
tint: 0xff0000
}, {
duration: 200
});
tween(playerGraphics, {
tint: 0xffffff
}, {
duration: 200
});
}
};
self.heal = function (amount) {
self.health += amount;
if (self.health > 100) self.health = 100;
tween(playerGraphics, {
tint: 0x00ff00
}, {
duration: 300
});
tween(playerGraphics, {
tint: 0xffffff
}, {
duration: 300
});
};
self.addBattery = function (amount) {
self.batteryLife += amount;
if (self.batteryLife > 100) self.batteryLife = 100;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Game variables
var player = null;
var demogorgons = [];
var batteries = [];
var healthKits = [];
var hideSpots = [];
var lightCircle = null;
var waveNumber = 1;
var spawnTimer = 0;
// UI Elements
var scoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0, 0);
LK.gui.topRight.addChild(scoreText);
var healthText = new Text2('Health: 100', {
size: 50,
fill: 0xFF0000
});
healthText.anchor.set(0, 0);
LK.gui.bottomLeft.addChild(healthText);
var batteryText = new Text2('Battery: 100%', {
size: 50,
fill: 0xFFFF00
});
batteryText.anchor.set(0, 0);
LK.gui.bottomRight.addChild(batteryText);
var waveText = new Text2('Wave: 1', {
size: 55,
fill: 0x00FFFF
});
waveText.anchor.set(0.5, 0);
LK.gui.top.addChild(waveText);
// Create light circle
lightCircle = game.addChild(LK.getAsset('lightCircle', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.3
}));
// Initialize player
player = game.addChild(new Player());
player.x = 1024;
player.y = 1366;
// Create initial hide spots
for (var i = 0; i < 8; i++) {
var hideSpot = game.addChild(new HideSpot());
hideSpot.x = Math.random() * 1800 + 124;
hideSpot.y = Math.random() * 2400 + 166;
hideSpots.push(hideSpot);
}
// Spawn initial resources
function spawnBattery() {
var battery = game.addChild(new Battery());
battery.x = Math.random() * 1800 + 124;
battery.y = Math.random() * 2400 + 166;
batteries.push(battery);
}
function spawnHealthKit() {
var healthKit = game.addChild(new HealthKit());
healthKit.x = Math.random() * 1800 + 124;
healthKit.y = Math.random() * 2400 + 166;
healthKits.push(healthKit);
}
function spawnDemogorgon() {
var demogorgon = game.addChild(new Demogorgon());
// Spawn away from player
var angle = Math.random() * Math.PI * 2;
var distance = 800 + Math.random() * 400;
demogorgon.x = player.x + Math.cos(angle) * distance;
demogorgon.y = player.y + Math.sin(angle) * distance;
// Keep within bounds
if (demogorgon.x < 100) demogorgon.x = 100;
if (demogorgon.x > 1948) demogorgon.x = 1948;
if (demogorgon.y < 100) demogorgon.y = 100;
if (demogorgon.y > 2632) demogorgon.y = 2632;
demogorgons.push(demogorgon);
}
// Spawn initial resources
for (var i = 0; i < 3; i++) {
spawnBattery();
spawnHealthKit();
}
spawnDemogorgon();
// Touch controls
game.down = function (x, y, obj) {
if (player && !player.isMoving) {
player.moveTo(x, y);
}
};
// Game update loop
game.update = function () {
if (!player) return;
spawnTimer++;
// Update UI
healthText.setText('Health: ' + Math.ceil(player.health));
batteryText.setText('Battery: ' + Math.ceil(player.batteryLife) + '%');
// Game over if battery dies
if (player.batteryLife <= 0) {
LK.showGameOver();
}
// Clean up destroyed objects
batteries = batteries.filter(function (battery) {
return !battery.destroyed;
});
healthKits = healthKits.filter(function (healthKit) {
return !healthKit.destroyed;
});
demogorgons = demogorgons.filter(function (demogorgon) {
return !demogorgon.destroyed;
});
// Spawn new resources periodically
if (spawnTimer % 600 == 0) {
// Every 10 seconds
spawnBattery();
}
if (spawnTimer % 900 == 0) {
// Every 15 seconds
spawnHealthKit();
}
// Wave progression
if (spawnTimer % 1800 == 0) {
// Every 30 seconds
waveNumber++;
waveText.setText('Wave: ' + waveNumber);
// Spawn more demogorgons each wave
for (var i = 0; i < waveNumber; i++) {
spawnDemogorgon();
}
// Increase demogorgon speed
for (var j = 0; j < demogorgons.length; j++) {
demogorgons[j].speed += 0.2;
}
}
// Maintain minimum resource count
if (batteries.length < 2) {
spawnBattery();
}
if (healthKits.length < 1) {
spawnHealthKit();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -11,43 +11,77 @@
var batteryGraphics = self.attachAsset('battery', {
anchorX: 0.5,
anchorY: 0.5
});
- self.value = 25;
+ self.collected = false;
+ self.update = function () {
+ if (player && !self.collected) {
+ var distance = Math.sqrt(Math.pow(self.x - player.x, 2) + Math.pow(self.y - player.y, 2));
+ if (distance < 50) {
+ self.collected = true;
+ player.addBattery(30);
+ LK.setScore(LK.getScore() + 10);
+ scoreText.setText(LK.getScore());
+ tween(batteryGraphics, {
+ scaleX: 1.5,
+ scaleY: 1.5,
+ alpha: 0
+ }, {
+ duration: 500,
+ onFinish: function onFinish() {
+ self.destroy();
+ }
+ });
+ }
+ }
+ };
return self;
});
var Demogorgon = Container.expand(function () {
var self = Container.call(this);
var demoGraphics = self.attachAsset('demogorgon', {
anchorX: 0.5,
anchorY: 0.5
});
- self.speed = 2;
- self.targetX = 0;
- self.targetY = 0;
- self.huntRadius = 600;
- self.attackCooldown = 0;
+ self.speed = 1;
+ self.huntingPlayer = false;
+ self.lastPlayerDistance = 0;
+ self.patrolAngle = Math.random() * Math.PI * 2;
+ self.patrolSpeed = 0.5;
self.update = function () {
- if (player && flashlight.alpha > 0.1) {
- var dx = player.x - self.x;
- var dy = player.y - self.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- if (distance < self.huntRadius) {
- self.targetX = player.x;
- self.targetY = player.y;
+ if (!player) return;
+ var distanceToPlayer = Math.sqrt(Math.pow(self.x - player.x, 2) + Math.pow(self.y - player.y, 2));
+ var lightRadius = player.batteryLife / 100 * 300;
+ // Hunt player if they're in light radius
+ if (distanceToPlayer < lightRadius && player.batteryLife > 10) {
+ self.huntingPlayer = true;
+ // Move towards player
+ var angle = Math.atan2(player.y - self.y, player.x - self.x);
+ self.x += Math.cos(angle) * self.speed;
+ self.y += Math.sin(angle) * self.speed;
+ // Check collision with player
+ if (distanceToPlayer < 60 && !player.isMoving) {
+ player.takeDamage(20);
+ // Push demogorgon away after attack
+ self.x += Math.cos(angle + Math.PI) * 100;
+ self.y += Math.sin(angle + Math.PI) * 100;
}
+ } else {
+ self.huntingPlayer = false;
+ // Patrol behavior
+ self.x += Math.cos(self.patrolAngle) * self.patrolSpeed;
+ self.y += Math.sin(self.patrolAngle) * self.patrolSpeed;
+ // Change patrol direction randomly
+ if (Math.random() < 0.02) {
+ self.patrolAngle = Math.random() * Math.PI * 2;
+ }
}
- var moveX = self.targetX - self.x;
- var moveY = self.targetY - self.y;
- var moveDistance = Math.sqrt(moveX * moveX + moveY * moveY);
- if (moveDistance > 5) {
- self.x += moveX / moveDistance * self.speed;
- self.y += moveY / moveDistance * self.speed;
- }
- // Attack cooldown timer
- if (self.attackCooldown > 0) {
- self.attackCooldown--;
- }
+ // Keep within game bounds
+ if (self.x < 100) self.x = 100;
+ if (self.x > 1948) self.x = 1948;
+ if (self.y < 100) self.y = 100;
+ if (self.y > 2632) self.y = 2632;
+ self.lastPlayerDistance = distanceToPlayer;
};
return self;
});
var HealthKit = Container.expand(function () {
@@ -55,278 +89,278 @@
var healthGraphics = self.attachAsset('healthKit', {
anchorX: 0.5,
anchorY: 0.5
});
- self.value = 30;
+ self.collected = false;
+ self.update = function () {
+ if (player && !self.collected) {
+ var distance = Math.sqrt(Math.pow(self.x - player.x, 2) + Math.pow(self.y - player.y, 2));
+ if (distance < 50) {
+ self.collected = true;
+ player.heal(25);
+ LK.setScore(LK.getScore() + 15);
+ scoreText.setText(LK.getScore());
+ tween(healthGraphics, {
+ scaleX: 1.5,
+ scaleY: 1.5,
+ alpha: 0
+ }, {
+ duration: 500,
+ onFinish: function onFinish() {
+ self.destroy();
+ }
+ });
+ }
+ }
+ };
return self;
});
var HideSpot = Container.expand(function () {
var self = Container.call(this);
var hideGraphics = self.attachAsset('hideSpot', {
anchorX: 0.5,
anchorY: 0.5
});
- hideGraphics.alpha = 0.6;
+ hideGraphics.alpha = 0.3;
return self;
});
+// Game variables
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 100;
- self.batteryLevel = 100;
- self.isHiding = false;
- self.maxBatteryLevel = 100;
- self.takeDamage = function (amount) {
- if (!self.isHiding) {
- self.health -= amount;
- if (self.health <= 0) {
- self.health = 0;
+ self.batteryLife = 100;
+ self.isMoving = false;
+ self.targetX = 0;
+ self.targetY = 0;
+ self.update = function () {
+ // Drain battery over time
+ if (self.batteryLife > 0) {
+ self.batteryLife -= 0.1;
+ if (self.batteryLife < 0) self.batteryLife = 0;
+ }
+ // Update light circle based on battery
+ if (lightCircle) {
+ lightCircle.alpha = self.batteryLife / 100 * 0.8;
+ lightCircle.x = self.x;
+ lightCircle.y = self.y;
+ }
+ // Check if reached target position
+ if (self.isMoving) {
+ var distanceToTarget = Math.sqrt(Math.pow(self.x - self.targetX, 2) + Math.pow(self.y - self.targetY, 2));
+ if (distanceToTarget < 10) {
+ self.isMoving = false;
}
}
};
+ self.moveTo = function (x, y) {
+ if (!self.isMoving && self.health > 0) {
+ self.isMoving = true;
+ self.targetX = x;
+ self.targetY = y;
+ var duration = Math.sqrt(Math.pow(x - self.x, 2) + Math.pow(y - self.y, 2)) * 3;
+ tween(self, {
+ x: x,
+ y: y
+ }, {
+ duration: duration,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ self.isMoving = false;
+ }
+ });
+ }
+ };
+ self.takeDamage = function (amount) {
+ self.health -= amount;
+ if (self.health <= 0) {
+ self.health = 0;
+ LK.showGameOver();
+ } else {
+ tween(playerGraphics, {
+ tint: 0xff0000
+ }, {
+ duration: 200
+ });
+ tween(playerGraphics, {
+ tint: 0xffffff
+ }, {
+ duration: 200
+ });
+ }
+ };
self.heal = function (amount) {
- self.health = Math.min(100, self.health + amount);
+ self.health += amount;
+ if (self.health > 100) self.health = 100;
+ tween(playerGraphics, {
+ tint: 0x00ff00
+ }, {
+ duration: 300
+ });
+ tween(playerGraphics, {
+ tint: 0xffffff
+ }, {
+ duration: 300
+ });
};
self.addBattery = function (amount) {
- self.batteryLevel = Math.min(self.maxBatteryLevel, self.batteryLevel + amount);
+ self.batteryLife += amount;
+ if (self.batteryLife > 100) self.batteryLife = 100;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x0a0a0a
+ backgroundColor: 0x000000
});
/****
* Game Code
****/
+// Game variables
var player = null;
-var flashlight = null;
var demogorgons = [];
var batteries = [];
var healthKits = [];
var hideSpots = [];
+var lightCircle = null;
var waveNumber = 1;
-var itemSpawnTimer = 0;
-var demoSpawnTimer = 0;
-var batteryDrainTimer = 0;
-var damageTimer = 0;
+var spawnTimer = 0;
// UI Elements
+var scoreText = new Text2('Score: 0', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+scoreText.anchor.set(0, 0);
+LK.gui.topRight.addChild(scoreText);
var healthText = new Text2('Health: 100', {
- size: 40,
+ size: 50,
fill: 0xFF0000
});
healthText.anchor.set(0, 0);
-healthText.x = 120;
-healthText.y = 20;
-LK.gui.topLeft.addChild(healthText);
+LK.gui.bottomLeft.addChild(healthText);
var batteryText = new Text2('Battery: 100%', {
- size: 40,
+ size: 50,
fill: 0xFFFF00
});
batteryText.anchor.set(0, 0);
-batteryText.x = 120;
-batteryText.y = 70;
-LK.gui.topLeft.addChild(batteryText);
+LK.gui.bottomRight.addChild(batteryText);
var waveText = new Text2('Wave: 1', {
- size: 50,
- fill: 0xFFFFFF
+ size: 55,
+ fill: 0x00FFFF
});
waveText.anchor.set(0.5, 0);
LK.gui.top.addChild(waveText);
+// Create light circle
+lightCircle = game.addChild(LK.getAsset('lightCircle', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ alpha: 0.3
+}));
// Initialize player
player = game.addChild(new Player());
player.x = 1024;
player.y = 1366;
-// Initialize flashlight
-flashlight = game.addChild(LK.getAsset('lightCircle', {
- anchorX: 0.5,
- anchorY: 0.5
-}));
-flashlight.alpha = 0.3;
-flashlight.x = player.x;
-flashlight.y = player.y;
// Create initial hide spots
-function spawnHideSpots() {
- for (var i = 0; i < 6; i++) {
- var hideSpot = game.addChild(new HideSpot());
- hideSpot.x = Math.random() * 1800 + 200;
- hideSpot.y = Math.random() * 2400 + 200;
- hideSpots.push(hideSpot);
- }
+for (var i = 0; i < 8; i++) {
+ var hideSpot = game.addChild(new HideSpot());
+ hideSpot.x = Math.random() * 1800 + 124;
+ hideSpot.y = Math.random() * 2400 + 166;
+ hideSpots.push(hideSpot);
}
+// Spawn initial resources
function spawnBattery() {
var battery = game.addChild(new Battery());
- battery.x = Math.random() * 1800 + 200;
- battery.y = Math.random() * 2400 + 200;
+ battery.x = Math.random() * 1800 + 124;
+ battery.y = Math.random() * 2400 + 166;
batteries.push(battery);
}
function spawnHealthKit() {
var healthKit = game.addChild(new HealthKit());
- healthKit.x = Math.random() * 1800 + 200;
- healthKit.y = Math.random() * 2400 + 200;
+ healthKit.x = Math.random() * 1800 + 124;
+ healthKit.y = Math.random() * 2400 + 166;
healthKits.push(healthKit);
}
function spawnDemogorgon() {
- var demo = game.addChild(new Demogorgon());
- var edge = Math.floor(Math.random() * 4);
- switch (edge) {
- case 0:
- // Top
- demo.x = Math.random() * 2048;
- demo.y = -100;
- break;
- case 1:
- // Right
- demo.x = 2148;
- demo.y = Math.random() * 2732;
- break;
- case 2:
- // Bottom
- demo.x = Math.random() * 2048;
- demo.y = 2832;
- break;
- case 3:
- // Left
- demo.x = -100;
- demo.y = Math.random() * 2732;
- break;
- }
- demo.targetX = demo.x;
- demo.targetY = demo.y;
- demogorgons.push(demo);
+ var demogorgon = game.addChild(new Demogorgon());
+ // Spawn away from player
+ var angle = Math.random() * Math.PI * 2;
+ var distance = 800 + Math.random() * 400;
+ demogorgon.x = player.x + Math.cos(angle) * distance;
+ demogorgon.y = player.y + Math.sin(angle) * distance;
+ // Keep within bounds
+ if (demogorgon.x < 100) demogorgon.x = 100;
+ if (demogorgon.x > 1948) demogorgon.x = 1948;
+ if (demogorgon.y < 100) demogorgon.y = 100;
+ if (demogorgon.y > 2632) demogorgon.y = 2632;
+ demogorgons.push(demogorgon);
}
-// Initialize starting items
-spawnHideSpots();
-spawnBattery();
-spawnBattery();
-spawnHealthKit();
+// Spawn initial resources
+for (var i = 0; i < 3; i++) {
+ spawnBattery();
+ spawnHealthKit();
+}
+spawnDemogorgon();
+// Touch controls
game.down = function (x, y, obj) {
- tween(player, {
- x: x,
- y: y
- }, {
- duration: 500
- });
+ if (player && !player.isMoving) {
+ player.moveTo(x, y);
+ }
};
+// Game update loop
game.update = function () {
- // Update flashlight position
- flashlight.x = player.x;
- flashlight.y = player.y;
- // Battery drain
- batteryDrainTimer++;
- if (batteryDrainTimer >= 60) {
- // Every second
- player.batteryLevel = Math.max(0, player.batteryLevel - 1);
- batteryDrainTimer = 0;
+ if (!player) return;
+ spawnTimer++;
+ // Update UI
+ healthText.setText('Health: ' + Math.ceil(player.health));
+ batteryText.setText('Battery: ' + Math.ceil(player.batteryLife) + '%');
+ // Game over if battery dies
+ if (player.batteryLife <= 0) {
+ LK.showGameOver();
}
- // Adjust flashlight based on battery
- if (player.batteryLevel <= 0) {
- flashlight.alpha = 0;
- // Player takes damage in darkness
- damageTimer++;
- if (damageTimer >= 120) {
- // Every 2 seconds
- player.takeDamage(10);
- LK.getSound('damage').play();
- damageTimer = 0;
- }
- } else {
- flashlight.alpha = 0.3;
- damageTimer = 0;
+ // Clean up destroyed objects
+ batteries = batteries.filter(function (battery) {
+ return !battery.destroyed;
+ });
+ healthKits = healthKits.filter(function (healthKit) {
+ return !healthKit.destroyed;
+ });
+ demogorgons = demogorgons.filter(function (demogorgon) {
+ return !demogorgon.destroyed;
+ });
+ // Spawn new resources periodically
+ if (spawnTimer % 600 == 0) {
+ // Every 10 seconds
+ spawnBattery();
}
- // Check if player is hiding
- player.isHiding = false;
- for (var h = 0; h < hideSpots.length; h++) {
- if (player.intersects(hideSpots[h])) {
- player.isHiding = true;
- flashlight.alpha = Math.min(0.1, flashlight.alpha);
- break;
- }
+ if (spawnTimer % 900 == 0) {
+ // Every 15 seconds
+ spawnHealthKit();
}
- // Update demogorgons
- for (var d = demogorgons.length - 1; d >= 0; d--) {
- var demo = demogorgons[d];
- // Check collision with player
- if (demo.intersects(player) && demo.attackCooldown <= 0) {
- player.takeDamage(35);
- LK.getSound('damage').play();
- LK.effects.flashScreen(0xff0000, 300);
- demo.attackCooldown = 30; // Short cooldown before next attack
- }
- // Remove if too far from game area
- if (demo.x < -300 || demo.x > 2348 || demo.y < -300 || demo.y > 3032) {
- demo.destroy();
- demogorgons.splice(d, 1);
- }
- }
- // Check battery pickup
- for (var b = batteries.length - 1; b >= 0; b--) {
- if (player.intersects(batteries[b])) {
- player.addBattery(batteries[b].value);
- LK.getSound('pickup').play();
- batteries[b].destroy();
- batteries.splice(b, 1);
- }
- }
- // Check health kit pickup
- for (var h = healthKits.length - 1; h >= 0; h--) {
- if (player.intersects(healthKits[h])) {
- player.heal(healthKits[h].value);
- LK.getSound('pickup').play();
- healthKits[h].destroy();
- healthKits.splice(h, 1);
- }
- }
- // Spawn items
- itemSpawnTimer++;
- if (itemSpawnTimer >= 300) {
- // Every 5 seconds
- if (Math.random() < 0.7) {
- spawnBattery();
- } else {
- spawnHealthKit();
- }
- itemSpawnTimer = 0;
- }
- // Spawn demogorgons
- demoSpawnTimer++;
- var spawnRate = Math.max(180 - waveNumber * 20, 60); // Much faster spawning each wave
- if (demoSpawnTimer >= spawnRate) {
- // Spawn multiple demogorgons based on wave number
- var spawnCount = Math.floor(waveNumber / 2) + 1;
- for (var s = 0; s < spawnCount; s++) {
- spawnDemogorgon();
- }
- demoSpawnTimer = 0;
- }
// Wave progression
- if (LK.ticks % 900 === 0) {
- // Every 15 seconds
+ if (spawnTimer % 1800 == 0) {
+ // Every 30 seconds
waveNumber++;
- // Increase demogorgon speed more aggressively
- for (var d = 0; d < demogorgons.length; d++) {
- demogorgons[d].speed += 0.5;
- demogorgons[d].huntRadius += 50;
+ waveText.setText('Wave: ' + waveNumber);
+ // Spawn more demogorgons each wave
+ for (var i = 0; i < waveNumber; i++) {
+ spawnDemogorgon();
}
+ // Increase demogorgon speed
+ for (var j = 0; j < demogorgons.length; j++) {
+ demogorgons[j].speed += 0.2;
+ }
}
- // Update UI
- healthText.setText('Health: ' + Math.floor(player.health));
- batteryText.setText('Battery: ' + Math.floor(player.batteryLevel) + '%');
- waveText.setText('Wave: ' + waveNumber);
- // Game over condition
- if (player.health <= 0) {
- LK.setScore(waveNumber * 100 + LK.ticks);
- LK.showGameOver();
+ // Maintain minimum resource count
+ if (batteries.length < 2) {
+ spawnBattery();
}
- // Keep player in bounds
- player.x = Math.max(50, Math.min(1998, player.x));
- player.y = Math.max(50, Math.min(2682, player.y));
-};
-// Start ambient music
-LK.playMusic('ambient');
\ No newline at end of file
+ if (healthKits.length < 1) {
+ spawnHealthKit();
+ }
+};
\ No newline at end of file
A Stranger Things demogorgon in pixel art. In-Game asset. 2d. High contrast. No shadows
Will Byers from Stranger Things in pixel art style. In-Game asset. 2d. High contrast. No shadows
Una pila en estilo pixel art. In-Game asset. 2d. High contrast. No shadows
Un arbusto en estilo pixel art. Que tenga tonos principalemente negros con tonos rojizos. In-Game asset. 2d. High contrast. No shadows
Un botiquín en estilo pixel art y sin fondo. In-Game asset. 2d. High contrast. No shadows