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.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; 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 () { 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(); } 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() * 3); switch (attackPattern) { case 0: createBoneWall(); break; case 1: createBulletSpiral(); break; case 2: createRandomBullets(); 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 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 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
@@ -1,6 +1,291 @@
-/****
+/****
+* 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.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;
+ 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 () {
+ 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
-});
\ No newline at end of file
+});
+
+/****
+* 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();
+}
+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() * 3);
+ switch (attackPattern) {
+ case 0:
+ createBoneWall();
+ break;
+ case 1:
+ createBulletSpiral();
+ break;
+ case 2:
+ createRandomBullets();
+ 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 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 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
+ }
+ }
+};
\ No newline at end of file
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