/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Building = Container.expand(function () { var self = Container.call(this); var buildingGraphics = self.attachAsset('cityBuilding', { anchorX: 0.5, anchorY: 1.0 }); return self; }); var Cure = Container.expand(function () { var self = Container.call(this); var cureGraphics = self.attachAsset('cure', { anchorX: 0.5, anchorY: 0.5 }); self.healAmount = 25; self.floatPhase = 0; self.baseY = 0; self.glowPhase = 0; self.update = function () { // Floating animation self.floatPhase += 0.05; self.y = self.baseY + Math.sin(self.floatPhase) * 10; // Gentle glow effect self.glowPhase += 0.08; cureGraphics.alpha = 0.8 + Math.sin(self.glowPhase) * 0.2; // Slow rotation cureGraphics.rotation += 0.02; // Ensure visibility cureGraphics.visible = true; }; return self; }); var Enemy = Container.expand(function (enemyType) { var self = Container.call(this); var enemyGraphics = self.attachAsset(enemyType, { anchorX: 0.5, anchorY: 0.5 }); // Set health and damage based on enemy type with progressive difficulty var difficultyMultiplier = currentRound * 0.5; switch (enemyType) { case 'enemy1': self.health = 80 + currentRound * 20; self.damage = 20 + currentRound * 5; self.shootDelay = Math.max(30, 90 - currentRound * 10); // Gets faster each round break; case 'enemy2': self.health = 120 + currentRound * 30; self.damage = 30 + currentRound * 8; self.shootDelay = Math.max(25, 75 - currentRound * 10); break; case 'enemy3': self.health = 100 + currentRound * 25; self.damage = 25 + currentRound * 6; self.shootDelay = Math.max(35, 80 - currentRound * 6); break; case 'enemy4': self.health = 100 + currentRound * 20; self.damage = 25 + currentRound * 5; self.shootDelay = Math.max(30, 70 - currentRound * 4); break; case 'enemy5': self.health = 120 + currentRound * 20; self.damage = 30 + currentRound * 6; self.shootDelay = Math.max(30, 70 - currentRound * 3); break; } self.maxHealth = self.health; self.shootTimer = 0; self.moveDirection = 1; self.speed = 2 + currentRound * 0.5; self.isMoving = false; self.takeDamage = function (damage) { self.health -= damage; LK.effects.flashObject(self, 0xffffff, 200); if (self.health <= 0) { self.health = 0; return true; // Enemy destroyed } return false; }; self.update = function () { // Active movement patterns based on round if (!self.isMoving && Math.random() < 0.02 + currentRound * 0.005) { self.isMoving = true; var movementPattern = Math.floor(Math.random() * 3); switch (movementPattern) { case 0: // Vertical movement var newY = 200 + Math.random() * 1300; tween(self, { y: newY }, { duration: 1000 + Math.random() * 1000, easing: tween.easeInOut, onFinish: function onFinish() { self.isMoving = false; } }); break; case 1: // Horizontal movement var newX = Math.max(1200, Math.min(1900, self.x + (Math.random() - 0.5) * 400)); tween(self, { x: newX }, { duration: 800 + Math.random() * 800, easing: tween.easeInOut, onFinish: function onFinish() { self.isMoving = false; } }); break; case 2: // Diagonal movement var newX = Math.max(1200, Math.min(1900, self.x + (Math.random() - 0.5) * 300)); var newY = 200 + Math.random() * 1300; tween(self, { x: newX, y: newY }, { duration: 1200 + Math.random() * 800, easing: tween.easeInOut, onFinish: function onFinish() { self.isMoving = false; } }); break; } } // Basic movement fallback self.y += self.moveDirection * self.speed; if (self.y < 200 || self.y > 1500) { self.moveDirection *= -1; } // Shoot at Superman with increased frequency self.shootTimer++; if (self.shootTimer >= self.shootDelay) { self.shootTimer = 0; self.shoot(); } }; self.shoot = function () { var bulletSpeed = 8 + currentRound * 2; var bulletCount = currentRound >= 3 ? 2 : 1; // Determine bullet type based on enemy type var BulletClass; switch (enemyType) { case 'enemy1': BulletClass = EnemyBullet1; break; case 'enemy2': BulletClass = EnemyBullet2; break; case 'enemy3': BulletClass = EnemyBullet3; break; case 'enemy4': BulletClass = EnemyBullet4; break; case 'enemy5': BulletClass = EnemyBullet5; break; default: BulletClass = EnemyBullet1; } for (var b = 0; b < bulletCount; b++) { var bullet = new BulletClass(); bullet.x = self.x - 50; bullet.y = self.y + (b * 40 - 20); bullet.damage = self.damage; // Special handling for wave bullets (enemy3) if (enemyType === 'enemy3') { bullet.originalY = bullet.y; } // Calculate direction to Superman var dx = superman.x - bullet.x; var dy = superman.y - bullet.y; var distance = Math.sqrt(dx * dx + dy * dy); // Add spread for multiple bullets if (bulletCount > 1) { var spreadAngle = (b - 0.5) * 0.3; var cos = Math.cos(spreadAngle); var sin = Math.sin(spreadAngle); var tempX = dx * cos - dy * sin; var tempY = dx * sin + dy * cos; dx = tempX; dy = tempY; distance = Math.sqrt(dx * dx + dy * dy); } // Normalize direction and set velocity (except for wave bullets) if (enemyType !== 'enemy3') { bullet.velocityX = dx / distance * bulletSpeed; bullet.velocityY = dy / distance * bulletSpeed; } else { bullet.velocityX = dx / distance * bulletSpeed; bullet.velocityY = 0; // Wave bullets don't use velocityY } enemyBullets.push(bullet); game.addChild(bullet); // Play specific sound for each enemy type switch (enemyType) { case 'enemy1': LK.getSound('enemyShoot1').play(); break; case 'enemy2': LK.getSound('enemyShoot2').play(); break; case 'enemy3': LK.getSound('enemyShoot3').play(); break; case 'enemy4': LK.getSound('enemyShoot4').play(); break; case 'enemy5': LK.getSound('enemyShoot5').play(); break; } } }; return self; }); var EnemyBullet1 = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('enemyBullet1', { anchorX: 0.5, anchorY: 0.5 }); self.velocityX = -8; self.velocityY = 0; self.damage = 10; self.update = function () { self.x += self.velocityX; self.y += self.velocityY; }; return self; }); var EnemyBullet2 = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('enemyBullet2', { anchorX: 0.5, anchorY: 0.5 }); self.velocityX = -8; self.velocityY = 0; self.damage = 15; self.rotationSpeed = 0.1; self.update = function () { self.x += self.velocityX; self.y += self.velocityY; bulletGraphics.rotation += self.rotationSpeed; }; return self; }); var EnemyBullet3 = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('enemyBullet3', { anchorX: 0.5, anchorY: 0.5 }); self.velocityX = -8; self.velocityY = 0; self.damage = 20; self.wavePhase = 0; self.waveAmplitude = 100; self.originalY = 0; self.update = function () { self.x += self.velocityX; self.wavePhase += 0.2; self.y = self.originalY + Math.sin(self.wavePhase) * self.waveAmplitude; }; return self; }); var EnemyBullet4 = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('enemyBullet4', { anchorX: 0.5, anchorY: 0.5 }); self.velocityX = -8; self.velocityY = 0; self.damage = 25; self.pulsePhase = 0; self.baseScale = 1; self.update = function () { self.x += self.velocityX; self.y += self.velocityY; self.pulsePhase += 0.3; var scale = self.baseScale + Math.sin(self.pulsePhase) * 0.3; bulletGraphics.scale.set(scale, scale); }; return self; }); var EnemyBullet5 = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('enemyBullet5', { anchorX: 0.5, anchorY: 0.5 }); self.velocityX = -8; self.velocityY = 0; self.damage = 30; self.acceleration = 0.2; self.rotationSpeed = 0.15; self.update = function () { self.velocityX -= self.acceleration; self.velocityY += (Math.random() - 0.5) * 0.5; self.x += self.velocityX; self.y += self.velocityY; bulletGraphics.rotation += self.rotationSpeed; }; return self; }); var HeatVision = Container.expand(function () { var self = Container.call(this); var heatGraphics = self.attachAsset('heatVision', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 15; self.damage = 20; self.update = function () { self.x += self.speed; }; return self; }); var Moon = Container.expand(function () { var self = Container.call(this); var moonGraphics = self.attachAsset('moon', { anchorX: 0.5, anchorY: 0.5 }); moonGraphics.alpha = 0.9; self.glowPhase = 0; self.update = function () { // Subtle glow effect self.glowPhase += 0.01; moonGraphics.alpha = 0.8 + Math.sin(self.glowPhase) * 0.1; }; return self; }); var Star = Container.expand(function () { var self = Container.call(this); var starGraphics = self.attachAsset('star', { anchorX: 0.5, anchorY: 0.5 }); self.baseAlpha = 0.3 + Math.random() * 0.7; self.twinkleSpeed = 0.02 + Math.random() * 0.03; self.twinklePhase = Math.random() * Math.PI * 2; self.update = function () { // Twinkling effect self.twinklePhase += self.twinkleSpeed; starGraphics.alpha = self.baseAlpha + Math.sin(self.twinklePhase) * 0.3; }; return self; }); var Superman = Container.expand(function () { var self = Container.call(this); var supermanGraphics = self.attachAsset('superman', { anchorX: 0.5, anchorY: 0.5 }); self.health = 100; self.maxHealth = 100; self.shootCooldown = 0; self.invulnerable = false; self.invulnerableTime = 0; self.takeDamage = function (damage) { if (self.invulnerable) return; self.health -= damage; self.invulnerable = true; self.invulnerableTime = 60; // 1 second at 60fps // Flash red when taking damage LK.effects.flashObject(self, 0xff0000, 500); LK.getSound('hit').play(); if (self.health <= 0) { self.health = 0; gameOver = true; } }; self.update = function () { if (self.shootCooldown > 0) { self.shootCooldown--; } if (self.invulnerableTime > 0) { self.invulnerableTime--; if (self.invulnerableTime <= 0) { self.invulnerable = false; } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x0f0f23 }); /**** * Game Code ****/ var superman = null; var heatVisionBeams = []; var enemies = []; var enemyBullets = []; var buildings = []; var stars = []; var moon = null; var currentRound = 1; var maxRounds = 5; var gameOver = false; var roundComplete = false; var dragNode = null; var cures = []; // Enemy types for each round var enemyTypes = ['enemy1', 'enemy2', 'enemy3', 'enemy4', 'enemy5']; // Create night sky gradient background var skyGradient = LK.getAsset('heatVision', { anchorX: 0, anchorY: 0, scaleX: 34, scaleY: 228 }); skyGradient.x = 0; skyGradient.y = 0; skyGradient.alpha = 0.3; skyGradient.tint = 0x1a1a3a; game.addChild(skyGradient); // Create stars for (var i = 0; i < 80; i++) { var star = new Star(); star.x = Math.random() * 2048; star.y = Math.random() * 1000; stars.push(star); game.addChild(star); } // Create moon moon = new Moon(); moon.x = 1700; moon.y = 300; game.addChild(moon); // Create city background for (var i = 0; i < 12; i++) { var building = new Building(); building.x = i * 180; building.y = 2732; building.alpha = 0.3; buildings.push(building); game.addChild(building); } // Create Superman superman = new Superman(); superman.x = 300; superman.y = 1366; game.addChild(superman); // Create UI elements var roundText = new Text2('Round: 1', { size: 60, fill: 0xFFFFFF }); roundText.anchor.set(0.5, 0); LK.gui.top.addChild(roundText); var healthText = new Text2('Health: 100', { size: 50, fill: 0xFFFFFF }); healthText.anchor.set(0, 0); healthText.x = 120; healthText.y = 10; LK.gui.topLeft.addChild(healthText); var scoreText = new Text2('Score: 0', { size: 50, fill: 0xFFFFFF }); scoreText.anchor.set(1, 0); LK.gui.topRight.addChild(scoreText); // Start first round function startRound() { if (currentRound > maxRounds) { LK.showYouWin(); return; } roundComplete = false; var enemy = new Enemy(enemyTypes[currentRound - 1]); enemy.x = 1800; enemy.y = 800; enemies.push(enemy); game.addChild(enemy); roundText.setText('Round: ' + currentRound); // Spawn 2 cures per round only when Superman merges (advances to next round) // This means cures appear when advancing from one round to the next if (currentRound > 1) { for (var c = 0; c < 2; c++) { var cure = new Cure(); cure.x = 400 + Math.random() * 1200; // Random x position in playable area cure.y = 400 + Math.random() * 1200; // Random y position in playable area cure.baseY = cure.y; cures.push(cure); game.addChild(cure); } } } // Touch controls game.down = function (x, y, obj) { dragNode = superman; superman.x = x; superman.y = y; // Shoot heat vision if (superman.shootCooldown <= 0) { var beam = new HeatVision(); beam.x = superman.x + 40; beam.y = superman.y; heatVisionBeams.push(beam); game.addChild(beam); superman.shootCooldown = 15; // 0.25 seconds LK.getSound('shoot').play(); } }; game.move = function (x, y, obj) { if (dragNode) { dragNode.x = x; dragNode.y = y; } }; game.up = function (x, y, obj) { dragNode = null; }; // Initialize first round startRound(); // Start the game music LK.playMusic('Superhero'); game.update = function () { if (gameOver) { LK.showGameOver(); return; } // Update health display healthText.setText('Health: ' + superman.health); scoreText.setText('Score: ' + LK.getScore()); // Check if round is complete if (enemies.length === 0 && !roundComplete) { roundComplete = true; currentRound++; LK.setTimeout(function () { startRound(); }, 2000); } // Update heat vision beams for (var i = heatVisionBeams.length - 1; i >= 0; i--) { var beam = heatVisionBeams[i]; // Remove if off screen if (beam.x > 2100) { beam.destroy(); heatVisionBeams.splice(i, 1); continue; } // Check collision with enemies for (var j = enemies.length - 1; j >= 0; j--) { var enemy = enemies[j]; if (beam.intersects(enemy)) { var destroyed = enemy.takeDamage(beam.damage); beam.destroy(); heatVisionBeams.splice(i, 1); if (destroyed) { LK.setScore(LK.getScore() + 100); enemy.destroy(); enemies.splice(j, 1); } break; } } } // Update enemy bullets for (var i = enemyBullets.length - 1; i >= 0; i--) { var bullet = enemyBullets[i]; // Remove if off screen if (bullet.x < -100 || bullet.x > 2148 || bullet.y < -100 || bullet.y > 2832) { bullet.destroy(); enemyBullets.splice(i, 1); continue; } // Check collision with Superman if (bullet.intersects(superman)) { superman.takeDamage(bullet.damage); bullet.destroy(); enemyBullets.splice(i, 1); } } // Update cures for (var i = cures.length - 1; i >= 0; i--) { var cure = cures[i]; // Call update method to animate cure cure.update(); // Remove if off screen if (cure.x < -100 || cure.x > 2148 || cure.y < -100 || cure.y > 2832) { cure.destroy(); cures.splice(i, 1); continue; } // Check collision with Superman if (cure.intersects(superman)) { // Heal Superman but don't exceed max health superman.health = Math.min(superman.maxHealth, superman.health + cure.healAmount); LK.effects.flashObject(superman, 0x00ff00, 300); // Green flash for healing LK.getSound('heal').play(); cure.destroy(); cures.splice(i, 1); } } // Update night sky elements for (var i = 0; i < stars.length; i++) { stars[i].update(); } if (moon) { moon.update(); } // Keep Superman within bounds if (superman.x < 40) superman.x = 40; if (superman.x > 2008) superman.x = 2008; if (superman.y < 60) superman.y = 60; if (superman.y > 2672) superman.y = 2672; };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Building = Container.expand(function () {
var self = Container.call(this);
var buildingGraphics = self.attachAsset('cityBuilding', {
anchorX: 0.5,
anchorY: 1.0
});
return self;
});
var Cure = Container.expand(function () {
var self = Container.call(this);
var cureGraphics = self.attachAsset('cure', {
anchorX: 0.5,
anchorY: 0.5
});
self.healAmount = 25;
self.floatPhase = 0;
self.baseY = 0;
self.glowPhase = 0;
self.update = function () {
// Floating animation
self.floatPhase += 0.05;
self.y = self.baseY + Math.sin(self.floatPhase) * 10;
// Gentle glow effect
self.glowPhase += 0.08;
cureGraphics.alpha = 0.8 + Math.sin(self.glowPhase) * 0.2;
// Slow rotation
cureGraphics.rotation += 0.02;
// Ensure visibility
cureGraphics.visible = true;
};
return self;
});
var Enemy = Container.expand(function (enemyType) {
var self = Container.call(this);
var enemyGraphics = self.attachAsset(enemyType, {
anchorX: 0.5,
anchorY: 0.5
});
// Set health and damage based on enemy type with progressive difficulty
var difficultyMultiplier = currentRound * 0.5;
switch (enemyType) {
case 'enemy1':
self.health = 80 + currentRound * 20;
self.damage = 20 + currentRound * 5;
self.shootDelay = Math.max(30, 90 - currentRound * 10); // Gets faster each round
break;
case 'enemy2':
self.health = 120 + currentRound * 30;
self.damage = 30 + currentRound * 8;
self.shootDelay = Math.max(25, 75 - currentRound * 10);
break;
case 'enemy3':
self.health = 100 + currentRound * 25;
self.damage = 25 + currentRound * 6;
self.shootDelay = Math.max(35, 80 - currentRound * 6);
break;
case 'enemy4':
self.health = 100 + currentRound * 20;
self.damage = 25 + currentRound * 5;
self.shootDelay = Math.max(30, 70 - currentRound * 4);
break;
case 'enemy5':
self.health = 120 + currentRound * 20;
self.damage = 30 + currentRound * 6;
self.shootDelay = Math.max(30, 70 - currentRound * 3);
break;
}
self.maxHealth = self.health;
self.shootTimer = 0;
self.moveDirection = 1;
self.speed = 2 + currentRound * 0.5;
self.isMoving = false;
self.takeDamage = function (damage) {
self.health -= damage;
LK.effects.flashObject(self, 0xffffff, 200);
if (self.health <= 0) {
self.health = 0;
return true; // Enemy destroyed
}
return false;
};
self.update = function () {
// Active movement patterns based on round
if (!self.isMoving && Math.random() < 0.02 + currentRound * 0.005) {
self.isMoving = true;
var movementPattern = Math.floor(Math.random() * 3);
switch (movementPattern) {
case 0:
// Vertical movement
var newY = 200 + Math.random() * 1300;
tween(self, {
y: newY
}, {
duration: 1000 + Math.random() * 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
self.isMoving = false;
}
});
break;
case 1:
// Horizontal movement
var newX = Math.max(1200, Math.min(1900, self.x + (Math.random() - 0.5) * 400));
tween(self, {
x: newX
}, {
duration: 800 + Math.random() * 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
self.isMoving = false;
}
});
break;
case 2:
// Diagonal movement
var newX = Math.max(1200, Math.min(1900, self.x + (Math.random() - 0.5) * 300));
var newY = 200 + Math.random() * 1300;
tween(self, {
x: newX,
y: newY
}, {
duration: 1200 + Math.random() * 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
self.isMoving = false;
}
});
break;
}
}
// Basic movement fallback
self.y += self.moveDirection * self.speed;
if (self.y < 200 || self.y > 1500) {
self.moveDirection *= -1;
}
// Shoot at Superman with increased frequency
self.shootTimer++;
if (self.shootTimer >= self.shootDelay) {
self.shootTimer = 0;
self.shoot();
}
};
self.shoot = function () {
var bulletSpeed = 8 + currentRound * 2;
var bulletCount = currentRound >= 3 ? 2 : 1;
// Determine bullet type based on enemy type
var BulletClass;
switch (enemyType) {
case 'enemy1':
BulletClass = EnemyBullet1;
break;
case 'enemy2':
BulletClass = EnemyBullet2;
break;
case 'enemy3':
BulletClass = EnemyBullet3;
break;
case 'enemy4':
BulletClass = EnemyBullet4;
break;
case 'enemy5':
BulletClass = EnemyBullet5;
break;
default:
BulletClass = EnemyBullet1;
}
for (var b = 0; b < bulletCount; b++) {
var bullet = new BulletClass();
bullet.x = self.x - 50;
bullet.y = self.y + (b * 40 - 20);
bullet.damage = self.damage;
// Special handling for wave bullets (enemy3)
if (enemyType === 'enemy3') {
bullet.originalY = bullet.y;
}
// Calculate direction to Superman
var dx = superman.x - bullet.x;
var dy = superman.y - bullet.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Add spread for multiple bullets
if (bulletCount > 1) {
var spreadAngle = (b - 0.5) * 0.3;
var cos = Math.cos(spreadAngle);
var sin = Math.sin(spreadAngle);
var tempX = dx * cos - dy * sin;
var tempY = dx * sin + dy * cos;
dx = tempX;
dy = tempY;
distance = Math.sqrt(dx * dx + dy * dy);
}
// Normalize direction and set velocity (except for wave bullets)
if (enemyType !== 'enemy3') {
bullet.velocityX = dx / distance * bulletSpeed;
bullet.velocityY = dy / distance * bulletSpeed;
} else {
bullet.velocityX = dx / distance * bulletSpeed;
bullet.velocityY = 0; // Wave bullets don't use velocityY
}
enemyBullets.push(bullet);
game.addChild(bullet);
// Play specific sound for each enemy type
switch (enemyType) {
case 'enemy1':
LK.getSound('enemyShoot1').play();
break;
case 'enemy2':
LK.getSound('enemyShoot2').play();
break;
case 'enemy3':
LK.getSound('enemyShoot3').play();
break;
case 'enemy4':
LK.getSound('enemyShoot4').play();
break;
case 'enemy5':
LK.getSound('enemyShoot5').play();
break;
}
}
};
return self;
});
var EnemyBullet1 = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('enemyBullet1', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = -8;
self.velocityY = 0;
self.damage = 10;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
};
return self;
});
var EnemyBullet2 = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('enemyBullet2', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = -8;
self.velocityY = 0;
self.damage = 15;
self.rotationSpeed = 0.1;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
bulletGraphics.rotation += self.rotationSpeed;
};
return self;
});
var EnemyBullet3 = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('enemyBullet3', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = -8;
self.velocityY = 0;
self.damage = 20;
self.wavePhase = 0;
self.waveAmplitude = 100;
self.originalY = 0;
self.update = function () {
self.x += self.velocityX;
self.wavePhase += 0.2;
self.y = self.originalY + Math.sin(self.wavePhase) * self.waveAmplitude;
};
return self;
});
var EnemyBullet4 = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('enemyBullet4', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = -8;
self.velocityY = 0;
self.damage = 25;
self.pulsePhase = 0;
self.baseScale = 1;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.pulsePhase += 0.3;
var scale = self.baseScale + Math.sin(self.pulsePhase) * 0.3;
bulletGraphics.scale.set(scale, scale);
};
return self;
});
var EnemyBullet5 = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('enemyBullet5', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = -8;
self.velocityY = 0;
self.damage = 30;
self.acceleration = 0.2;
self.rotationSpeed = 0.15;
self.update = function () {
self.velocityX -= self.acceleration;
self.velocityY += (Math.random() - 0.5) * 0.5;
self.x += self.velocityX;
self.y += self.velocityY;
bulletGraphics.rotation += self.rotationSpeed;
};
return self;
});
var HeatVision = Container.expand(function () {
var self = Container.call(this);
var heatGraphics = self.attachAsset('heatVision', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.damage = 20;
self.update = function () {
self.x += self.speed;
};
return self;
});
var Moon = Container.expand(function () {
var self = Container.call(this);
var moonGraphics = self.attachAsset('moon', {
anchorX: 0.5,
anchorY: 0.5
});
moonGraphics.alpha = 0.9;
self.glowPhase = 0;
self.update = function () {
// Subtle glow effect
self.glowPhase += 0.01;
moonGraphics.alpha = 0.8 + Math.sin(self.glowPhase) * 0.1;
};
return self;
});
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.attachAsset('star', {
anchorX: 0.5,
anchorY: 0.5
});
self.baseAlpha = 0.3 + Math.random() * 0.7;
self.twinkleSpeed = 0.02 + Math.random() * 0.03;
self.twinklePhase = Math.random() * Math.PI * 2;
self.update = function () {
// Twinkling effect
self.twinklePhase += self.twinkleSpeed;
starGraphics.alpha = self.baseAlpha + Math.sin(self.twinklePhase) * 0.3;
};
return self;
});
var Superman = Container.expand(function () {
var self = Container.call(this);
var supermanGraphics = self.attachAsset('superman', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 100;
self.maxHealth = 100;
self.shootCooldown = 0;
self.invulnerable = false;
self.invulnerableTime = 0;
self.takeDamage = function (damage) {
if (self.invulnerable) return;
self.health -= damage;
self.invulnerable = true;
self.invulnerableTime = 60; // 1 second at 60fps
// Flash red when taking damage
LK.effects.flashObject(self, 0xff0000, 500);
LK.getSound('hit').play();
if (self.health <= 0) {
self.health = 0;
gameOver = true;
}
};
self.update = function () {
if (self.shootCooldown > 0) {
self.shootCooldown--;
}
if (self.invulnerableTime > 0) {
self.invulnerableTime--;
if (self.invulnerableTime <= 0) {
self.invulnerable = false;
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x0f0f23
});
/****
* Game Code
****/
var superman = null;
var heatVisionBeams = [];
var enemies = [];
var enemyBullets = [];
var buildings = [];
var stars = [];
var moon = null;
var currentRound = 1;
var maxRounds = 5;
var gameOver = false;
var roundComplete = false;
var dragNode = null;
var cures = [];
// Enemy types for each round
var enemyTypes = ['enemy1', 'enemy2', 'enemy3', 'enemy4', 'enemy5'];
// Create night sky gradient background
var skyGradient = LK.getAsset('heatVision', {
anchorX: 0,
anchorY: 0,
scaleX: 34,
scaleY: 228
});
skyGradient.x = 0;
skyGradient.y = 0;
skyGradient.alpha = 0.3;
skyGradient.tint = 0x1a1a3a;
game.addChild(skyGradient);
// Create stars
for (var i = 0; i < 80; i++) {
var star = new Star();
star.x = Math.random() * 2048;
star.y = Math.random() * 1000;
stars.push(star);
game.addChild(star);
}
// Create moon
moon = new Moon();
moon.x = 1700;
moon.y = 300;
game.addChild(moon);
// Create city background
for (var i = 0; i < 12; i++) {
var building = new Building();
building.x = i * 180;
building.y = 2732;
building.alpha = 0.3;
buildings.push(building);
game.addChild(building);
}
// Create Superman
superman = new Superman();
superman.x = 300;
superman.y = 1366;
game.addChild(superman);
// Create UI elements
var roundText = new Text2('Round: 1', {
size: 60,
fill: 0xFFFFFF
});
roundText.anchor.set(0.5, 0);
LK.gui.top.addChild(roundText);
var healthText = new Text2('Health: 100', {
size: 50,
fill: 0xFFFFFF
});
healthText.anchor.set(0, 0);
healthText.x = 120;
healthText.y = 10;
LK.gui.topLeft.addChild(healthText);
var scoreText = new Text2('Score: 0', {
size: 50,
fill: 0xFFFFFF
});
scoreText.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreText);
// Start first round
function startRound() {
if (currentRound > maxRounds) {
LK.showYouWin();
return;
}
roundComplete = false;
var enemy = new Enemy(enemyTypes[currentRound - 1]);
enemy.x = 1800;
enemy.y = 800;
enemies.push(enemy);
game.addChild(enemy);
roundText.setText('Round: ' + currentRound);
// Spawn 2 cures per round only when Superman merges (advances to next round)
// This means cures appear when advancing from one round to the next
if (currentRound > 1) {
for (var c = 0; c < 2; c++) {
var cure = new Cure();
cure.x = 400 + Math.random() * 1200; // Random x position in playable area
cure.y = 400 + Math.random() * 1200; // Random y position in playable area
cure.baseY = cure.y;
cures.push(cure);
game.addChild(cure);
}
}
}
// Touch controls
game.down = function (x, y, obj) {
dragNode = superman;
superman.x = x;
superman.y = y;
// Shoot heat vision
if (superman.shootCooldown <= 0) {
var beam = new HeatVision();
beam.x = superman.x + 40;
beam.y = superman.y;
heatVisionBeams.push(beam);
game.addChild(beam);
superman.shootCooldown = 15; // 0.25 seconds
LK.getSound('shoot').play();
}
};
game.move = function (x, y, obj) {
if (dragNode) {
dragNode.x = x;
dragNode.y = y;
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Initialize first round
startRound();
// Start the game music
LK.playMusic('Superhero');
game.update = function () {
if (gameOver) {
LK.showGameOver();
return;
}
// Update health display
healthText.setText('Health: ' + superman.health);
scoreText.setText('Score: ' + LK.getScore());
// Check if round is complete
if (enemies.length === 0 && !roundComplete) {
roundComplete = true;
currentRound++;
LK.setTimeout(function () {
startRound();
}, 2000);
}
// Update heat vision beams
for (var i = heatVisionBeams.length - 1; i >= 0; i--) {
var beam = heatVisionBeams[i];
// Remove if off screen
if (beam.x > 2100) {
beam.destroy();
heatVisionBeams.splice(i, 1);
continue;
}
// Check collision with enemies
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (beam.intersects(enemy)) {
var destroyed = enemy.takeDamage(beam.damage);
beam.destroy();
heatVisionBeams.splice(i, 1);
if (destroyed) {
LK.setScore(LK.getScore() + 100);
enemy.destroy();
enemies.splice(j, 1);
}
break;
}
}
}
// Update enemy bullets
for (var i = enemyBullets.length - 1; i >= 0; i--) {
var bullet = enemyBullets[i];
// Remove if off screen
if (bullet.x < -100 || bullet.x > 2148 || bullet.y < -100 || bullet.y > 2832) {
bullet.destroy();
enemyBullets.splice(i, 1);
continue;
}
// Check collision with Superman
if (bullet.intersects(superman)) {
superman.takeDamage(bullet.damage);
bullet.destroy();
enemyBullets.splice(i, 1);
}
}
// Update cures
for (var i = cures.length - 1; i >= 0; i--) {
var cure = cures[i];
// Call update method to animate cure
cure.update();
// Remove if off screen
if (cure.x < -100 || cure.x > 2148 || cure.y < -100 || cure.y > 2832) {
cure.destroy();
cures.splice(i, 1);
continue;
}
// Check collision with Superman
if (cure.intersects(superman)) {
// Heal Superman but don't exceed max health
superman.health = Math.min(superman.maxHealth, superman.health + cure.healAmount);
LK.effects.flashObject(superman, 0x00ff00, 300); // Green flash for healing
LK.getSound('heal').play();
cure.destroy();
cures.splice(i, 1);
}
}
// Update night sky elements
for (var i = 0; i < stars.length; i++) {
stars[i].update();
}
if (moon) {
moon.update();
}
// Keep Superman within bounds
if (superman.x < 40) superman.x = 40;
if (superman.x > 2008) superman.x = 2008;
if (superman.y < 60) superman.y = 60;
if (superman.y > 2672) superman.y = 2672;
};
Superman 2d game. In-Game asset. 2d. High contrast. No shadows
City building 2d game long and grey with windows. In-Game asset. 2d. High contrast
Aggressive strong big robot 2d game right side. In-Game asset. 2d. High contrast. No shadows
Mad strong person like the joker 2d game. In-Game asset. 2d. High contrast. No shadows
Savage alien strong 2d game. In-Game asset. 2d. High contrast. No shadows
Mad strong wizard dc world 2d game. In-Game asset. 2d. High contrast. No shadows
Dark superman 2d game. In-Game asset. 2d. High contrast. No shadows
Robot bullet 2d game. In-Game asset. 2d. High contrast. No shadows
Knife 2d game. In-Game asset. 2d. High contrast. No shadows
Thunder 2d game. In-Game asset. 2d. High contrast. No shadows
Superhero heal. In-Game asset. 2d. High contrast. No shadows