User prompt
Aun no persiguen al player, solo se van al medio soluciona esto, y reduce esa cantidad de monstruos hay muchos, solo coloca 4 monstruos al inicio, y que al presionar los botones no se coloque ningún bloque ni objeto nada, solo en otro espacio que no sea los botones, colocale una hitbox a los botones
User prompt
Reduce el lag, en la noche uno pon 2 monstruos de bajo nivel y ya después aumentan la cantidad x2 al pasar cada noche, y que los corruptos monstruos ataquen al player
User prompt
Pero que la distancia de los botones entre si sea más grande
User prompt
Los botones hazlos un poco más grandes
User prompt
Pero los botones colocalos hacia la parte izquierda por la esquina de abajo
User prompt
Crea 4 botones, el botón de arriba, abajo, izquierda y derecha, que cada botón te permita moverte a esa dirección, estos botones aparecerán cuando se elija al inicio la opción móvil
User prompt
Mete un jefe terrorífico pero no tanto que cada 10 segundos invoque un zombi y que el muñeco principal tenga una pistola qué mate los zombis y que con 20 disparos mate al jefe
User prompt
Has que al inicio al entrar, el lobby, pregunte sobre en que plataforma estas? Y que haigan dos botones (móvil) y (pc) móvil para celulares y pc para computadoras, crea botones para los jugadores de teléfonos y para computadoras ya tu sabes
User prompt
Agrega botones para celulares
Code edit (1 edits merged)
Please save this source code
User prompt
Corrupted Nightfall
User prompt
Que haiga monstruos corruptos y que aparezcan en la noche, que sean morados, y que cada día aparezcan más y más, claro los monstruos tienen sus variedades de corruptos
Initial prompt
El proyecto trata sobre unos personajes que iban en un avión y se estrellaron, esta es una cinemática, después el personaje despierta otra cinemática, y aquí inicia nuestra aventura, es un survival 2d, donde te puedes mover hacia arriba, abajo, izquierda y derecha, pero saltar no se puede, hay armas, aldeas y una variedad de cosas, mundo abierto
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Boss = Container.expand(function () {
var self = Container.call(this);
var bossGraphics = self.attachAsset('corruptedTank', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.5,
scaleY: 2.5
});
bossGraphics.tint = 0x4a0080; // Darker purple for boss
self.health = 20;
self.maxHealth = 20;
self.speed = 0.5;
self.damage = 30;
self.type = 'boss';
self.spawnTimer = 0;
self.targetX = 1024;
self.targetY = 1366;
self.update = function () {
// Boss movement
var dx = self.targetX - self.x;
var dy = self.targetY - 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;
}
// Spawn zombies every 10 seconds (600 frames at 60fps)
self.spawnTimer++;
if (self.spawnTimer >= 600) {
self.spawnTimer = 0;
// Spawn a zombie near the boss
var zombie = new CorruptedScout();
zombie.x = self.x + (Math.random() - 0.5) * 200;
zombie.y = self.y + (Math.random() - 0.5) * 200;
zombie.health = 15; // Weaker zombies
monsters.push(zombie);
game.addChild(zombie);
}
};
self.takeDamage = function (damage) {
self.health -= damage;
LK.effects.flashObject(self, 0xff0000, 200);
if (self.health <= 0) {
return true;
}
return false;
};
return self;
});
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('resource', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
bulletGraphics.tint = 0xffff00; // Yellow bullets
self.speed = 8;
self.damage = 1;
self.type = 'bullet';
self.direction = {
x: 0,
y: 0
};
self.update = function () {
self.x += self.direction.x * self.speed;
self.y += self.direction.y * self.speed;
// Remove bullet if it goes off screen
if (self.x < -50 || self.x > 2098 || self.y < -50 || self.y > 2782) {
self.destroy();
for (var i = bullets.length - 1; i >= 0; i--) {
if (bullets[i] === self) {
bullets.splice(i, 1);
break;
}
}
}
};
return self;
});
var CorruptedScout = Container.expand(function () {
var self = Container.call(this);
var scoutGraphics = self.attachAsset('corruptedScout', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 30;
self.maxHealth = 30;
self.speed = 2;
self.damage = 10;
self.type = 'scout';
self.targetX = 1024;
self.targetY = 1366;
self.update = function () {
var dx = self.targetX - self.x;
var dy = self.targetY - 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;
}
};
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health <= 0) {
return true;
}
return false;
};
return self;
});
var CorruptedSwarm = Container.expand(function () {
var self = Container.call(this);
var swarmGraphics = self.attachAsset('corruptedSwarm', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 15;
self.maxHealth = 15;
self.speed = 3;
self.damage = 5;
self.type = 'swarm';
self.targetX = 1024;
self.targetY = 1366;
self.update = function () {
var dx = self.targetX - self.x;
var dy = self.targetY - 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;
}
};
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health <= 0) {
return true;
}
return false;
};
return self;
});
var CorruptedTank = Container.expand(function () {
var self = Container.call(this);
var tankGraphics = self.attachAsset('corruptedTank', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 100;
self.maxHealth = 100;
self.speed = 1;
self.damage = 25;
self.type = 'tank';
self.targetX = 1024;
self.targetY = 1366;
self.update = function () {
var dx = self.targetX - self.x;
var dy = self.targetY - 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;
}
};
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health <= 0) {
return true;
}
return false;
};
return self;
});
var Resource = Container.expand(function () {
var self = Container.call(this);
var resourceGraphics = self.attachAsset('resource', {
anchorX: 0.5,
anchorY: 0.5
});
self.value = 10;
self.type = 'resource';
self.update = function () {
self.rotation += 0.05;
};
return self;
});
var Trap = Container.expand(function () {
var self = Container.call(this);
var trapGraphics = self.attachAsset('trap', {
anchorX: 0.5,
anchorY: 0.5
});
self.damage = 30;
self.cooldown = 0;
self.type = 'trap';
self.update = function () {
if (self.cooldown > 0) {
self.cooldown--;
}
};
self.activate = function () {
if (self.cooldown <= 0) {
self.cooldown = 60;
LK.effects.flashObject(self, 0xff6b35, 300);
return self.damage;
}
return 0;
};
return self;
});
var Wall = Container.expand(function () {
var self = Container.call(this);
var wallGraphics = self.attachAsset('wall', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 100;
self.maxHealth = 100;
self.type = 'wall';
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health <= 0) {
self.health = 0;
wallGraphics.alpha = 0.3;
} else {
wallGraphics.alpha = 0.5 + self.health / self.maxHealth * 0.5;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a2e
});
/****
* Game Code
****/
var gameState = 'platform_select'; // Start with platform selection
var platform = null; // Will be 'mobile' or 'pc'
var currentNight = 0;
var dayTimer = 1800; // 30 seconds at 60fps
var nightTimer = 0;
var playerHealth = 100;
var playerResources = 50;
var selectedDefense = 'wall';
var walls = [];
var traps = [];
var resources = [];
var monsters = [];
var boss = null;
var bullets = [];
var playerPistol = true; // Player has pistol
var player = game.addChild(LK.getAsset('player', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
}));
// UI Elements
var gameStateText = new Text2('Day Phase', {
size: 80,
fill: 0xFFFFFF
});
gameStateText.anchor.set(0.5, 0);
LK.gui.top.addChild(gameStateText);
var timerText = new Text2('30s', {
size: 60,
fill: 0xFFFF00
});
timerText.anchor.set(0.5, 0);
timerText.y = 100;
LK.gui.top.addChild(timerText);
var healthText = new Text2('Health: 100', {
size: 50,
fill: 0xFF0000
});
healthText.anchor.set(0, 0);
LK.gui.topLeft.addChild(healthText);
healthText.x = 120;
var resourceText = new Text2('Resources: 50', {
size: 50,
fill: 0xFFD700
});
resourceText.anchor.set(0, 0);
resourceText.y = 60;
LK.gui.topLeft.addChild(resourceText);
resourceText.x = 120;
var nightText = new Text2('Night: 0', {
size: 50,
fill: 0x8B3A8B
});
nightText.anchor.set(1, 0);
LK.gui.topRight.addChild(nightText);
// Platform selection UI
var platformTitle = new Text2('Select Your Platform', {
size: 100,
fill: 0xFFFFFF
});
platformTitle.anchor.set(0.5, 0.5);
platformTitle.x = 0;
platformTitle.y = -200;
LK.gui.center.addChild(platformTitle);
var mobileButton = LK.getAsset('player', {
anchorX: 0.5,
anchorY: 0.5,
x: -200,
y: 0,
scaleX: 2,
scaleY: 2
});
LK.gui.center.addChild(mobileButton);
var pcButton = LK.getAsset('player', {
anchorX: 0.5,
anchorY: 0.5,
x: 200,
y: 0,
scaleX: 2,
scaleY: 2
});
LK.gui.center.addChild(pcButton);
var mobileText = new Text2('MOBILE', {
size: 80,
fill: 0x00FF00
});
mobileText.anchor.set(0.5, 0.5);
mobileText.x = -200;
mobileText.y = 120;
LK.gui.center.addChild(mobileText);
var pcText = new Text2('PC', {
size: 80,
fill: 0x00FF00
});
pcText.anchor.set(0.5, 0.5);
pcText.x = 200;
pcText.y = 120;
LK.gui.center.addChild(pcText);
var instructionText = new Text2('Choose your platform to optimize controls', {
size: 50,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0.5);
instructionText.x = 0;
instructionText.y = 250;
LK.gui.center.addChild(instructionText);
var defenseText = new Text2('Defense: Wall (Cost: 10)', {
size: 40,
fill: 0xFFFFFF
});
defenseText.anchor.set(0.5, 1);
defenseText.y = -120;
defenseText.alpha = 0;
LK.gui.bottom.addChild(defenseText);
// Mobile UI Buttons (initially hidden)
var wallButton = LK.getAsset('wall', {
anchorX: 0.5,
anchorY: 0.5,
x: -150,
y: -60,
scaleX: 1.2,
scaleY: 1.2
});
wallButton.alpha = 0;
LK.gui.bottom.addChild(wallButton);
var trapButton = LK.getAsset('trap', {
anchorX: 0.5,
anchorY: 0.5,
x: -50,
y: -60,
scaleX: 1.2,
scaleY: 1.2
});
trapButton.alpha = 0;
LK.gui.bottom.addChild(trapButton);
var collectButton = LK.getAsset('resource', {
anchorX: 0.5,
anchorY: 0.5,
x: 50,
y: -60,
scaleX: 1.2,
scaleY: 1.2
});
collectButton.alpha = 0;
LK.gui.bottom.addChild(collectButton);
var wallButtonText = new Text2('Wall\n10R', {
size: 30,
fill: 0xFFFFFF
});
wallButtonText.anchor.set(0.5, 0.5);
wallButtonText.x = -150;
wallButtonText.y = -10;
wallButtonText.alpha = 0;
LK.gui.bottom.addChild(wallButtonText);
var trapButtonText = new Text2('Trap\n15R', {
size: 30,
fill: 0xFFFFFF
});
trapButtonText.anchor.set(0.5, 0.5);
trapButtonText.x = -50;
trapButtonText.y = -10;
trapButtonText.alpha = 0;
LK.gui.bottom.addChild(trapButtonText);
var collectButtonText = new Text2('Collect\nMode', {
size: 30,
fill: 0xFFFFFF
});
collectButtonText.anchor.set(0.5, 0.5);
collectButtonText.x = 50;
collectButtonText.y = -10;
collectButtonText.alpha = 0;
LK.gui.bottom.addChild(collectButtonText);
// Button selection indicator
var buttonIndicator = LK.getAsset('wall', {
anchorX: 0.5,
anchorY: 0.5,
x: -150,
y: -60,
scaleX: 1.5,
scaleY: 1.5
});
buttonIndicator.alpha = 0;
LK.gui.bottom.addChild(buttonIndicator);
// Mobile movement buttons (initially hidden) - positioned in bottom-left corner
var upButton = LK.getAsset('moveButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 120,
y: -200
});
upButton.alpha = 0;
LK.gui.bottomLeft.addChild(upButton);
var downButton = LK.getAsset('moveButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 120,
y: -80
});
downButton.alpha = 0;
LK.gui.bottomLeft.addChild(downButton);
var leftButton = LK.getAsset('moveButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 60,
y: -140
});
leftButton.alpha = 0;
LK.gui.bottomLeft.addChild(leftButton);
var rightButton = LK.getAsset('moveButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 180,
y: -140
});
rightButton.alpha = 0;
LK.gui.bottomLeft.addChild(rightButton);
// Movement button text labels
var upButtonText = new Text2('↑', {
size: 60,
fill: 0xFFFFFF
});
upButtonText.anchor.set(0.5, 0.5);
upButtonText.x = 120;
upButtonText.y = -200;
upButtonText.alpha = 0;
LK.gui.bottomLeft.addChild(upButtonText);
var downButtonText = new Text2('↓', {
size: 60,
fill: 0xFFFFFF
});
downButtonText.anchor.set(0.5, 0.5);
downButtonText.x = 120;
downButtonText.y = -80;
downButtonText.alpha = 0;
LK.gui.bottomLeft.addChild(downButtonText);
var leftButtonText = new Text2('←', {
size: 60,
fill: 0xFFFFFF
});
leftButtonText.anchor.set(0.5, 0.5);
leftButtonText.x = 60;
leftButtonText.y = -140;
leftButtonText.alpha = 0;
LK.gui.bottomLeft.addChild(leftButtonText);
var rightButtonText = new Text2('→', {
size: 60,
fill: 0xFFFFFF
});
rightButtonText.anchor.set(0.5, 0.5);
rightButtonText.x = 180;
rightButtonText.y = -140;
rightButtonText.alpha = 0;
LK.gui.bottomLeft.addChild(rightButtonText);
// Game mode state
var gameMode = 'build'; // 'build' or 'collect'
// Spawn initial resources
for (var i = 0; i < 8; i++) {
var resource = new Resource();
resource.x = 200 + Math.random() * 1648;
resource.y = 200 + Math.random() * 1200;
resources.push(resource);
game.addChild(resource);
}
function spawnMonster(type) {
var monster;
switch (type) {
case 'scout':
monster = new CorruptedScout();
break;
case 'tank':
monster = new CorruptedTank();
break;
case 'swarm':
monster = new CorruptedSwarm();
break;
default:
monster = new CorruptedScout();
}
// Spawn from edges
var side = Math.floor(Math.random() * 4);
switch (side) {
case 0:
// Top
monster.x = Math.random() * 2048;
monster.y = -50;
break;
case 1:
// Right
monster.x = 2098;
monster.y = Math.random() * 2732;
break;
case 2:
// Bottom
monster.x = Math.random() * 2048;
monster.y = 2782;
break;
case 3:
// Left
monster.x = -50;
monster.y = Math.random() * 2732;
break;
}
monsters.push(monster);
game.addChild(monster);
}
function switchToNight() {
gameState = 'night';
currentNight++;
nightTimer = 1800; // 30 seconds
gameStateText.setText('Night ' + currentNight);
timerText.setText('30s');
nightText.setText('Night: ' + currentNight);
game.setBackgroundColor(0x0f0f23);
LK.playMusic('nightfall');
// Hide UI buttons during night
wallButton.alpha = 0.3;
trapButton.alpha = 0.3;
collectButton.alpha = 0.3;
buttonIndicator.alpha = 0.1;
defenseText.setText('Night Phase - Survive!');
// Spawn boss every 3rd night
if (currentNight % 3 === 0 && boss === null) {
boss = new Boss();
// Spawn boss from a random edge
var side = Math.floor(Math.random() * 4);
switch (side) {
case 0:
// Top
boss.x = Math.random() * 2048;
boss.y = -100;
break;
case 1:
// Right
boss.x = 2148;
boss.y = Math.random() * 2732;
break;
case 2:
// Bottom
boss.x = Math.random() * 2048;
boss.y = 2832;
break;
case 3:
// Left
boss.x = -100;
boss.y = Math.random() * 2732;
break;
}
game.addChild(boss);
}
}
function switchToDay() {
gameState = 'day';
dayTimer = 1800; // 30 seconds
gameStateText.setText('Day Phase');
timerText.setText('30s');
game.setBackgroundColor(0x1a1a2e);
LK.stopMusic();
// Show UI buttons during day
wallButton.alpha = 1.0;
trapButton.alpha = 1.0;
collectButton.alpha = 1.0;
buttonIndicator.alpha = 0.3;
// Reset to default mode
gameMode = 'build';
selectedDefense = 'wall';
defenseText.setText('Defense: Wall (Cost: 10)');
buttonIndicator.x = -150;
wallButtonText.tint = 0x00FF00;
trapButtonText.tint = 0xFFFFFF;
collectButtonText.tint = 0xFFFFFF;
// Spawn new resources
for (var i = 0; i < 3; i++) {
var resource = new Resource();
resource.x = 200 + Math.random() * 1648;
resource.y = 200 + Math.random() * 1200;
resources.push(resource);
game.addChild(resource);
}
}
// Platform selection button handlers
mobileButton.down = function (x, y, obj) {
if (gameState === 'platform_select') {
platform = 'mobile';
startGame();
}
};
pcButton.down = function (x, y, obj) {
if (gameState === 'platform_select') {
platform = 'pc';
startGame();
}
};
function startGame() {
// Hide platform selection UI
platformTitle.alpha = 0;
mobileButton.alpha = 0;
pcButton.alpha = 0;
mobileText.alpha = 0;
pcText.alpha = 0;
instructionText.alpha = 0;
// Configure UI based on platform
if (platform === 'mobile') {
// Show mobile UI buttons
wallButton.alpha = 1.0;
trapButton.alpha = 1.0;
collectButton.alpha = 1.0;
buttonIndicator.alpha = 0.3;
wallButtonText.alpha = 1.0;
trapButtonText.alpha = 1.0;
collectButtonText.alpha = 1.0;
defenseText.alpha = 1.0;
// Show movement buttons
upButton.alpha = 1.0;
downButton.alpha = 1.0;
leftButton.alpha = 1.0;
rightButton.alpha = 1.0;
upButtonText.alpha = 1.0;
downButtonText.alpha = 1.0;
leftButtonText.alpha = 1.0;
rightButtonText.alpha = 1.0;
} else {
// Hide mobile UI buttons for PC
wallButton.alpha = 0;
trapButton.alpha = 0;
collectButton.alpha = 0;
buttonIndicator.alpha = 0;
wallButtonText.alpha = 0;
trapButtonText.alpha = 0;
collectButtonText.alpha = 0;
defenseText.setText('Use keyboard: W=Wall, T=Trap, C=Collect');
// Hide movement buttons
upButton.alpha = 0;
downButton.alpha = 0;
leftButton.alpha = 0;
rightButton.alpha = 0;
upButtonText.alpha = 0;
downButtonText.alpha = 0;
leftButtonText.alpha = 0;
rightButtonText.alpha = 0;
}
// Start the game
gameState = 'day';
}
// Button event handlers
wallButton.down = function (x, y, obj) {
if (gameState === 'day') {
selectedDefense = 'wall';
gameMode = 'build';
defenseText.setText('Defense: Wall (Cost: 10)');
buttonIndicator.x = -150;
wallButtonText.tint = 0x00FF00;
trapButtonText.tint = 0xFFFFFF;
collectButtonText.tint = 0xFFFFFF;
}
};
trapButton.down = function (x, y, obj) {
if (gameState === 'day') {
selectedDefense = 'trap';
gameMode = 'build';
defenseText.setText('Defense: Trap (Cost: 15)');
buttonIndicator.x = -50;
wallButtonText.tint = 0xFFFFFF;
trapButtonText.tint = 0x00FF00;
collectButtonText.tint = 0xFFFFFF;
}
};
collectButton.down = function (x, y, obj) {
if (gameState === 'day') {
gameMode = 'collect';
defenseText.setText('Mode: Resource Collection');
buttonIndicator.x = 50;
wallButtonText.tint = 0xFFFFFF;
trapButtonText.tint = 0xFFFFFF;
collectButtonText.tint = 0x00FF00;
}
};
// Movement button event handlers
upButton.down = function (x, y, obj) {
if (gameState !== 'platform_select') {
player.y = Math.max(50, player.y - 30);
}
};
downButton.down = function (x, y, obj) {
if (gameState !== 'platform_select') {
player.y = Math.min(2682, player.y + 30);
}
};
leftButton.down = function (x, y, obj) {
if (gameState !== 'platform_select') {
player.x = Math.max(50, player.x - 30);
}
};
rightButton.down = function (x, y, obj) {
if (gameState !== 'platform_select') {
player.x = Math.min(1998, player.x + 30);
}
};
game.down = function (x, y, obj) {
if (gameState === 'platform_select') {
return; // Don't allow interaction during platform selection
}
if (gameState === 'day') {
if (gameMode === 'build') {
var cost = selectedDefense === 'wall' ? 10 : 15;
if (playerResources >= cost) {
var defense;
if (selectedDefense === 'wall') {
defense = new Wall();
} else {
defense = new Trap();
}
defense.x = x;
defense.y = y;
if (selectedDefense === 'wall') {
walls.push(defense);
} else {
traps.push(defense);
}
game.addChild(defense);
playerResources -= cost;
resourceText.setText('Resources: ' + playerResources);
LK.getSound('build').play();
}
} else if (gameMode === 'collect') {
// Enhanced resource collection in collect mode
for (var i = resources.length - 1; i >= 0; i--) {
var resource = resources[i];
var dx = x - resource.x;
var dy = y - resource.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 100) {
playerResources += resource.value;
resourceText.setText('Resources: ' + playerResources);
resource.destroy();
resources.splice(i, 1);
LK.getSound('collect').play();
break;
}
}
}
} else if (gameState === 'night' && playerPistol) {
// Shoot bullet towards click position
var bullet = new Bullet();
bullet.x = player.x;
bullet.y = player.y;
// Calculate direction to target
var dx = x - player.x;
var dy = y - player.y;
var distance = Math.sqrt(dx * dx + dy * dy);
bullet.direction.x = dx / distance;
bullet.direction.y = dy / distance;
bullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
}
};
game.up = function (x, y, obj) {
// Button visibility is now handled by the UI buttons
};
game.update = function () {
if (gameState === 'platform_select') {
return; // Don't update game during platform selection
}
if (gameState === 'day') {
dayTimer--;
timerText.setText(Math.ceil(dayTimer / 60) + 's');
if (dayTimer <= 0) {
switchToNight();
}
// Resource collection
for (var i = resources.length - 1; i >= 0; i--) {
var resource = resources[i];
var dx = player.x - resource.x;
var dy = player.y - resource.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 60) {
playerResources += resource.value;
resourceText.setText('Resources: ' + playerResources);
resource.destroy();
resources.splice(i, 1);
LK.getSound('collect').play();
}
}
} else if (gameState === 'night') {
nightTimer--;
timerText.setText(Math.ceil(nightTimer / 60) + 's');
// Spawn monsters
var spawnRate = Math.max(5, 30 - currentNight * 2);
if (LK.ticks % spawnRate === 0) {
var monsterTypes = ['scout', 'tank', 'swarm'];
var type = monsterTypes[Math.floor(Math.random() * monsterTypes.length)];
spawnMonster(type);
}
// Monster AI and collision
for (var i = monsters.length - 1; i >= 0; i--) {
var monster = monsters[i];
// Check collision with player
var dx = player.x - monster.x;
var dy = player.y - monster.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 50) {
playerHealth -= monster.damage;
healthText.setText('Health: ' + playerHealth);
monster.destroy();
monsters.splice(i, 1);
LK.getSound('damage').play();
if (playerHealth <= 0) {
LK.showGameOver();
}
continue;
}
// Check collision with walls
var hitWall = false;
for (var j = 0; j < walls.length; j++) {
var wall = walls[j];
if (wall.health > 0 && monster.intersects(wall)) {
wall.takeDamage(monster.damage);
monster.destroy();
monsters.splice(i, 1);
hitWall = true;
break;
}
}
if (hitWall) continue;
// Check collision with traps
for (var k = 0; k < traps.length; k++) {
var trap = traps[k];
if (monster.intersects(trap)) {
var trapDamage = trap.activate();
if (trapDamage > 0) {
var isDead = monster.takeDamage(trapDamage);
if (isDead) {
LK.setScore(LK.getScore() + 10);
monster.destroy();
monsters.splice(i, 1);
break;
}
}
}
}
}
// Handle boss combat
if (boss !== null) {
// Check collision with player
var dx = player.x - boss.x;
var dy = player.y - boss.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 80) {
playerHealth -= boss.damage;
healthText.setText('Health: ' + playerHealth);
LK.getSound('damage').play();
if (playerHealth <= 0) {
LK.showGameOver();
}
// Push player away from boss
var pushDistance = 100;
var pushX = dx / distance * pushDistance;
var pushY = dy / distance * pushDistance;
player.x = Math.max(50, Math.min(1998, player.x + pushX));
player.y = Math.max(50, Math.min(2682, player.y + pushY));
}
}
// Handle bullet collisions
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
var bulletHit = false;
// Check collision with monsters
for (var j = monsters.length - 1; j >= 0; j--) {
var monster = monsters[j];
var dx = bullet.x - monster.x;
var dy = bullet.y - monster.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 30) {
var isDead = monster.takeDamage(bullet.damage);
if (isDead) {
LK.setScore(LK.getScore() + 10);
monster.destroy();
monsters.splice(j, 1);
}
bullet.destroy();
bullets.splice(i, 1);
bulletHit = true;
break;
}
}
// Check collision with boss
if (!bulletHit && boss !== null) {
var dx = bullet.x - boss.x;
var dy = bullet.y - boss.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 60) {
var isBossDead = boss.takeDamage(bullet.damage);
if (isBossDead) {
LK.setScore(LK.getScore() + 100);
boss.destroy();
boss = null;
LK.effects.flashScreen(0x00ff00, 500); // Green flash for boss kill
}
bullet.destroy();
bullets.splice(i, 1);
}
}
}
if (nightTimer <= 0) {
// Clear remaining monsters
for (var m = monsters.length - 1; m >= 0; m--) {
monsters[m].destroy();
monsters.splice(m, 1);
}
// Clear remaining bullets
for (var b = bullets.length - 1; b >= 0; b--) {
bullets[b].destroy();
bullets.splice(b, 1);
}
// Clear boss if exists
if (boss !== null) {
boss.destroy();
boss = null;
}
switchToDay();
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -432,78 +432,78 @@
scaleY: 1.5
});
buttonIndicator.alpha = 0;
LK.gui.bottom.addChild(buttonIndicator);
-// Mobile movement buttons (initially hidden)
+// Mobile movement buttons (initially hidden) - positioned in bottom-left corner
var upButton = LK.getAsset('moveButton', {
anchorX: 0.5,
anchorY: 0.5,
- x: 0,
+ x: 120,
y: -200
});
upButton.alpha = 0;
-LK.gui.right.addChild(upButton);
+LK.gui.bottomLeft.addChild(upButton);
var downButton = LK.getAsset('moveButton', {
anchorX: 0.5,
anchorY: 0.5,
- x: 0,
- y: 200
+ x: 120,
+ y: -80
});
downButton.alpha = 0;
-LK.gui.right.addChild(downButton);
+LK.gui.bottomLeft.addChild(downButton);
var leftButton = LK.getAsset('moveButton', {
anchorX: 0.5,
anchorY: 0.5,
- x: -100,
- y: 0
+ x: 60,
+ y: -140
});
leftButton.alpha = 0;
-LK.gui.right.addChild(leftButton);
+LK.gui.bottomLeft.addChild(leftButton);
var rightButton = LK.getAsset('moveButton', {
anchorX: 0.5,
anchorY: 0.5,
- x: 100,
- y: 0
+ x: 180,
+ y: -140
});
rightButton.alpha = 0;
-LK.gui.right.addChild(rightButton);
+LK.gui.bottomLeft.addChild(rightButton);
// Movement button text labels
var upButtonText = new Text2('↑', {
size: 60,
fill: 0xFFFFFF
});
upButtonText.anchor.set(0.5, 0.5);
-upButtonText.x = 0;
+upButtonText.x = 120;
upButtonText.y = -200;
upButtonText.alpha = 0;
-LK.gui.right.addChild(upButtonText);
+LK.gui.bottomLeft.addChild(upButtonText);
var downButtonText = new Text2('↓', {
size: 60,
fill: 0xFFFFFF
});
downButtonText.anchor.set(0.5, 0.5);
-downButtonText.x = 0;
-downButtonText.y = 200;
+downButtonText.x = 120;
+downButtonText.y = -80;
downButtonText.alpha = 0;
-LK.gui.right.addChild(downButtonText);
+LK.gui.bottomLeft.addChild(downButtonText);
var leftButtonText = new Text2('←', {
size: 60,
fill: 0xFFFFFF
});
leftButtonText.anchor.set(0.5, 0.5);
-leftButtonText.x = -100;
-leftButtonText.y = 0;
+leftButtonText.x = 60;
+leftButtonText.y = -140;
leftButtonText.alpha = 0;
-LK.gui.right.addChild(leftButtonText);
+LK.gui.bottomLeft.addChild(leftButtonText);
var rightButtonText = new Text2('→', {
size: 60,
fill: 0xFFFFFF
});
rightButtonText.anchor.set(0.5, 0.5);
-rightButtonText.x = 100;
-rightButtonText.y = 0;
+rightButtonText.x = 180;
+rightButtonText.y = -140;
rightButtonText.alpha = 0;
-LK.gui.right.addChild(rightButtonText);
+LK.gui.bottomLeft.addChild(rightButtonText);
// Game mode state
var gameMode = 'build'; // 'build' or 'collect'
// Spawn initial resources
for (var i = 0; i < 8; i++) {
Crea picos de madera, que todos estén unidos en una tablilla por abajo y que arriba estén los picos. In-Game asset. 2d. High contrast. No shadows
Crea un botón de color azul pixel. In-Game asset. 2d. High contrast. No shadows
Genera una imagen de lava pixel. In-Game asset. 2d. High contrast. No shadows
Genera una imagen de un guerrero pixel, sin armas, y que tenga la cabeza un poco más grande que el cuerpo tipo pixel. In-Game asset. 2d. High contrast. No shadows
Genera una imagen de un monstruo corrupto morado de piedra qué no sea tan terrorífico, y que sea pixel.Y qué tenga manos grandes, y torso y que la cabeza no sea tan terrorífico, y no le ponga ojos perturbadores, y que su cabeza sea de un tamaño moderado no muy grande, que algo que si sea grande sea sus brazos, y que tenga algas moradas y que tenga algunas piedras moradas y otras piedras que no sean moradas qué sean grises In-Game asset. 2d. High contrast. No shadows.
Genera una imagen verde solo verde oscuro. In-Game asset. 2d. High contrast. No shadows
Genera una imagen de una avispa no terroríficas, pixel y que sean moradas. Que sea corrupta In-Game asset. 2d. High contrast. No shadows
Genera una imagen de un corrupto pixel, y que no sea terrorífico y que sea morado. In-Game asset. 2d. High contrast. No shadows
Genera una imagen morado oscuro solo morado oscuro In-Game asset. 2d. High contrast. No shadows
Genera una imagen de una roca morada sonriente. In-Game asset. 2d. High contrast. No shadows
Genera una imagen de un círculo verde pixel. In-Game asset. 2d. High contrast. No shadows
Genera una imagen de un destello brillante morado pixel. In-Game asset. 2d. High contrast. No shadows
Genera una imagen de una pistola pixel. In-Game asset. 2d. High contrast. No shadows
Genera una imagen de una bala pixel. In-Game asset. 2d. High contrast. No shadows
Genera una imagen de un médico guerrero pixel, y que su cabeza sea un poco más grande que el cuerpo. Y que no tenga armas In-Game asset. 2d. High contrast. No shadows
Genera una imagen de un albañil guerrero pixel, que su cabeza sea un poco más grande que su cuerpo, y que no tenga armas. In-Game asset. 2d. High contrast. No shadows
Genera una imagen de un comerciante pixel y que su cabeza sea un poco más grande que su cuerpo. In-Game asset. 2d. High contrast. No shadows
Crea una imagen de un texto que diga "The corrupt survival" qué sea pixel y en la palabra "i" ponle una espada pixel. In-Game asset. 2d. High contrast. No shadows