/****
* 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 = 2;
self.huntingPlayer = false;
self.lastPlayerDistance = 0;
self.patrolAngle = Math.random() * Math.PI * 2;
self.patrolSpeed = 1;
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) {
LK.showGameOver();
}
} 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.05;
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);
// Health bar background
var healthBarBg = LK.getAsset('shape', {
width: 300,
height: 20,
color: 0x330000,
shape: 'box',
anchorX: 0,
anchorY: 0
});
LK.gui.bottomLeft.addChild(healthBarBg);
// Health bar
var healthBar = LK.getAsset('shape', {
width: 300,
height: 20,
color: 0xFF0000,
shape: 'box',
anchorX: 0,
anchorY: 0
});
LK.gui.bottomLeft.addChild(healthBar);
// Energy bar background
var energyBarBg = LK.getAsset('shape', {
width: 300,
height: 20,
color: 0x333300,
shape: 'box',
anchorX: 0,
anchorY: 0
});
energyBarBg.y = 30;
LK.gui.bottomLeft.addChild(energyBarBg);
// Energy bar
var energyBar = LK.getAsset('shape', {
width: 300,
height: 20,
color: 0xFFFF00,
shape: 'box',
anchorX: 0,
anchorY: 0
});
energyBar.y = 30;
LK.gui.bottomLeft.addChild(energyBar);
var healthText = new Text2('Health: 100', {
size: 50,
fill: 0xFF0000
});
healthText.anchor.set(0, 0);
healthText.y = 60;
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);
}
};
// Play background music
LK.playMusic('Theme');
// 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) + '%');
// Update health bar
var healthPercent = player.health / 100;
healthBar.width = 300 * healthPercent;
// Update energy bar
var energyPercent = player.batteryLife / 100;
energyBar.width = 300 * energyPercent;
// 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();
}
}; /****
* 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 = 2;
self.huntingPlayer = false;
self.lastPlayerDistance = 0;
self.patrolAngle = Math.random() * Math.PI * 2;
self.patrolSpeed = 1;
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) {
LK.showGameOver();
}
} 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.05;
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);
// Health bar background
var healthBarBg = LK.getAsset('shape', {
width: 300,
height: 20,
color: 0x330000,
shape: 'box',
anchorX: 0,
anchorY: 0
});
LK.gui.bottomLeft.addChild(healthBarBg);
// Health bar
var healthBar = LK.getAsset('shape', {
width: 300,
height: 20,
color: 0xFF0000,
shape: 'box',
anchorX: 0,
anchorY: 0
});
LK.gui.bottomLeft.addChild(healthBar);
// Energy bar background
var energyBarBg = LK.getAsset('shape', {
width: 300,
height: 20,
color: 0x333300,
shape: 'box',
anchorX: 0,
anchorY: 0
});
energyBarBg.y = 30;
LK.gui.bottomLeft.addChild(energyBarBg);
// Energy bar
var energyBar = LK.getAsset('shape', {
width: 300,
height: 20,
color: 0xFFFF00,
shape: 'box',
anchorX: 0,
anchorY: 0
});
energyBar.y = 30;
LK.gui.bottomLeft.addChild(energyBar);
var healthText = new Text2('Health: 100', {
size: 50,
fill: 0xFF0000
});
healthText.anchor.set(0, 0);
healthText.y = 60;
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);
}
};
// Play background music
LK.playMusic('Theme');
// 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) + '%');
// Update health bar
var healthPercent = player.health / 100;
healthBar.width = 300 * healthPercent;
// Update energy bar
var energyPercent = player.batteryLife / 100;
energyBar.width = 300 * energyPercent;
// 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();
}
};
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