User prompt
que no dispare solo
User prompt
que los ataques de fuego tengan un limite
User prompt
solo un cubo
User prompt
que el fondo sea un cubo
Code edit (1 edits merged)
Please save this source code
User prompt
Shadow Fighter: Light vs Dark
Initial prompt
crea un juego de un personage que tiene que luchar contra sombras utilizando luz y fuego junto a los movimientos vase
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var FireSpell = Container.expand(function () {
var self = Container.call(this);
var spellGraphics = self.attachAsset('fireSpell', {
anchorX: 0.5,
anchorY: 0.5
});
self.lifetime = 30; // Half second
self.radius = 80;
self.update = function () {
self.lifetime--;
// Grow the spell
var scale = 1 + (30 - self.lifetime) / 30;
spellGraphics.scaleX = scale;
spellGraphics.scaleY = scale;
spellGraphics.alpha = self.lifetime / 30;
};
return self;
});
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.attachAsset('hero', {
anchorX: 0.5,
anchorY: 0.5
});
self.lightPower = 1;
self.fireRate = 60; // Fire every 60 ticks initially
self.lastLightShot = 0;
self.update = function () {
// Auto-fire light projectiles
if (LK.ticks - self.lastLightShot >= self.fireRate) {
if (shadows.length > 0) {
var closestShadow = shadows[0];
var closestDistance = Math.sqrt(Math.pow(closestShadow.x - self.x, 2) + Math.pow(closestShadow.y - self.y, 2));
for (var i = 1; i < shadows.length; i++) {
var distance = Math.sqrt(Math.pow(shadows[i].x - self.x, 2) + Math.pow(shadows[i].y - self.y, 2));
if (distance < closestDistance) {
closestDistance = distance;
closestShadow = shadows[i];
}
}
if (closestDistance < 400) {
var newProjectile = new LightProjectile();
newProjectile.x = self.x;
newProjectile.y = self.y;
var angle = Math.atan2(closestShadow.y - self.y, closestShadow.x - self.x);
newProjectile.velocityX = Math.cos(angle) * 8;
newProjectile.velocityY = Math.sin(angle) * 8;
lightProjectiles.push(newProjectile);
game.addChild(newProjectile);
LK.getSound('lightShoot').play();
}
self.lastLightShot = LK.ticks;
}
}
};
return self;
});
var LightOrb = Container.expand(function () {
var self = Container.call(this);
var orbGraphics = self.attachAsset('lightOrb', {
anchorX: 0.5,
anchorY: 0.5
});
self.bobOffset = Math.random() * Math.PI * 2;
self.baseY = self.y;
self.update = function () {
self.y = self.baseY + Math.sin(LK.ticks * 0.1 + self.bobOffset) * 10;
};
return self;
});
var LightProjectile = Container.expand(function () {
var self = Container.call(this);
var projectileGraphics = self.attachAsset('lightProjectile', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = 0;
self.velocityY = 0;
self.lifetime = 180; // 3 seconds at 60fps
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.lifetime--;
};
return self;
});
var Shadow = Container.expand(function () {
var self = Container.call(this);
var shadowGraphics = self.attachAsset('shadow', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1 + Math.random() * 2;
self.health = 1;
self.update = function () {
var angle = Math.atan2(hero.y - self.y, hero.x - self.x);
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Create single cube background
var cube = LK.getAsset('cube', {
anchorX: 0.5,
anchorY: 0.5
});
cube.x = 1024;
cube.y = 1366;
game.addChild(cube);
var hero = game.addChild(new Hero());
hero.x = 1024;
hero.y = 1366;
var shadows = [];
var lightProjectiles = [];
var fireSpells = [];
var lightOrbs = [];
var lastShadowSpawn = 0;
var shadowSpawnRate = 120; // Start spawning every 2 seconds
var waveLevel = 1;
var score = 0;
var lastFireSpell = 0;
var fireSpellCooldown = 90; // 1.5 seconds cooldown at 60fps
var maxActiveFireSpells = 3;
var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var dragNode = null;
function handleMove(x, y, obj) {
if (dragNode) {
dragNode.x = x;
dragNode.y = y;
// Keep hero within bounds
if (dragNode.x < 40) dragNode.x = 40;
if (dragNode.x > 2008) dragNode.x = 2008;
if (dragNode.y < 40) dragNode.y = 40;
if (dragNode.y > 2692) dragNode.y = 2692;
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
// Check if touching hero
var heroDistance = Math.sqrt(Math.pow(x - hero.x, 2) + Math.pow(y - hero.y, 2));
if (heroDistance < 60) {
dragNode = hero;
handleMove(x, y, obj);
} else {
// Fire spell at touch location - check cooldown and limit
var timeSinceLastFire = LK.ticks - lastFireSpell;
if (timeSinceLastFire >= fireSpellCooldown && fireSpells.length < maxActiveFireSpells) {
var newFireSpell = new FireSpell();
newFireSpell.x = x;
newFireSpell.y = y;
fireSpells.push(newFireSpell);
game.addChild(newFireSpell);
lastFireSpell = LK.ticks;
LK.getSound('fireBlast').play();
}
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
game.update = function () {
// Spawn shadows
if (LK.ticks - lastShadowSpawn >= shadowSpawnRate) {
var newShadow = new Shadow();
// Spawn from random edge
var edge = Math.floor(Math.random() * 4);
switch (edge) {
case 0:
// Top
newShadow.x = Math.random() * 2048;
newShadow.y = -30;
break;
case 1:
// Right
newShadow.x = 2078;
newShadow.y = Math.random() * 2732;
break;
case 2:
// Bottom
newShadow.x = Math.random() * 2048;
newShadow.y = 2762;
break;
case 3:
// Left
newShadow.x = -30;
newShadow.y = Math.random() * 2732;
break;
}
newShadow.speed += waveLevel * 0.5;
shadows.push(newShadow);
game.addChild(newShadow);
lastShadowSpawn = LK.ticks;
}
// Check hero collision with shadows
for (var i = 0; i < shadows.length; i++) {
if (hero.intersects(shadows[i])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
}
// Update and check light projectiles
for (var j = lightProjectiles.length - 1; j >= 0; j--) {
var projectile = lightProjectiles[j];
if (projectile.lifetime <= 0 || projectile.x < -50 || projectile.x > 2098 || projectile.y < -50 || projectile.y > 2782) {
projectile.destroy();
lightProjectiles.splice(j, 1);
continue;
}
// Check collision with shadows
for (var k = shadows.length - 1; k >= 0; k--) {
if (projectile.intersects(shadows[k])) {
// Create light orb
var newOrb = new LightOrb();
newOrb.x = shadows[k].x;
newOrb.y = shadows[k].y;
newOrb.baseY = newOrb.y;
lightOrbs.push(newOrb);
game.addChild(newOrb);
shadows[k].destroy();
shadows.splice(k, 1);
projectile.destroy();
lightProjectiles.splice(j, 1);
score += 10;
scoreTxt.setText('Score: ' + score);
LK.getSound('shadowDestroy').play();
break;
}
}
}
// Update and check fire spells
for (var l = fireSpells.length - 1; l >= 0; l--) {
var spell = fireSpells[l];
if (spell.lifetime <= 0) {
spell.destroy();
fireSpells.splice(l, 1);
continue;
}
// Check collision with shadows
for (var m = shadows.length - 1; m >= 0; m--) {
var distance = Math.sqrt(Math.pow(spell.x - shadows[m].x, 2) + Math.pow(spell.y - shadows[m].y, 2));
if (distance < spell.radius) {
// Create light orb
var newOrb = new LightOrb();
newOrb.x = shadows[m].x;
newOrb.y = shadows[m].y;
newOrb.baseY = newOrb.y;
lightOrbs.push(newOrb);
game.addChild(newOrb);
shadows[m].destroy();
shadows.splice(m, 1);
score += 15;
scoreTxt.setText('Score: ' + score);
LK.getSound('shadowDestroy').play();
}
}
}
// Check light orb collection
for (var n = lightOrbs.length - 1; n >= 0; n--) {
var orb = lightOrbs[n];
if (hero.intersects(orb)) {
hero.lightPower++;
if (hero.fireRate > 20) {
hero.fireRate -= 2;
}
orb.destroy();
lightOrbs.splice(n, 1);
LK.getSound('collectOrb').play();
// Flash hero with light effect
LK.effects.flashObject(hero, 0xffffaa, 500);
}
}
// Increase difficulty over time
if (LK.ticks % 1800 === 0) {
// Every 30 seconds
waveLevel++;
if (shadowSpawnRate > 30) {
shadowSpawnRate -= 10;
}
}
// Victory condition
if (score >= 500) {
LK.showYouWin();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -136,8 +136,11 @@
var lastShadowSpawn = 0;
var shadowSpawnRate = 120; // Start spawning every 2 seconds
var waveLevel = 1;
var score = 0;
+var lastFireSpell = 0;
+var fireSpellCooldown = 90; // 1.5 seconds cooldown at 60fps
+var maxActiveFireSpells = 3;
var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
@@ -162,15 +165,19 @@
if (heroDistance < 60) {
dragNode = hero;
handleMove(x, y, obj);
} else {
- // Fire spell at touch location
- var newFireSpell = new FireSpell();
- newFireSpell.x = x;
- newFireSpell.y = y;
- fireSpells.push(newFireSpell);
- game.addChild(newFireSpell);
- LK.getSound('fireBlast').play();
+ // Fire spell at touch location - check cooldown and limit
+ var timeSinceLastFire = LK.ticks - lastFireSpell;
+ if (timeSinceLastFire >= fireSpellCooldown && fireSpells.length < maxActiveFireSpells) {
+ var newFireSpell = new FireSpell();
+ newFireSpell.x = x;
+ newFireSpell.y = y;
+ fireSpells.push(newFireSpell);
+ game.addChild(newFireSpell);
+ lastFireSpell = LK.ticks;
+ LK.getSound('fireBlast').play();
+ }
}
};
game.up = function (x, y, obj) {
dragNode = null;
bola de fuego de pixeles. In-Game asset. 2d. High contrast. No shadows
monstruo de slime negro de pixeles. In-Game asset. 2d. High contrast. No shadows
suelo de sesped oscuro de pixeles. In-Game asset. 2d. High contrast. No shadows
bola de luz de pixeles. In-Game asset. 2d. High contrast. No shadows
sombra de pixeles que de miedo. In-Game asset. 2d. High contrast. No shadows
portal de pixeles de luz. In-Game asset. 2d. High contrast. No shadows
angel en forma de ojo de pixeles. In-Game asset. 2d. High contrast. No shadows
que ahora tenga una exprecion de determinacion
fuego negro de pixeles. In-Game asset. 2d. High contrast. No shadows
bola de luz azul de pixeles. In-Game asset. 2d. High contrast. No shadows
la muerte de pixeles. In-Game asset. 2d. High contrast. No shadows
orbe oscuro de pixeles con cara enojada. In-Game asset. 2d. High contrast. No shadows
berserquer de pixeles. In-Game asset. 2d. High contrast. No shadows
sombra mimica de pixeles. In-Game asset. 2d. High contrast. No shadows
casa de madera con barricadas de pixeles. In-Game asset. 2d. High contrast. No shadows
bola de hielo de pixeles. In-Game asset. 2d. High contrast. No shadows
bola de viento de pixeles. In-Game asset. 2d. High contrast. No shadows