User prompt
Que al pasar 20 segundos el juego pase a modo noche
User prompt
Aumenta la distancia de los botones de movimiento entre si
User prompt
Si la IA detecta que está más abajo de la base principal, que se mueva a la base centrar para evitar caerse
User prompt
Si la IA detecta que está más abajo de la base principal, que se mueva a la más cercana para que evite caerse
User prompt
Que la IA detecte cuando un enemigo este en la misma base, si es así que se desplase al enemigo más cercano
User prompt
Que la IA detecte si un jugador está en la misma base , si es así entonces que se mueva hacia el que este más cerca
User prompt
Aumenta la inteligencia de la IA para que se desplase hacia el jugador más cercano si está en una base , y si se encuentra en una base diferente entonces que salte hacia el jugador más cercano
User prompt
Aumenta el alcance de la hitbox al estar en modo rueda
User prompt
Si un jugador está en modo rueda y entra en contacto con otro este hará daño
User prompt
Que al entrar en modo rueda el jugador salte sin parar al tocar el suelo ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
La rueda tiembla al entrar en contacto con el suelo, arreglalo por favor ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Agrégale un rebote al modo rueda que sea de la misma altura que el salto normal ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Centra el giro de la imagen del modo rueda ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Centra el giro del modo rueda y ajustalo para que la imagen no atraviesca el suelo ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Centra el giro del modo rueda ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Arregla el giro del modo rueda para que no atraviese el suelo
User prompt
Aumenta la velocidad de aparición de los power up
User prompt
Quita el giro del modo rueda y que gire solamente la imagen al moverse a su respectiva dirección ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Al girar la imagen atraviesa el suelo, arreglalo por favor
User prompt
El giro del modo rueda atraviesa todo y es muy exagerado, arreglalo por favor
User prompt
Actualiza la ubicación de aparición de los power ups a la nueva ubicación de las bases
User prompt
Que la base de la izquierda y derecha tengan más distancia entre si
User prompt
Agrega un nuevo power up, que este al optenerlo convierta al que lo obtuvo en una rueda que gire según hacia donde se mueva , agrégale físicas de rueda y rebote, una nueva textura diferente para cada jugador y que el efecto dure 10 segundos ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Bájalo mucho más
User prompt
Bájalo el doble
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Fighter = Container.expand(function (playerNumber, color) {
var self = Container.call(this);
var assetName = 'player1';
if (playerNumber === 2) assetName = 'player2';else if (playerNumber === 3) assetName = 'player3';else if (playerNumber === 4) assetName = 'player4';
var fighterGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 1.0
});
self.playerNumber = playerNumber;
self.velocityX = 0;
self.velocityY = 0;
self.onGround = false;
self.jumpsRemaining = 2; // Allow double jump
self.health = 0;
self.maxHealth = 100;
self.damage = 0; // New damage accumulation property
self.moveSpeed = 8;
self.jumpPower = 25;
self.knockbackResistance = 1.0;
self.lastHitTime = 0;
self.invulnerable = false;
self.powerupCount = 0; // Track number of powerups collected
self.baseMoveSpeed = 8; // Store original move speed
self.baseJumpPower = 25; // Store original jump power
self.baseDamage = 15; // Store original damage
self.baseKnockback = 20; // Store original knockback
self.lastVelocityX = 0; // Track last velocity for rotation
self.isWheelMode = false; // Track if in wheel mode
self.wheelModeTimer = 0; // Timer for wheel mode duration
self.wheelGraphics = null; // Reference to wheel graphics
// Create damage bar background
var damageBarBg = self.addChild(LK.getAsset('platform', {
width: 100,
height: 12,
anchorX: 0.5,
anchorY: 1.0,
x: 0,
y: -130
}));
damageBarBg.tint = 0x333333;
damageBarBg.scaleX = 0.8;
damageBarBg.scaleY = 0.3;
// Create damage bar fill
self.damageBar = self.addChild(LK.getAsset('platform', {
width: 100,
height: 12,
anchorX: 0,
anchorY: 1.0,
x: -40,
y: -130
}));
self.damageBar.tint = 0xff4444;
self.damageBar.scaleX = 0;
self.damageBar.scaleY = 0.3;
// Create damage text
self.damageText = self.addChild(new Text2('0%', {
size: 30,
fill: 0xFFFFFF,
stroke: 0x000000,
strokeThickness: 4
}));
self.damageText.anchor.set(0.5, 1);
self.damageText.x = 0;
self.damageText.y = -140;
self.takeDamage = function (damage, knockbackX, knockbackY) {
if (self.invulnerable) return;
self.health += damage;
self.damage += damage; // Accumulate damage for knockback scaling
// Cap damage at 999%
if (self.damage > 999) self.damage = 999;
// Update damage display
self.damageText.setText(Math.floor(self.damage) + '%');
// Reapply stroke properties to maintain black background texture
if (self.damageText.style) {
self.damageText.style.stroke = 0x000000;
self.damageText.style.strokeThickness = 4;
}
// Update damage bar scale (0 to 1 based on damage up to 200%)
var barScale = Math.min(self.damage / 200, 1);
self.damageBar.scaleX = barScale * 0.8;
// Change bar color based on damage level
if (self.damage < 50) {
self.damageBar.tint = 0x44ff44; // Green for low damage
} else if (self.damage < 100) {
self.damageBar.tint = 0xffff44; // Yellow for medium damage
} else if (self.damage < 150) {
self.damageBar.tint = 0xff8844; // Orange for high damage
} else {
self.damageBar.tint = 0xff4444; // Red for very high damage
}
// Check if player has reached 200 damage - explosion and life loss
if (self.damage >= 200) {
// Create explosion effect with tween
tween(self, {
scaleX: 2.0,
scaleY: 2.0,
alpha: 0
}, {
duration: 500,
easing: tween.bounceOut,
onFinish: function onFinish() {
// Reset scale and alpha after explosion
self.scaleX = 1.0;
self.scaleY = 1.0;
self.alpha = 1.0;
// Trigger respawn which handles life loss
self.respawn();
}
});
// Flash screen effect for dramatic explosion
LK.effects.flashScreen(0xff8800, 600);
// Play explosion sound effect
LK.getSound('explosion').play();
// Reset damage to prevent multiple explosions
self.damage = 0;
return; // Exit early to prevent further processing this frame
}
// Knockback multiplier based on accumulated damage - exponential scaling for stronger hits at higher damage
var knockbackMultiplier = 1.5 + self.damage / 20 + Math.pow(self.damage / 100, 1.5); // Exponential scaling that increases dramatically with damage
self.velocityX += knockbackX * knockbackMultiplier / self.knockbackResistance;
self.velocityY += knockbackY * knockbackMultiplier / self.knockbackResistance;
// Flash effect when hit
LK.effects.flashObject(self, 0xff0000, 300);
self.invulnerable = true;
LK.setTimeout(function () {
self.invulnerable = false;
}, 500);
LK.getSound('hit').play();
};
self.attack = function (targetX, targetY) {
var attackRange = 150;
var damage = self.baseDamage + self.powerupCount * 8; // Increase damage by 8 per powerup
var baseKnockback = self.baseKnockback + self.powerupCount * 10; // Increase knockback by 10 per powerup
for (var i = 0; i < fighters.length; i++) {
var target = fighters[i];
if (target === self) continue;
var distance = Math.sqrt(Math.pow(target.x - self.x, 2) + Math.pow(target.y - self.y, 2));
if (distance <= attackRange) {
var angle = Math.atan2(target.y - self.y, target.x - self.x);
var knockbackX = Math.cos(angle) * baseKnockback;
var knockbackY = Math.sin(angle) * baseKnockback - 5; // Slight upward angle
target.takeDamage(damage, knockbackX, knockbackY);
}
}
};
self.update = function () {
// Handle wheel mode timer
if (self.isWheelMode) {
self.wheelModeTimer--;
if (self.wheelModeTimer <= 0) {
self.deactivateWheelMode();
}
}
// Update movement stats based on powerups
self.moveSpeed = self.baseMoveSpeed + self.powerupCount * 3; // Increase move speed by 3 per powerup
self.jumpPower = self.baseJumpPower + self.powerupCount * 5; // Increase jump power by 5 per powerup
// Apply wheel mode bonuses
if (self.isWheelMode) {
self.moveSpeed *= 1.5;
self.jumpPower *= 1.3;
}
// Apply gravity
if (!self.onGround) {
self.velocityY += 1.2;
}
// Apply friction
self.velocityX *= 0.85;
if (self.onGround) {
self.velocityX *= 0.75;
}
// Limit velocities to prevent teleportation
var maxVelocityX = 20;
var maxVelocityY = 30;
if (self.velocityX > maxVelocityX) {
self.velocityX = maxVelocityX;
}
if (self.velocityX < -maxVelocityX) {
self.velocityX = -maxVelocityX;
}
if (self.velocityY > maxVelocityY) {
self.velocityY = maxVelocityY;
}
if (self.velocityY < -maxVelocityY) {
self.velocityY = -maxVelocityY;
}
// Track last position for smoke trail
if (self.lastX === undefined) self.lastX = self.x;
if (self.lastY === undefined) self.lastY = self.y;
// Update position
self.x += self.velocityX;
self.y += self.velocityY;
// Generate smoke trail when moving
var movementSpeed = Math.sqrt(Math.pow(self.x - self.lastX, 2) + Math.pow(self.y - self.lastY, 2));
if (movementSpeed > 3 && LK.ticks % 3 === 0) {
// Calculate movement direction
var movementDirectionX = self.x - self.lastX;
var movementDirectionY = self.y - self.lastY;
// Normalize the direction
var directionLength = Math.sqrt(movementDirectionX * movementDirectionX + movementDirectionY * movementDirectionY);
if (directionLength > 0) {
movementDirectionX /= directionLength;
movementDirectionY /= directionLength;
}
// Position smoke trail behind the movement direction
var smokeDistance = 30; // Distance behind the player
var smokeX = self.x - movementDirectionX * smokeDistance;
var smokeY = self.y - movementDirectionY * smokeDistance + 20;
var smoke = new SmokeTrail(self.playerNumber, smokeX, smokeY);
game.addChild(smoke);
smokeTrails.push(smoke);
}
// Update last position
self.lastX = self.x;
self.lastY = self.y;
// Update visual size based on powerup count
var targetScale = 1.0 + self.powerupCount * 0.2; // Increase size by 20% per powerup
if (Math.abs(fighterGraphics.scaleX) !== targetScale) {
var isFlipped = fighterGraphics.scaleX < 0;
fighterGraphics.scaleX = isFlipped ? -targetScale : targetScale;
fighterGraphics.scaleY = targetScale;
}
// Handle wheel mode rotation and physics
if (self.isWheelMode && self.wheelGraphics) {
// Only rotate wheel when moving and not on ground, or when on ground with sufficient velocity
if (!self.onGround && Math.abs(self.velocityX) > 1 || self.onGround && Math.abs(self.velocityX) > 2) {
self.wheelGraphics.rotation += self.velocityX * 0.1;
}
// Add bounce effect when hitting ground
if (self.onGround && Math.abs(self.velocityY) > 5) {
self.velocityY = -Math.abs(self.velocityY) * 0.6; // Bounce with energy loss
}
// Enhanced friction for wheel mode
if (self.onGround) {
self.velocityX *= 0.95; // More responsive control
}
} else {
// Rotate player based on movement direction (normal mode)
if (Math.abs(self.velocityX) > 1) {
// Only rotate if moving with significant velocity
if (self.velocityX > 0) {
// Moving right - face right (normal orientation)
fighterGraphics.scaleX = Math.abs(fighterGraphics.scaleX);
} else {
// Moving left - face left (flip horizontally)
fighterGraphics.scaleX = -Math.abs(fighterGraphics.scaleX);
}
}
}
// Platform collision
var wasOnGround = self.onGround;
self.onGround = false;
for (var i = 0; i < platforms.length; i++) {
var platform = platforms[i];
// More precise collision detection with tighter bounds
var platformLeft = platform.x - platform.width / 2 + 10; // Add small margin
var platformRight = platform.x + platform.width / 2 - 10; // Add small margin
var platformTop = platform.y - platform.height / 2;
var platformBottom = platform.y + platform.height / 2;
// Check if player is within platform horizontal bounds and approaching from above
if (self.x >= platformLeft && self.x <= platformRight && self.y >= platformTop - 20 && self.y <= platformBottom + 5 && self.velocityY >= 0) {
// Snap player to exact platform surface
self.y = platformTop;
self.velocityY = 0;
// Play landing sound if just landed (wasn't on ground before)
if (!wasOnGround) {
LK.getSound('landing').play();
}
self.onGround = true;
self.jumpsRemaining = 2; // Reset jumps when landing
break;
}
}
// Check if fallen off screen
if (self.y > 2900) {
// Play fall sound effect
LK.getSound('fall').play();
self.respawn();
}
// Fighter-to-fighter collision detection and pushing
for (var i = 0; i < fighters.length; i++) {
var otherFighter = fighters[i];
if (otherFighter === self || otherFighter.destroyed) continue;
// Calculate distance between fighters
var deltaX = otherFighter.x - self.x;
var deltaY = otherFighter.y - self.y;
var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
// Check if fighters are colliding (within collision radius)
var collisionRadius = 80; // Adjust this value to change collision sensitivity
if (distance < collisionRadius && distance > 0) {
// Calculate push force based on overlap
var overlap = collisionRadius - distance;
var pushStrength = overlap * 0.3; // Adjust push strength
// Normalize direction vector
var normalX = deltaX / distance;
var normalY = deltaY / distance;
// Apply push forces to both fighters
var pushX = normalX * pushStrength;
var pushY = normalY * pushStrength * 0.3; // Reduced vertical push
// Push both fighters apart
self.velocityX -= pushX;
self.velocityY -= pushY;
otherFighter.velocityX += pushX;
otherFighter.velocityY += pushY;
// Separate fighters to prevent overlap
var separationX = normalX * (overlap * 0.5);
var separationY = normalY * (overlap * 0.3);
self.x -= separationX;
self.y -= separationY;
otherFighter.x += separationX;
otherFighter.y += separationY;
}
}
// Screen boundaries (horizontal bouncing)
if (self.x < 60) {
self.x = 60;
if (self.isWheelMode) {
self.velocityX = Math.abs(self.velocityX) * 0.8; // Enhanced bounce in wheel mode
} else {
self.velocityX = Math.abs(self.velocityX) * 0.5;
}
}
if (self.x > 2700) {
self.x = 2700;
if (self.isWheelMode) {
self.velocityX = -Math.abs(self.velocityX) * 0.8; // Enhanced bounce in wheel mode
} else {
self.velocityX = -Math.abs(self.velocityX) * 0.5;
}
}
};
self.respawn = function () {
// Decrease lives for the player who died
if (self.playerNumber === 1) {
player1Lives--;
} else if (self.playerNumber === 2) {
player2Lives--;
} else if (self.playerNumber === 3) {
player3Lives--;
} else if (self.playerNumber === 4) {
player4Lives--;
}
updateScoreDisplay();
// Check if player is eliminated (no lives left)
var isEliminated = false;
if (self.playerNumber === 1 && player1Lives <= 0) {
isEliminated = true;
} else if (self.playerNumber === 2 && player2Lives <= 0) {
isEliminated = true;
} else if (self.playerNumber === 3 && player3Lives <= 0) {
isEliminated = true;
} else if (self.playerNumber === 4 && player4Lives <= 0) {
isEliminated = true;
}
if (isEliminated) {
// Remove player from the game completely
self.destroy();
// Remove from fighters array
for (var j = fighters.length - 1; j >= 0; j--) {
if (fighters[j] === self) {
fighters.splice(j, 1);
break;
}
}
activePlayers--;
// Check if only one player remains
if (activePlayers <= 1) {
// Find the winner
var winner = "";
if (player1Lives > 0) winner = "Player 1";else if (player2Lives > 0) winner = "Player 2";else if (player3Lives > 0) winner = "Player 3";else if (player4Lives > 0) winner = "Player 4";
LK.setScore(100);
LK.showGameOver();
}
} else {
// Player still has lives, respawn normally
if (self.playerNumber === 1) {
self.x = 1048; // Respawn on left platform
self.y = 1950; // Just above left platform surface
} else if (self.playerNumber === 2) {
self.x = 1648; // Respawn on main platform
self.y = 2300; // Just above main platform surface
} else if (self.playerNumber === 3) {
self.x = 1648; // Respawn on top platform
self.y = 1600; // Just above top platform surface
} else if (self.playerNumber === 4) {
self.x = 2248; // Respawn on right platform
self.y = 1950; // Just above right platform surface
}
self.velocityX = 0;
self.velocityY = 0;
self.health = 0;
self.damage = 0; // Reset damage on respawn
self.powerupCount = 0; // Reset powerup count on respawn
self.damageText.setText('0%');
// Reapply stroke properties to maintain black background texture
if (self.damageText.style) {
self.damageText.style.stroke = 0x000000;
self.damageText.style.strokeThickness = 4;
}
self.damageBar.scaleX = 0;
self.damageBar.tint = 0x44ff44;
self.jumpsRemaining = 2; // Reset jumps on respawn
}
};
self.activateWheelMode = function () {
if (self.isWheelMode) return; // Already in wheel mode
self.isWheelMode = true;
self.wheelModeTimer = 600; // 10 seconds at 60fps
// Hide original fighter graphics
fighterGraphics.visible = false;
// Create wheel graphics based on player number
var wheelAsset = 'wheel1';
if (self.playerNumber === 2) wheelAsset = 'wheel2';else if (self.playerNumber === 3) wheelAsset = 'wheel3';else if (self.playerNumber === 4) wheelAsset = 'wheel4';
self.wheelGraphics = self.attachAsset(wheelAsset, {
anchorX: 0.5,
anchorY: 0.5
});
// Increase move speed and add bounce physics
self.moveSpeed *= 1.5;
self.jumpPower *= 1.3;
};
self.deactivateWheelMode = function () {
if (!self.isWheelMode) return;
self.isWheelMode = false;
self.wheelModeTimer = 0;
// Show original fighter graphics
fighterGraphics.visible = true;
// Remove wheel graphics
if (self.wheelGraphics) {
self.wheelGraphics.destroy();
self.wheelGraphics = null;
}
// Reset move speed
self.moveSpeed = self.baseMoveSpeed + self.powerupCount * 3;
self.jumpPower = self.baseJumpPower + self.powerupCount * 5;
};
return self;
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerupGraphics = self.attachAsset('powerup', {
anchorX: 0.5,
anchorY: 0.5
});
self.lifeTime = 0;
self.maxLifeTime = 600; // 10 seconds at 60fps
self.collected = false;
self.velocityY = 0; // Falling velocity
self.onGround = false; // Track if powerup has landed
self.update = function () {
self.lifeTime++;
self.rotation += 0.05;
// Apply gravity if not on ground
if (!self.onGround) {
self.velocityY += 0.8; // Gravity effect
self.y += self.velocityY;
// Check platform collision for landing
for (var i = 0; i < platforms.length; i++) {
var platform = platforms[i];
var platformLeft = platform.x - platform.width / 2;
var platformRight = platform.x + platform.width / 2;
var platformTop = platform.y - platform.height / 2;
var platformBottom = platform.y + platform.height / 2;
// Check if powerup is within platform bounds and landing on top
if (self.x >= platformLeft && self.x <= platformRight && self.y >= platformTop - 30 && self.y <= platformBottom && self.velocityY >= 0) {
self.y = platformTop - 30; // Position on top of platform
self.velocityY = 0;
self.onGround = true;
break;
}
}
// Remove if fallen off screen
if (self.y > 2800) {
self.destroy();
for (var j = powerups.length - 1; j >= 0; j--) {
if (powerups[j] === self) {
powerups.splice(j, 1);
break;
}
}
return;
}
} else {
// Bounce effect when on ground
self.y += Math.sin(self.lifeTime * 0.1) * 0.5;
}
if (self.lifeTime > self.maxLifeTime) {
self.destroy();
for (var i = powerups.length - 1; i >= 0; i--) {
if (powerups[i] === self) {
powerups.splice(i, 1);
break;
}
}
}
// Check collection by players
if (!self.collected) {
for (var i = 0; i < fighters.length; i++) {
var fighter = fighters[i];
var distance = Math.sqrt(Math.pow(fighter.x - self.x, 2) + Math.pow(fighter.y - self.y, 2));
if (distance < 80) {
self.collected = true;
// Increase powerup count for stacking effects
fighter.powerupCount++;
// Visual effects for powerup collection
LK.getSound('powerup').play();
LK.effects.flashObject(fighter, 0xffd700, 800);
// Create scaling animation effect
tween(fighter, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 200,
easing: tween.bounceOut,
onFinish: function onFinish() {
// Scale back down slightly
tween(fighter, {
scaleX: 1.0 + fighter.powerupCount * 0.2,
scaleY: 1.0 + fighter.powerupCount * 0.2
}, {
duration: 300,
easing: tween.easeOut
});
}
});
// Temporary knockback resistance boost (stacks with permanent effects)
var originalResistance = fighter.knockbackResistance;
fighter.knockbackResistance *= 0.7; // 30% less knockback temporarily
LK.setTimeout(function () {
fighter.knockbackResistance = originalResistance;
}, 3000);
self.destroy();
for (var j = powerups.length - 1; j >= 0; j--) {
if (powerups[j] === self) {
powerups.splice(j, 1);
break;
}
}
break;
}
}
}
};
return self;
});
var SmokeTrail = Container.expand(function (playerNumber, x, y) {
var self = Container.call(this);
var assetName = 'smokeTrail1';
if (playerNumber === 2) assetName = 'smokeTrail2';else if (playerNumber === 3) assetName = 'smokeTrail3';else if (playerNumber === 4) assetName = 'smokeTrail4';
var smokeGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.x = x;
self.y = y;
self.lifeTime = 0;
self.maxLifeTime = 30; // 0.5 seconds at 60fps
self.startScale = 0.6 + Math.random() * 0.4;
self.endScale = 1.2 + Math.random() * 0.8;
smokeGraphics.scaleX = self.startScale;
smokeGraphics.scaleY = self.startScale;
smokeGraphics.alpha = 0.9;
self.velocityX = (Math.random() - 0.5) * 2;
self.velocityY = -2 - Math.random() * 3;
self.update = function () {
self.lifeTime++;
var progress = self.lifeTime / self.maxLifeTime;
// Move the smoke particle
self.x += self.velocityX;
self.y += self.velocityY;
// Fade out and scale up over time
smokeGraphics.alpha = 0.9 * (1 - progress);
var currentScale = self.startScale + (self.endScale - self.startScale) * progress;
smokeGraphics.scaleX = currentScale;
smokeGraphics.scaleY = currentScale;
// Remove when life time is over
if (self.lifeTime >= self.maxLifeTime) {
self.destroy();
for (var i = smokeTrails.length - 1; i >= 0; i--) {
if (smokeTrails[i] === self) {
smokeTrails.splice(i, 1);
break;
}
}
}
};
return self;
});
var WheelPowerUp = Container.expand(function () {
var self = Container.call(this);
var wheelPowerupGraphics = self.attachAsset('wheelPowerup', {
anchorX: 0.5,
anchorY: 0.5
});
self.lifeTime = 0;
self.maxLifeTime = 600; // 10 seconds at 60fps
self.collected = false;
self.velocityY = 0; // Falling velocity
self.onGround = false; // Track if powerup has landed
self.update = function () {
self.lifeTime++;
self.rotation += 0.05;
// Apply gravity if not on ground
if (!self.onGround) {
self.velocityY += 0.8; // Gravity effect
self.y += self.velocityY;
// Check platform collision for landing
for (var i = 0; i < platforms.length; i++) {
var platform = platforms[i];
var platformLeft = platform.x - platform.width / 2;
var platformRight = platform.x + platform.width / 2;
var platformTop = platform.y - platform.height / 2;
var platformBottom = platform.y + platform.height / 2;
// Check if powerup is within platform bounds and landing on top
if (self.x >= platformLeft && self.x <= platformRight && self.y >= platformTop - 30 && self.y <= platformBottom && self.velocityY >= 0) {
self.y = platformTop - 30; // Position on top of platform
self.velocityY = 0;
self.onGround = true;
break;
}
}
// Remove if fallen off screen
if (self.y > 2800) {
self.destroy();
for (var j = wheelPowerups.length - 1; j >= 0; j--) {
if (wheelPowerups[j] === self) {
wheelPowerups.splice(j, 1);
break;
}
}
return;
}
} else {
// Bounce effect when on ground
self.y += Math.sin(self.lifeTime * 0.1) * 0.5;
}
if (self.lifeTime > self.maxLifeTime) {
self.destroy();
for (var i = wheelPowerups.length - 1; i >= 0; i--) {
if (wheelPowerups[i] === self) {
wheelPowerups.splice(i, 1);
break;
}
}
}
// Check collection by players
if (!self.collected) {
for (var i = 0; i < fighters.length; i++) {
var fighter = fighters[i];
var distance = Math.sqrt(Math.pow(fighter.x - self.x, 2) + Math.pow(fighter.y - self.y, 2));
if (distance < 80) {
self.collected = true;
// Convert fighter to wheel mode
fighter.activateWheelMode();
// Visual effects for powerup collection
LK.getSound('powerup').play();
LK.effects.flashObject(fighter, 0x00ff00, 800);
self.destroy();
for (var j = wheelPowerups.length - 1; j >= 0; j--) {
if (wheelPowerups[j] === self) {
wheelPowerups.splice(j, 1);
break;
}
}
break;
}
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Game variables
var fighters = [];
var platforms = [];
var powerups = [];
var wheelPowerups = [];
var smokeTrails = [];
var player1Lives = 3;
var player2Lives = 3;
var player3Lives = 3;
var player4Lives = 3;
var activePlayers = 4;
var draggedFighter = null;
var lastTapTime = 0;
var powerupSpawnTimer = 0;
// Camera variables
var cameraX = 1024; // Center of screen
var cameraY = 1366; // Center of screen
var cameraScale = 1.0;
var targetCameraX = 1024;
var targetCameraY = 1366;
var targetCameraScale = 1.0;
var cameraUpdateTimer = 0;
// Add background image with parallax tracking
var backgroundImage = game.addChild(LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 1648,
y: 2400
}));
backgroundImage.originalX = 1648;
backgroundImage.originalY = 2400;
// Add second background image on top of the first with parallax tracking
var backgroundOverlay = game.addChild(LK.getAsset('backgroundOverlay', {
anchorX: 0.5,
anchorY: 0.5,
x: 1648,
y: 2400
}));
backgroundOverlay.originalX = 1648;
backgroundOverlay.originalY = 2400;
// Add third background image above the previous two with parallax tracking
var backgroundTop = game.addChild(LK.getAsset('backgroundTop', {
anchorX: 0.5,
anchorY: 0.5,
x: 1648,
y: 3200
}));
backgroundTop.originalX = 1648;
backgroundTop.originalY = 3200;
// Button press states
var leftButtonPressed = false;
var rightButtonPressed = false;
var jumpButtonPressed = false;
var attackButtonPressed = false;
// Create platforms
var mainPlatform = game.addChild(LK.getAsset('mainPlatform', {
anchorX: 0.5,
anchorY: 0.5,
x: 1648,
y: 2400
}));
platforms.push(mainPlatform);
var leftPlatform = game.addChild(LK.getAsset('platform', {
anchorX: 0.5,
anchorY: 0.5,
x: 1048,
y: 2050
}));
platforms.push(leftPlatform);
var rightPlatform = game.addChild(LK.getAsset('platform', {
anchorX: 0.5,
anchorY: 0.5,
x: 2248,
y: 2050
}));
platforms.push(rightPlatform);
var topPlatform = game.addChild(LK.getAsset('platform', {
anchorX: 0.5,
anchorY: 0.5,
x: 1648,
y: 1700
}));
platforms.push(topPlatform);
// Add decorative textured images directly on top of platforms
var mainPlatformTexture = game.addChild(LK.getAsset('platformTexture', {
anchorX: 0.5,
anchorY: 1.0,
x: 1648,
y: 2250
}));
mainPlatformTexture.scaleX = 2.5; // Scale to match main platform width
mainPlatformTexture.scaleY = 0.8;
var leftPlatformTexture = game.addChild(LK.getAsset('platformTexture', {
anchorX: 0.5,
anchorY: 1.0,
x: 1048,
y: 1950
}));
leftPlatformTexture.scaleX = 1.25; // Scale to match platform width
leftPlatformTexture.scaleY = 0.6;
var rightPlatformTexture = game.addChild(LK.getAsset('platformTexture', {
anchorX: 0.5,
anchorY: 1.0,
x: 2248,
y: 1950
}));
rightPlatformTexture.scaleX = 1.25; // Scale to match platform width
rightPlatformTexture.scaleY = 0.6;
var topPlatformTexture = game.addChild(LK.getAsset('platformTexture', {
anchorX: 0.5,
anchorY: 1.0,
x: 1648,
y: 1600
}));
topPlatformTexture.scaleX = 1.25; // Scale to match platform width
topPlatformTexture.scaleY = 0.6;
// Create fighters
var player1 = game.addChild(new Fighter(1));
player1.x = 1048; // Position on left platform
player1.y = 1950; // Just above the platform surface
fighters.push(player1);
var player2 = game.addChild(new Fighter(2));
player2.x = 1648; // Position on main platform
player2.y = 2300; // Just above the main platform surface
fighters.push(player2);
var player3 = game.addChild(new Fighter(3));
player3.x = 1648; // Position on top platform
player3.y = 1600; // Just above the top platform surface
fighters.push(player3);
var player4 = game.addChild(new Fighter(4));
player4.x = 2248; // Position on right platform
player4.y = 1950; // Just above the right platform surface
fighters.push(player4);
// UI Elements
var scoreText = new Text2('Player 1: 0 | Player 2: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
// Create left movement button for player 1
var leftButton = LK.getAsset('leftButtonIcon', {
anchorX: 0,
anchorY: 1,
x: 50,
y: -160,
scaleX: 3,
scaleY: 3
});
LK.gui.bottomLeft.addChild(leftButton);
// Create right movement button for player 1
var rightButton = LK.getAsset('rightButtonIcon', {
anchorX: 0,
anchorY: 1,
x: 280,
y: -160,
scaleX: 3,
scaleY: 3
});
LK.gui.bottomLeft.addChild(rightButton);
// Create jump button for player 1
var jumpButton = LK.getAsset('jumpButtonIcon', {
anchorX: 0,
anchorY: 1,
x: 165,
y: -300,
scaleX: 3,
scaleY: 3
});
LK.gui.bottomLeft.addChild(jumpButton);
// Create attack button for player 1
var attackButton = LK.getAsset('attackButtonIcon', {
anchorX: 1,
anchorY: 1,
x: -100,
y: -160,
scaleX: 3,
scaleY: 3
});
LK.gui.bottomRight.addChild(attackButton);
function updateScoreDisplay() {
scoreText.setText('P1 Lives: ' + player1Lives + ' | P2 Lives: ' + player2Lives + ' | P3 Lives: ' + player3Lives + ' | P4 Lives: ' + player4Lives);
}
// Left button event handler
leftButton.down = function (x, y, obj) {
leftButtonPressed = true;
leftButton.alpha = 0.6;
tween(leftButton, {
scaleX: 2.7,
scaleY: 2.7
}, {
duration: 100
});
};
leftButton.up = function (x, y, obj) {
leftButtonPressed = false;
leftButton.alpha = 1.0;
tween(leftButton, {
scaleX: 3.0,
scaleY: 3.0
}, {
duration: 100
});
};
// Right button event handler
rightButton.down = function (x, y, obj) {
rightButtonPressed = true;
rightButton.alpha = 0.6;
tween(rightButton, {
scaleX: 2.7,
scaleY: 2.7
}, {
duration: 100
});
};
rightButton.up = function (x, y, obj) {
rightButtonPressed = false;
rightButton.alpha = 1.0;
tween(rightButton, {
scaleX: 3.0,
scaleY: 3.0
}, {
duration: 100
});
};
// Jump button event handler
jumpButton.down = function (x, y, obj) {
jumpButtonPressed = true;
jumpButton.alpha = 0.6;
tween(jumpButton, {
scaleX: 2.7,
scaleY: 2.7
}, {
duration: 100
});
};
jumpButton.up = function (x, y, obj) {
jumpButtonPressed = false;
jumpButton.alpha = 1.0;
tween(jumpButton, {
scaleX: 3.0,
scaleY: 3.0
}, {
duration: 100
});
};
// Attack button event handler
attackButton.down = function (x, y, obj) {
attackButtonPressed = true;
attackButton.alpha = 0.6;
tween(attackButton, {
scaleX: 2.7,
scaleY: 2.7
}, {
duration: 100
});
};
attackButton.up = function (x, y, obj) {
attackButtonPressed = false;
attackButton.alpha = 1.0;
tween(attackButton, {
scaleX: 3.0,
scaleY: 3.0
}, {
duration: 100
});
};
function updateCamera() {
// Only update camera if there are living fighters
var aliveFighters = [];
for (var i = 0; i < fighters.length; i++) {
var fighter = fighters[i];
if (fighter && !fighter.destroyed) {
// Check if fighter is alive based on lives
var isAlive = false;
if (fighter.playerNumber === 1 && player1Lives > 0) isAlive = true;else if (fighter.playerNumber === 2 && player2Lives > 0) isAlive = true;else if (fighter.playerNumber === 3 && player3Lives > 0) isAlive = true;else if (fighter.playerNumber === 4 && player4Lives > 0) isAlive = true;
if (isAlive) {
aliveFighters.push(fighter);
}
}
}
if (aliveFighters.length === 0) return;
// Calculate center point of all alive fighters
var minX = Infinity;
var maxX = -Infinity;
var minY = Infinity;
var maxY = -Infinity;
var totalX = 0;
var totalY = 0;
for (var i = 0; i < aliveFighters.length; i++) {
var fighter = aliveFighters[i];
totalX += fighter.x;
totalY += fighter.y;
if (fighter.x < minX) minX = fighter.x;
if (fighter.x > maxX) maxX = fighter.x;
if (fighter.y < minY) minY = fighter.y;
if (fighter.y > maxY) maxY = fighter.y;
}
// Calculate center point
targetCameraX = totalX / aliveFighters.length;
targetCameraY = totalY / aliveFighters.length;
// Calculate required zoom based on spread of players
var spreadX = maxX - minX;
var spreadY = maxY - minY;
// Base zoom calculation - zoom in more for closer view of players
var baseScale = 1.2; // Increased base scale for more zoom
var maxSpreadX = 400; // Further reduced max spread for tighter framing
var maxSpreadY = 300; // Further reduced max spread for tighter framing
var scaleX = maxSpreadX / Math.max(spreadX + 100, maxSpreadX); // Reduced padding for closer view
var scaleY = maxSpreadY / Math.max(spreadY + 100, maxSpreadY); // Reduced padding for closer view
// Use the smaller scale to ensure all players fit
targetCameraScale = Math.min(scaleX, scaleY, 1.3); // Increased max zoom to 1.3x for closer view
// Minimum zoom to prevent over-zooming - increased minimum for closer gameplay
if (targetCameraScale < 0.9) targetCameraScale = 0.9;
// Keep camera within reasonable bounds
var padding = 200;
if (targetCameraX < padding) targetCameraX = padding;
if (targetCameraX > 2048 - padding) targetCameraX = 2048 - padding;
if (targetCameraY < 400) targetCameraY = 400;
if (targetCameraY > 2400) targetCameraY = 2400;
}
function applyCameraSmoothing() {
// Smooth camera movement using tweening
var smoothingSpeed = 0.05; // How fast camera follows (0.01 = very slow, 0.1 = fast)
// Interpolate camera position
cameraX += (targetCameraX - cameraX) * smoothingSpeed;
cameraY += (targetCameraY - cameraY) * smoothingSpeed;
cameraScale += (targetCameraScale - cameraScale) * smoothingSpeed;
// Apply camera transformation to game
game.x = (1024 - cameraX) * cameraScale + 1024 * (1 - cameraScale);
game.y = (1366 - cameraY) * cameraScale + 1366 * (1 - cameraScale);
game.scaleX = cameraScale;
game.scaleY = cameraScale;
// Apply parallax scrolling to background layers
updateParallax();
}
function updateParallax() {
// Calculate camera movement offset from center
var cameraMoveX = cameraX - 1024; // How much camera moved from center horizontally
var cameraMoveY = cameraY - 1366; // How much camera moved from center vertically
// Background image (furthest back) - moves slowest (20% of camera movement)
backgroundImage.x = backgroundImage.originalX - cameraMoveX * 0.2;
backgroundImage.y = backgroundImage.originalY - cameraMoveY * 0.15;
// Background overlay (middle layer) - moves at medium speed (40% of camera movement)
backgroundOverlay.x = backgroundOverlay.originalX - cameraMoveX * 0.4;
backgroundOverlay.y = backgroundOverlay.originalY - cameraMoveY * 0.3;
// Background top (closest to foreground) - moves faster (60% of camera movement)
backgroundTop.x = backgroundTop.originalX - cameraMoveX * 0.6;
backgroundTop.y = backgroundTop.originalY - cameraMoveY * 0.45;
}
function spawnPowerUp() {
if (powerups.length + wheelPowerups.length < 2) {
// 50% chance for wheel powerup, 50% for regular powerup
if (Math.random() < 0.5) {
var powerup = game.addChild(new PowerUp());
// Spawn from random position above the screen aligned with new platform positions
powerup.x = 1048 + Math.random() * 1200; // Random X within extended platform bounds (left to right platform)
powerup.y = -100; // Start above screen
powerup.velocityY = 2 + Math.random() * 3; // Initial falling speed
powerups.push(powerup);
} else {
var wheelPowerup = game.addChild(new WheelPowerUp());
// Spawn from random position above the screen aligned with new platform positions
wheelPowerup.x = 1048 + Math.random() * 1200; // Random X within extended platform bounds (left to right platform)
wheelPowerup.y = -100; // Start above screen
wheelPowerup.velocityY = 2 + Math.random() * 3; // Initial falling speed
wheelPowerups.push(wheelPowerup);
}
}
}
// Game controls
game.down = function (x, y, obj) {
var currentTime = LK.ticks;
var tapSpeed = 20; // frames between taps for double tap
// Find closest fighter to touch point (only player 1)
var closestFighter = null;
var closestDistance = Infinity;
for (var i = 0; i < fighters.length; i++) {
var fighter = fighters[i];
// Only allow touch control for player 1 if they're still alive
if (fighter.playerNumber !== 1 || player1Lives <= 0) continue;
var distance = Math.sqrt(Math.pow(fighter.x - x, 2) + Math.pow(fighter.y - y, 2));
if (distance < closestDistance && distance < 200) {
closestDistance = distance;
closestFighter = fighter;
}
}
if (closestFighter) {
// Check for double tap (attack)
if (currentTime - lastTapTime < tapSpeed) {
closestFighter.attack(x, y);
draggedFighter = null;
} else {
draggedFighter = closestFighter;
}
lastTapTime = currentTime;
}
};
game.move = function (x, y, obj) {
if (draggedFighter && draggedFighter.playerNumber === 1) {
var deltaX = x - draggedFighter.x;
var deltaY = y - draggedFighter.y;
// Move fighter towards touch point
draggedFighter.velocityX += deltaX * 0.3;
// Jump if dragging upward and has jumps remaining
if (deltaY < -50 && draggedFighter.jumpsRemaining > 0) {
draggedFighter.velocityY = -draggedFighter.jumpPower;
draggedFighter.jumpsRemaining--;
draggedFighter.onGround = false;
LK.getSound('jump').play();
}
}
};
game.up = function (x, y, obj) {
draggedFighter = null;
};
// Function to find closest target for AI
function findClosestTarget(aiPlayer) {
var closestPlayer = null;
var closestDistance = Infinity;
for (var i = 0; i < fighters.length; i++) {
var fighter = fighters[i];
// Skip self, dead players, and destroyed fighters
if (fighter === aiPlayer) continue;
if (fighter.destroyed) continue;
if (fighter.playerNumber === 1 && player1Lives <= 0) continue;
if (fighter.playerNumber === 2 && player2Lives <= 0) continue;
if (fighter.playerNumber === 3 && player3Lives <= 0) continue;
if (fighter.playerNumber === 4 && player4Lives <= 0) continue;
var distance = Math.sqrt(Math.pow(fighter.x - aiPlayer.x, 2) + Math.pow(fighter.y - aiPlayer.y, 2));
if (distance < closestDistance) {
closestDistance = distance;
closestPlayer = fighter;
}
}
return {
player: closestPlayer,
distance: closestDistance
};
}
// AI variables for player 2
var aiDecisionTimer = 0;
var aiAction = 'idle';
var aiTargetX = player2.x;
var aiCooldown = 0;
// AI variables for player 3
var ai3DecisionTimer = 0;
var ai3Action = 'idle';
var ai3TargetX = 1648;
var ai3Cooldown = 0;
// AI variables for player 4
var ai4DecisionTimer = 0;
var ai4Action = 'idle';
var ai4TargetX = 2248;
var ai4Cooldown = 0;
game.update = function () {
// Start background music on first update
if (LK.ticks === 1) {
LK.playMusic('backgroundMusic');
}
// Handle continuous button presses for player 1 (only if alive)
if (player1Lives > 0) {
if (leftButtonPressed) {
player1.velocityX -= player1.moveSpeed * 0.5;
}
if (rightButtonPressed) {
player1.velocityX += player1.moveSpeed * 0.5;
}
if (jumpButtonPressed && player1.jumpsRemaining > 0) {
player1.velocityY = -player1.jumpPower;
player1.jumpsRemaining--;
player1.onGround = false;
LK.getSound('jump').play();
jumpButtonPressed = false; // Prevent continuous jumping
}
if (attackButtonPressed) {
player1.attack(player1.x, player1.y);
attackButtonPressed = false; // Prevent continuous attacking
}
}
// Spawn power-ups occasionally
powerupSpawnTimer++;
if (powerupSpawnTimer > 120) {
// Every 2 seconds
if (Math.random() < 0.5) {
spawnPowerUp();
}
powerupSpawnTimer = 0;
}
// AI for player 2 (only if alive)
if (player2Lives > 0) {
aiDecisionTimer++;
if (aiCooldown > 0) {
aiCooldown--;
}
// Make AI decisions every 30 frames (half second)
if (aiDecisionTimer > 30) {
aiDecisionTimer = 0;
// Find closest target
var closestTarget = findClosestTarget(player2);
var distanceToClosest = closestTarget.distance;
// Check for nearby powerups
var nearestPowerup = null;
var nearestPowerupDistance = Infinity;
for (var i = 0; i < powerups.length; i++) {
var powerup = powerups[i];
var distance = Math.sqrt(Math.pow(powerup.x - player2.x, 2) + Math.pow(powerup.y - player2.y, 2));
if (distance < nearestPowerupDistance) {
nearestPowerupDistance = distance;
nearestPowerup = powerup;
}
}
// AI decision making
if (aiCooldown === 0 && closestTarget.player) {
if (distanceToClosest < 200 && Math.random() < 0.8) {
// Attack if close to closest target
aiAction = 'attack';
aiCooldown = 60; // Attack cooldown
} else if (nearestPowerup && nearestPowerupDistance < 300 && Math.random() < 0.3) {
// Go for powerup if nearby (lower priority)
aiAction = 'moveToPowerup';
aiTargetX = nearestPowerup.x;
} else if (Math.random() < 0.9) {
// Chase closest target most of the time
aiAction = 'moveToPlayer';
aiTargetX = closestTarget.player.x;
} else {
// Random movement (rare)
aiAction = 'randomMove';
aiTargetX = 1200 + Math.random() * 900; // Random X within platform area
}
} else if (!closestTarget.player) {
aiAction = 'idle';
}
}
// Execute AI actions
if (aiAction === 'attack' && closestTarget.player) {
player2.attack(closestTarget.player.x, closestTarget.player.y);
aiAction = 'idle';
} else if (aiAction === 'moveToPowerup' || aiAction === 'moveToPlayer' || aiAction === 'randomMove') {
// Move towards target
var deltaX = aiTargetX - player2.x;
if (Math.abs(deltaX) > 50) {
player2.velocityX += deltaX * 0.2;
}
// Jump if target is above or if stuck
if (aiAction === 'moveToPlayer' && closestTarget && closestTarget.player && closestTarget.player.y < player2.y - 100 || Math.abs(player2.velocityX) < 1 && player2.onGround && Math.random() < 0.1) {
if (player2.jumpsRemaining > 0) {
player2.velocityY = -player2.jumpPower;
player2.jumpsRemaining--;
player2.onGround = false;
LK.getSound('jump').play();
}
}
// Reset action if close enough to target
if (Math.abs(deltaX) < 100) {
aiAction = 'idle';
}
}
// AI logic: double jump if can't reach player who is much higher
var heightDifference = player2.y - player1.y;
var horizontalDistance = Math.abs(player2.x - player1.x);
if (heightDifference > 200 && horizontalDistance < 400 && player2.jumpsRemaining > 0) {
// Check if AI is below player and perform double jump to reach them
player2.velocityY = -player2.jumpPower;
player2.jumpsRemaining--;
player2.onGround = false;
LK.getSound('jump').play();
}
// AI emergency jump if falling off platform
if (player2.y > 2500 && player2.jumpsRemaining > 0) {
player2.velocityY = -player2.jumpPower;
player2.jumpsRemaining--;
player2.onGround = false;
LK.getSound('jump').play();
}
}
// AI for player 3 (only if alive)
if (player3Lives > 0) {
ai3DecisionTimer++;
if (ai3Cooldown > 0) {
ai3Cooldown--;
}
if (ai3DecisionTimer > 45) {
ai3DecisionTimer = 0;
// Find closest target
var closestTarget_3 = findClosestTarget(player3);
var closestDistance_3 = closestTarget_3.distance;
if (ai3Cooldown === 0 && closestTarget_3.player) {
if (closestDistance_3 < 200 && Math.random() < 0.7) {
ai3Action = 'attack';
ai3Cooldown = 70;
} else if (Math.random() < 0.8) {
// Chase closest target most of the time
ai3Action = 'moveToPlayer';
ai3TargetX = closestTarget_3.player.x;
} else if (Math.random() < 0.3) {
ai3Action = 'randomMove';
ai3TargetX = 1200 + Math.random() * 900;
} else {
ai3Action = 'idle';
}
} else if (!closestTarget_3.player) {
ai3Action = 'idle';
}
}
if (ai3Action === 'attack' && closestTarget_3.player) {
player3.attack(closestTarget_3.player.x, closestTarget_3.player.y);
ai3Action = 'idle';
} else if (ai3Action === 'moveToPlayer' || ai3Action === 'randomMove') {
var deltaX_3 = ai3TargetX - player3.x;
if (Math.abs(deltaX_3) > 50) {
player3.velocityX += deltaX_3 * 0.18;
}
if (Math.abs(deltaX_3) > 200 && player3.onGround && Math.random() < 0.15) {
if (player3.jumpsRemaining > 0) {
player3.velocityY = -player3.jumpPower;
player3.jumpsRemaining--;
player3.onGround = false;
LK.getSound('jump').play();
}
}
if (Math.abs(deltaX_3) < 100) {
ai3Action = 'idle';
}
}
if (player3.y > 2500 && player3.jumpsRemaining > 0) {
player3.velocityY = -player3.jumpPower;
player3.jumpsRemaining--;
player3.onGround = false;
LK.getSound('jump').play();
}
}
// AI for player 4 (only if alive)
if (player4Lives > 0) {
ai4DecisionTimer++;
if (ai4Cooldown > 0) {
ai4Cooldown--;
}
if (ai4DecisionTimer > 35) {
ai4DecisionTimer = 0;
// Find closest target
var closestTarget_4 = findClosestTarget(player4);
var closestDistance_4 = closestTarget_4.distance;
if (ai4Cooldown === 0 && closestTarget_4.player) {
if (closestDistance_4 < 180 && Math.random() < 0.85) {
ai4Action = 'attack';
ai4Cooldown = 50;
} else if (Math.random() < 0.9) {
// Chase closest target aggressively
ai4Action = 'moveToPlayer';
ai4TargetX = closestTarget_4.player.x;
} else if (Math.random() < 0.4) {
ai4Action = 'randomMove';
ai4TargetX = 1200 + Math.random() * 900;
} else {
ai4Action = 'idle';
}
} else if (!closestTarget_4.player) {
ai4Action = 'idle';
}
}
if (ai4Action === 'attack' && closestTarget_4.player) {
player4.attack(closestTarget_4.player.x, closestTarget_4.player.y);
ai4Action = 'idle';
} else if (ai4Action === 'moveToPlayer' || ai4Action === 'randomMove') {
var deltaX_4 = ai4TargetX - player4.x;
if (Math.abs(deltaX_4) > 50) {
player4.velocityX += deltaX_4 * 0.22;
}
if (Math.abs(deltaX_4) > 150 && player4.onGround && Math.random() < 0.2) {
if (player4.jumpsRemaining > 0) {
player4.velocityY = -player4.jumpPower;
player4.jumpsRemaining--;
player4.onGround = false;
LK.getSound('jump').play();
}
}
if (Math.abs(deltaX_4) < 100) {
ai4Action = 'idle';
}
}
if (player4.y > 2500 && player4.jumpsRemaining > 0) {
player4.velocityY = -player4.jumpPower;
player4.jumpsRemaining--;
player4.onGround = false;
LK.getSound('jump').play();
}
}
// Update all fighters
for (var i = fighters.length - 1; i >= 0; i--) {
if (fighters[i] && !fighters[i].destroyed) {
fighters[i].update();
}
}
// Update all powerups
for (var i = powerups.length - 1; i >= 0; i--) {
if (powerups[i] && !powerups[i].destroyed) {
powerups[i].update();
}
}
// Update all wheel powerups
for (var i = wheelPowerups.length - 1; i >= 0; i--) {
if (wheelPowerups[i] && !wheelPowerups[i].destroyed) {
wheelPowerups[i].update();
}
}
// Update all smoke trails
for (var i = smokeTrails.length - 1; i >= 0; i--) {
if (smokeTrails[i] && !smokeTrails[i].destroyed) {
smokeTrails[i].update();
}
}
// Update camera every 10 frames for smooth performance
cameraUpdateTimer++;
if (cameraUpdateTimer >= 10) {
cameraUpdateTimer = 0;
updateCamera();
}
// Apply smooth camera movement
applyCameraSmoothing();
}; ===================================================================
--- original.js
+++ change.js
@@ -228,10 +228,10 @@
fighterGraphics.scaleY = targetScale;
}
// Handle wheel mode rotation and physics
if (self.isWheelMode && self.wheelGraphics) {
- // Rotate wheel image based on movement direction only
- if (Math.abs(self.velocityX) > 1) {
+ // Only rotate wheel when moving and not on ground, or when on ground with sufficient velocity
+ if (!self.onGround && Math.abs(self.velocityX) > 1 || self.onGround && Math.abs(self.velocityX) > 2) {
self.wheelGraphics.rotation += self.velocityX * 0.1;
}
// Add bounce effect when hitting ground
if (self.onGround && Math.abs(self.velocityY) > 5) {
@@ -265,12 +265,10 @@
var platformTop = platform.y - platform.height / 2;
var platformBottom = platform.y + platform.height / 2;
// Check if player is within platform horizontal bounds and approaching from above
if (self.x >= platformLeft && self.x <= platformRight && self.y >= platformTop - 20 && self.y <= platformBottom + 5 && self.velocityY >= 0) {
- // Adjust ground position for wheel mode to prevent clipping
- var groundOffset = self.isWheelMode ? -60 : 0; // Offset wheel players higher to prevent clipping
// Snap player to exact platform surface
- self.y = platformTop + groundOffset;
+ self.y = platformTop;
self.velocityY = 0;
// Play landing sound if just landed (wasn't on ground before)
if (!wasOnGround) {
LK.getSound('landing').play();
Slime azul, pixelart. In-Game asset. 2d. High contrast. No shadows
Slime rojo, pixelart. In-Game asset. 2d. High contrast. No shadows
Slime amarillo, pixelart. In-Game asset. 2d. High contrast. No shadows
Slime verde, pixelart. In-Game asset. 2d. High contrast. No shadows
Montañas en atardecer pixelart. In-Game asset. 2d. High contrast. No shadows
Elimina la montaña
Burbuja azul, una , pixelart. In-Game asset. 2d. High contrast. No shadows
Esfera amarilla con la letra P , pixelart. In-Game asset. 2d. High contrast. No shadows
Flecha azul de Slime , pixelart. In-Game asset. 2d. High contrast. No shadows
Cámbiale el color a rojo , pixelart
Cámbiale el color a amarillo, pixelart
Cámbiale el color a verde, pixelart
Apaga las luces de la ventanas
Luciérnaga, pixelart. In-Game asset. 2d. High contrast. No shadows
Cabeza de girasol, pixelart. In-Game asset. 2d. High contrast. No shadows
Número 1 azul , pixelart. In-Game asset. 2d. High contrast. No shadows
Número 0 azul, pixelart. In-Game asset. 2d. High contrast. No shadows
Número 3 azul, pixelart. In-Game asset. 2d. High contrast. No shadows
Retro, pixelart