User prompt
Ponle que desaparezcan después de 5 segundos los huesos y las pelotas que quedan en la pantalla ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Haz que tire más poderes distintos crea 5 o 6 más ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Chara vs Sans: Undertale Battle
Initial prompt
Crea un juego de pelea contra sans tu eres chara y tienes que pelear contra sans
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Bone = Container.expand(function () { var self = Container.call(this); var boneGraphics = self.attachAsset('bone', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.direction = 1; // 1 for right, -1 for left self.creationTime = LK.ticks; // Track when bone was created self.update = function () { self.x += self.speed * self.direction; }; return self; }); var Bullet = Container.expand(function () { var self = Container.call(this); self.bulletType = 'orange'; // 'orange' or 'blue' self.speed = 6; self.directionX = 0; self.directionY = 0; self.creationTime = LK.ticks; // Track when bullet was created var bulletGraphics; if (self.bulletType === 'orange') { bulletGraphics = self.attachAsset('orangeBullet', { anchorX: 0.5, anchorY: 0.5 }); } else { bulletGraphics = self.attachAsset('blueBullet', { anchorX: 0.5, anchorY: 0.5 }); } self.update = function () { if (self.isChasing) { // Update direction to chase chara var dx = chara.x - self.x; var dy = chara.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { self.directionX = dx / distance * 0.8; self.directionY = dy / distance * 0.8; } } if (self.gravityEffect) { // Add gravity effect self.directionY += 0.02; } self.x += self.speed * self.directionX; self.y += self.speed * self.directionY; }; return self; }); var Chara = Container.expand(function () { var self = Container.call(this); var charaGraphics = self.attachAsset('chara', { anchorX: 0.5, anchorY: 1.0 }); self.health = 100; self.maxHealth = 100; self.invulnerable = false; self.canAttack = true; self.takeDamage = function (damage) { if (!self.invulnerable) { self.health -= damage; self.invulnerable = true; // Flash red when hit LK.effects.flashObject(self, 0xff0000, 500); LK.getSound('hit').play(); // Brief invulnerability period LK.setTimeout(function () { self.invulnerable = false; }, 1000); if (self.health <= 0) { LK.showGameOver(); } } }; return self; }); var Sans = Container.expand(function () { var self = Container.call(this); var sansGraphics = self.attachAsset('sans', { anchorX: 0.5, anchorY: 1.0 }); self.health = 100; self.phase = 1; self.attackTimer = 0; self.isAttacking = false; self.update = function () { self.attackTimer++; // Trigger attack patterns based on timer if (self.attackTimer % 120 === 0 && !self.isAttacking) { self.startAttack(); } }; self.startAttack = function () { self.isAttacking = true; // Reset attack timer for next attack LK.setTimeout(function () { self.isAttacking = false; }, 2000); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Game state variables var gamePhase = 1; var attackPattern = 0; var patternTimer = 0; var survivalTime = 0; // Battle area setup var battleArea = game.addChild(LK.getAsset('battleArea', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1800 })); // Create characters var chara = game.addChild(new Chara()); chara.x = 1024; chara.y = 1750; var sans = game.addChild(new Sans()); sans.x = 1024; sans.y = 1400; // Health UI var healthBg = LK.getAsset('healthBg', { anchorX: 0.5, anchorY: 0, x: 0, y: 100 }); LK.gui.top.addChild(healthBg); var healthBar = LK.getAsset('healthBar', { anchorX: 0.5, anchorY: 0, x: 0, y: 100 }); LK.gui.top.addChild(healthBar); // Score display var scoreText = new Text2('Time: 0', { size: 80, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); LK.gui.topRight.addChild(scoreText); scoreText.x = -150; scoreText.y = 50; // Attack arrays var bones = []; var bullets = []; // Drag controls var isDragging = false; game.down = function (x, y, obj) { isDragging = true; chara.x = x; chara.y = Math.max(y, 1600); // Keep in battle area }; game.move = function (x, y, obj) { if (isDragging) { chara.x = Math.max(100, Math.min(1948, x)); // Keep within screen bounds chara.y = Math.max(1600, Math.min(2000, y)); // Keep in battle area } }; game.up = function (x, y, obj) { isDragging = false; }; // Attack pattern functions function createBoneWall() { var numBones = 5; var startY = 1500; var spacing = 80; for (var i = 0; i < numBones; i++) { var bone = new Bone(); bone.x = -100; bone.y = startY + i * spacing; bone.direction = 1; bones.push(bone); game.addChild(bone); } LK.getSound('attack').play(); } function createBulletSpiral() { var centerX = 1024; var centerY = 1500; var numBullets = 8; for (var i = 0; i < numBullets; i++) { var bullet = new Bullet(); bullet.bulletType = i % 2 === 0 ? 'orange' : 'blue'; bullet.x = centerX; bullet.y = centerY; var angle = i / numBullets * Math.PI * 2; bullet.directionX = Math.cos(angle); bullet.directionY = Math.sin(angle); bullets.push(bullet); game.addChild(bullet); } LK.getSound('attack').play(); } function createRandomBullets() { var numBullets = 6; for (var i = 0; i < numBullets; i++) { var bullet = new Bullet(); bullet.bulletType = Math.random() > 0.5 ? 'orange' : 'blue'; bullet.x = Math.random() * 1800 + 124; bullet.y = 1300; // Aim towards chara var dx = chara.x - bullet.x; var dy = chara.y - bullet.y; var distance = Math.sqrt(dx * dx + dy * dy); bullet.directionX = dx / distance; bullet.directionY = dy / distance; bullets.push(bullet); game.addChild(bullet); } LK.getSound('attack').play(); } function createBoneSlam() { // Create bones falling from top var numBones = 8; for (var i = 0; i < numBones; i++) { var bone = new Bone(); bone.x = 200 + i * 200; bone.y = 1200; bone.direction = 0; bone.speed = 0; bone.rotation = Math.PI / 2; // Horizontal bones.push(bone); game.addChild(bone); // Animate slam down with tween tween(bone, { y: 1900 }, { duration: 800, easing: tween.easeIn }); } LK.getSound('attack').play(); } function createTeleportBones() { // Sans teleports bones around the battle area var positions = [{ x: 300, y: 1600 }, { x: 700, y: 1700 }, { x: 1100, y: 1650 }, { x: 1500, y: 1750 }, { x: 1800, y: 1600 }]; for (var i = 0; i < positions.length; i++) { var bone = new Bone(); bone.x = positions[i].x; bone.y = positions[i].y; bone.direction = 0; bone.speed = 0; bone.alpha = 0; bones.push(bone); game.addChild(bone); // Fade in effect tween(bone, { alpha: 1 }, { duration: 500, easing: tween.easeOut }); } LK.getSound('attack').play(); } function createGravityWave() { // Create a wave of bullets that curve downward var numBullets = 12; var startX = 100; for (var i = 0; i < numBullets; i++) { var bullet = new Bullet(); bullet.bulletType = 'blue'; bullet.x = startX + i * 150; bullet.y = 1400; bullet.directionX = 0.3; bullet.directionY = 0.1; bullet.gravityEffect = true; bullets.push(bullet); game.addChild(bullet); } LK.getSound('attack').play(); } function createCircularTrap() { // Create a circle of bones that closes in var numBones = 16; var centerX = 1024; var centerY = 1700; var radius = 600; for (var i = 0; i < numBones; i++) { var bone = new Bone(); var angle = i / numBones * Math.PI * 2; bone.x = centerX + Math.cos(angle) * radius; bone.y = centerY + Math.sin(angle) * radius; bone.direction = 0; bone.speed = 0; bone.rotation = angle + Math.PI / 2; bones.push(bone); game.addChild(bone); // Move bones inward tween(bone, { x: centerX + Math.cos(angle) * 200, y: centerY + Math.sin(angle) * 200 }, { duration: 2000, easing: tween.easeInOut }); } LK.getSound('attack').play(); } function createBulletWave() { // Horizontal wave of bullets var numBullets = 10; for (var i = 0; i < numBullets; i++) { var bullet = new Bullet(); bullet.bulletType = i % 3 === 0 ? 'orange' : 'blue'; bullet.x = -50; bullet.y = 1500 + Math.sin(i * 0.5) * 100; bullet.directionX = 1; bullet.directionY = Math.sin(i * 0.8) * 0.3; bullet.speed = 4 + i * 0.2; bullets.push(bullet); game.addChild(bullet); } LK.getSound('attack').play(); } function createChasingBullets() { // Bullets that follow chara's position var numBullets = 4; for (var i = 0; i < numBullets; i++) { var bullet = new Bullet(); bullet.bulletType = 'orange'; bullet.x = 200 + i * 400; bullet.y = 1300; bullet.isChasing = true; bullet.speed = 2; bullets.push(bullet); game.addChild(bullet); } LK.getSound('attack').play(); } game.update = function () { survivalTime++; patternTimer++; // Update score display var timeSeconds = Math.floor(survivalTime / 60); scoreText.setText('Time: ' + timeSeconds + 's'); LK.setScore(timeSeconds); // Update health bar var healthPercent = chara.health / chara.maxHealth; healthBar.scaleX = healthPercent; // Trigger attack patterns if (patternTimer % 180 === 0) { // Every 3 seconds attackPattern = Math.floor(Math.random() * 9); switch (attackPattern) { case 0: createBoneWall(); break; case 1: createBulletSpiral(); break; case 2: createRandomBullets(); break; case 3: createBoneSlam(); break; case 4: createTeleportBones(); break; case 5: createGravityWave(); break; case 6: createCircularTrap(); break; case 7: createBulletWave(); break; case 8: createChasingBullets(); break; } } // Update and check bones for (var i = bones.length - 1; i >= 0; i--) { var bone = bones[i]; // Check collision with chara if (bone.intersects(chara)) { chara.takeDamage(20); } // Remove bones after 5 seconds (5 seconds = 300 ticks at 60fps) if (LK.ticks - bone.creationTime >= 300) { bone.destroy(); bones.splice(i, 1); continue; } // Remove off-screen bones if (bone.x > 2200 || bone.x < -200) { bone.destroy(); bones.splice(i, 1); } } // Update and check bullets for (var j = bullets.length - 1; j >= 0; j--) { var bullet = bullets[j]; // Check collision with chara if (bullet.intersects(chara)) { chara.takeDamage(15); bullet.destroy(); bullets.splice(j, 1); continue; } // Remove bullets after 5 seconds (5 seconds = 300 ticks at 60fps) if (LK.ticks - bullet.creationTime >= 300) { bullet.destroy(); bullets.splice(j, 1); continue; } // Remove off-screen bullets if (bullet.x > 2200 || bullet.x < -200 || bullet.y > 2800 || bullet.y < -100) { bullet.destroy(); bullets.splice(j, 1); } } // Win condition - survive for 2 minutes (7200 ticks) if (survivalTime >= 7200) { LK.showYouWin(); } // Increase difficulty over time if (survivalTime % 1800 === 0) { // Every 30 seconds gamePhase++; // Reduce pattern delay for increased difficulty if (patternTimer % 120 === 0) { patternTimer = 60; // Faster attacks } } };
===================================================================
--- original.js
+++ change.js
@@ -13,8 +13,9 @@
anchorY: 0.5
});
self.speed = 8;
self.direction = 1; // 1 for right, -1 for left
+ self.creationTime = LK.ticks; // Track when bone was created
self.update = function () {
self.x += self.speed * self.direction;
};
return self;
@@ -24,8 +25,9 @@
self.bulletType = 'orange'; // 'orange' or 'blue'
self.speed = 6;
self.directionX = 0;
self.directionY = 0;
+ self.creationTime = LK.ticks; // Track when bullet was created
var bulletGraphics;
if (self.bulletType === 'orange') {
bulletGraphics = self.attachAsset('orangeBullet', {
anchorX: 0.5,
@@ -418,8 +420,14 @@
// Check collision with chara
if (bone.intersects(chara)) {
chara.takeDamage(20);
}
+ // Remove bones after 5 seconds (5 seconds = 300 ticks at 60fps)
+ if (LK.ticks - bone.creationTime >= 300) {
+ bone.destroy();
+ bones.splice(i, 1);
+ continue;
+ }
// Remove off-screen bones
if (bone.x > 2200 || bone.x < -200) {
bone.destroy();
bones.splice(i, 1);
@@ -434,8 +442,14 @@
bullet.destroy();
bullets.splice(j, 1);
continue;
}
+ // Remove bullets after 5 seconds (5 seconds = 300 ticks at 60fps)
+ if (LK.ticks - bullet.creationTime >= 300) {
+ bullet.destroy();
+ bullets.splice(j, 1);
+ continue;
+ }
// Remove off-screen bullets
if (bullet.x > 2200 || bullet.x < -200 || bullet.y > 2800 || bullet.y < -100) {
bullet.destroy();
bullets.splice(j, 1);
Corazón pixel art de color rojo. In-Game asset. 2d. High contrast. No shadows
Un hueso de sans. In-Game asset. 2d. High contrast. No shadows
Sans todo poderoso. In-Game asset. 2d. High contrast. No shadows
a blue ball (no de deporte solo una pelota azul). In-Game asset. 2d. High contrast. No shadows
Sans de color azul. In-Game asset. 2d. High contrast. No shadows
Sans color rojo. In-Game asset. 2d. High contrast. No shadows
Sans pintado de color verde. In-Game asset. 2d. High contrast. No shadows
Sans color morado. In-Game asset. 2d. High contrast. No shadows
Sans de color dorado épico y brillante. In-Game asset. 2d. High contrast. No shadows
Sans consumido por la oscuridad misma sans oscuro y maligno. In-Game asset. 2d. High contrast. No shadows