User prompt
oyun sonunda canavar olmasın heart da olmasın
User prompt
300 altın toplandığında bölümün sonunda büyük bir uzaylıya karşı savaş yapalım uzaylıya ateş atalım uzaylının canı üstte sağda gözüksün uzaylı da bana ateş yollasın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
oyun bittiği zaman karakter ilerleyemesin ve hareket edilemesin oyun tekrar başladığında ise sıfırdan coın sıfırlansın
User prompt
oyun bittiği zaman arka planda oyun devam etmesin oyun yeniden başlasn ve coınler sıfırlansın
User prompt
oyun bitiş ekranından sonra oyunu başlattımızda karakterden 2 tane oluyor onu düzelt tek karakter yap
User prompt
oyunda 5 canınız vardır yazısısını büyük yap ve rengi kırmızı olsun yazının altına da şunu yaz ; ( You have 5 lives ) aynı şekilde oda büyük ve kırmızı olsun
User prompt
oyun başlama ekranındaki play yazısının altına şunu yaz ; (Oyunda 5 canınız vardır)
User prompt
oyun başlama ekranındaki resmi sil
User prompt
oyun başlama ekranındaki resim ekranı kaplasın
User prompt
oyun kaybetiş ekranına gelindiğinde müzik çalsın ve tekrar deneye basıldığında oyuna dönsün ama oyunda şarkı çalmasın
User prompt
oyun başlama müziği sadece başlama menüsünde çalsın oyun başladığı zaman kapatılsın
User prompt
OYUNA BAŞLAMA MÜZİĞİ EKLE
User prompt
VE OYUN BAŞLAMA EKRANINA RESİM EKLE RESİM YUKARIYA SABİT VE ORTADA DURMUŞ BİR ŞEKİLDE OLSUN
User prompt
TEKRAR DENEMEK İSTER MİSİN ? YAZISININ YERİNE TRY AGAIN YAZ AMA YAZI KALIN OLSUN VE SİYAH OLSUN
User prompt
oyun bitiş ekranın daki resmi yukarıya koy
User prompt
oyun bitiş arka planına resim ekle
User prompt
ve oyun sonundaki o şeffaf siyah yuvarlak şeyi kaldır
User prompt
TEKRAR DENEMEK İSTER MİSİN ? yazısının rengi beyaz olsun ve tıklandığında oyun yeniden başlansın ve yazıyı biraz büyüt
User prompt
TOPLANAN COIN YAZISI AŞAĞI YUKARI DOĞRU HAREKET ETSİN 5 SANİYE BOYUNCA( o yazı aşağıda olsun) VE ALTTAKİ SİYAH YAZININ YERİNE DE TEKRAR DENEMEK İSTER MİSİN ? yazsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
TOPLANAN COIN YAZISININ RENGİ SARI OLSUN VE TAHTANIN ESVİYESİNDE OLSUN
User prompt
coın collected yazısını biraz daha aşağıya koy ve oraya TOPLANAN COIN yaz
User prompt
ve bütün canlar bitip kaybettiğimiz zaman oyun sonunda toplanılan coın sayısını belirtsin ve birde oyun kaybetiş ekranında bir resim olsun ve tekrar denemek ister misin ? :) yazsın yazının rengi siyah olsun ve biraz italic ve birazda kalın olsun
User prompt
güzel ama yukarı giden kuş tahtanın seviyesinde olsun diğeri güzel ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
yukarı ve aşağı derken sola doğru yani karaktere doğru yukarıdan gelen kuş ve aşağıdan gelen kuş ( geldikleri yön orta , gidecekleri yön düz bir şekilde sola doğru hiçbir yere sapmıyacaklar ) ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
kuşlar sadece ortada gitsin ben kuşların bazılarının aşağı düz ve bazılarınında yukarı düz bir şekilde gitmesini istiyorum ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Alien = Container.expand(function () {
var self = Container.call(this);
var alienGraphics = self.attachAsset('bomb', {
// Using bomb asset as alien placeholder
anchorX: 0.5,
anchorY: 0.5
});
alienGraphics.scaleX = 3;
alienGraphics.scaleY = 3;
alienGraphics.tint = 0x00FF00; // Green tint for alien
self.health = 50;
self.maxHealth = 50;
self.shootTimer = 0;
self.moveTimer = 0;
self.verticalDirection = 1;
self.update = function () {
// Move alien up and down
self.moveTimer++;
if (self.moveTimer >= 60) {
self.verticalDirection *= -1;
self.moveTimer = 0;
}
self.y += self.verticalDirection * 2;
// Keep alien within bounds
if (self.y < 400) self.y = 400;
if (self.y > 1800) self.y = 1800;
// Shoot at player
self.shootTimer++;
if (self.shootTimer >= 90) {
// Shoot every 1.5 seconds
shootAtPlayer();
self.shootTimer = 0;
}
};
return self;
});
var AlienBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('thorn', {
anchorX: 0.5,
anchorY: 0.5
});
bulletGraphics.scaleX = 0.5;
bulletGraphics.scaleY = 0.5;
bulletGraphics.tint = 0xFF0000; // Red alien bullets
self.velocityX = 0;
self.velocityY = 0;
self.hasHit = false;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
if (!self.hasHit && self.intersects(mario)) {
self.hasHit = true;
takeDamage();
}
};
return self;
});
var Bird = Container.expand(function () {
var self = Container.call(this);
var birdGraphics = self.attachAsset('bird', {
anchorX: 0.5,
anchorY: 0.5
});
self.hasHit = false;
self.verticalDirection = 0; // Always fly straight horizontally
self.update = function () {
// Move towards character (left) faster than game speed
self.x -= gameSpeed + 6;
// Birds fly straight horizontally - no vertical movement
if (!self.hasHit && self.intersects(mario)) {
self.hasHit = true;
takeDamage();
}
};
return self;
});
var Bomb = Container.expand(function () {
var self = Container.call(this);
var bombGraphics = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 1.0
});
self.hasHit = false;
self.update = function () {
self.x -= gameSpeed;
if (!self.hasHit && self.intersects(mario)) {
self.hasHit = true;
takeDamage();
}
};
return self;
});
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
self.collected = false;
self.update = function () {
self.x -= gameSpeed;
if (!self.collected && self.intersects(mario)) {
self.collected = true;
LK.setScore(LK.getScore() + 10);
scoreTxt.setText(LK.getScore());
LK.getSound('coin').play();
self.alpha = 0;
// Check if we collected exactly 300 coins to start boss battle
if (LK.getScore() === 300) {
startBossBattle();
} else if (LK.getScore() % 200 === 0 && LK.getScore() > 0 && LK.getScore() !== 300) {
spawnDoor();
}
}
};
return self;
});
var Door = Container.expand(function () {
var self = Container.call(this);
var doorGraphics = self.attachAsset('door', {
anchorX: 0.5,
anchorY: 1.0
});
self.hasEntered = false;
self.update = function () {
self.x -= gameSpeed;
if (!self.hasEntered && self.intersects(mario)) {
self.hasEntered = true;
nextLevel();
}
};
return self;
});
var GameOverScreen = Container.expand(function () {
var self = Container.call(this);
self.visible = false;
// Add background image
var backgroundImg = self.attachAsset('gameOverBackground', {
anchorX: 0.5,
anchorY: 0.5
});
backgroundImg.x = 1024;
backgroundImg.y = 800;
// Game over image
var gameOverImg = self.attachAsset('gameOverImage', {
anchorX: 0.5,
anchorY: 0.5
});
gameOverImg.x = 1024;
gameOverImg.y = 800;
// Coins collected text
self.coinsText = new Text2('', {
size: 80,
fill: 0xFFD700
});
self.coinsText.anchor.set(0.5, 0.5);
self.coinsText.x = 1024;
self.coinsText.y = 1500; // Position lower on screen
self.addChild(self.coinsText);
// Retry text with bold black styling
self.retryText = new Text2('TRY AGAIN', {
size: 80,
fill: 0x000000,
fontStyle: 'bold'
});
self.retryText.anchor.set(0.5, 0.5);
self.retryText.x = 1024;
self.retryText.y = 1700;
self.addChild(self.retryText);
self.retryText.down = function (x, y, obj) {
// Restart game when retry text is clicked
LK.stopMusic();
self.hide();
restartGame();
};
self.show = function (coinCount) {
self.coinsText.setText('TOPLANAN COIN ' + coinCount);
self.visible = true;
LK.playMusic('gameOverMusic');
// Start upward movement animation for 5 seconds
var startY = self.coinsText.y;
var targetY = startY - 100; // Move up 100 pixels
tween(self.coinsText, {
y: targetY
}, {
duration: 2500,
easing: tween.easeInOut
});
tween(self.coinsText, {
y: startY
}, {
duration: 2500,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Animation complete after 5 seconds total
}
});
};
self.hide = function () {
self.visible = false;
};
self.down = function (x, y, obj) {
// Restart game when clicked
LK.stopMusic();
self.hide();
restartGame();
};
return self;
});
var Ground = Container.expand(function () {
var self = Container.call(this);
var groundGraphics = self.attachAsset('ground', {
anchorX: 0,
anchorY: 0
});
self.update = function () {
self.x -= gameSpeed;
};
return self;
});
var Mario = Container.expand(function () {
var self = Container.call(this);
var marioGraphics = self.attachAsset('mario', {
anchorX: 0.5,
anchorY: 1.0
});
self.velocityY = 0;
self.gravity = 0.8;
self.jumpPower = -30;
self.isOnGround = false;
self.isJumping = false;
self.jump = function () {
if (self.isOnGround && !self.isJumping) {
self.velocityY = self.jumpPower;
self.isOnGround = false;
self.isJumping = true;
LK.getSound('jump').play();
}
};
self.update = function () {
self.velocityY += self.gravity;
self.y += self.velocityY;
// Check platform collisions
var onPlatform = false;
for (var i = 0; i < platforms.length; i++) {
var platform = platforms[i];
// Better platform collision - check if Mario is above platform and falling down
var marioBottom = self.y;
var platformTop = platform.y - 10;
var platformLeft = platform.x - 300; // Half of platform width (600/2)
var platformRight = platform.x + 300; // Half of platform width (600/2)
if (self.velocityY >= 0 && marioBottom >= platformTop - 20 && marioBottom <= platformTop + 20 && self.x >= platformLeft && self.x <= platformRight) {
self.y = platformTop;
self.velocityY = 0;
self.isOnGround = true;
self.isJumping = false;
onPlatform = true;
break;
}
}
// Check ground collision
if (!onPlatform && self.y >= groundY) {
self.y = groundY;
self.velocityY = 0;
self.isOnGround = true;
self.isJumping = false;
}
};
return self;
});
var Platform = Container.expand(function () {
var self = Container.call(this);
var platformGraphics = self.attachAsset('platform', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.x -= gameSpeed;
};
return self;
});
var PlayerBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
bulletGraphics.scaleX = 0.7;
bulletGraphics.scaleY = 0.7;
bulletGraphics.tint = 0x0000FF; // Blue player bullets
self.velocityX = 15;
self.velocityY = 0;
self.hasHit = false;
self.update = function () {
self.x += self.velocityX;
if (!self.hasHit && alien && self.intersects(alien)) {
self.hasHit = true;
alien.health--;
if (alien.health <= 0) {
defeatedAlien();
}
updateAlienHealthBar();
}
};
return self;
});
var Thorn = Container.expand(function () {
var self = Container.call(this);
var thornGraphics = self.attachAsset('thorn', {
anchorX: 0.5,
anchorY: 1.0
});
self.hasHit = false;
self.update = function () {
self.x -= gameSpeed;
if (!self.hasHit && self.intersects(mario)) {
self.hasHit = true;
takeDamage();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
var mario;
var groundTiles = [];
var coins = [];
var bombs = [];
var thorns = [];
var platforms = [];
var hearts = [];
var doors = [];
var birds = [];
var gameSpeed = 10;
var groundY = 2400;
var maxHealth = 5;
var currentHealth = maxHealth;
var spawnTimer = 0;
var gameStarted = false;
var gameOver = false;
var currentLevel = storage.currentLevel || 1;
var doorSpawned = false;
var gameOverScreen;
var levelTxt = new Text2('Level ' + currentLevel, {
size: 60,
fill: 0xFFFFFF
});
levelTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(levelTxt);
levelTxt.x = 120; // Avoid the platform menu icon
levelTxt.y = 20;
// Boss battle variables
var alien = null;
var alienBullets = [];
var playerBullets = [];
var bossMode = false;
var alienHealthBar = null;
var alienHealthText = null;
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var startButton = new Text2('PLAY', {
size: 120,
fill: 0xFFFFFF
});
startButton.anchor.set(0.5, 0.5);
LK.gui.center.addChild(startButton);
var healthInfoText = new Text2('(Oyunda 5 canınız vardır)', {
size: 100,
fill: 0xFF0000
});
healthInfoText.anchor.set(0.5, 0.5);
healthInfoText.x = 0;
healthInfoText.y = 100; // Position below the play button
LK.gui.center.addChild(healthInfoText);
var healthInfoEnglishText = new Text2('( You have 5 lives )', {
size: 100,
fill: 0xFF0000
});
healthInfoEnglishText.anchor.set(0.5, 0.5);
healthInfoEnglishText.x = 0;
healthInfoEnglishText.y = 200; // Position below the Turkish text
LK.gui.center.addChild(healthInfoEnglishText);
// Add background image to start screen immediately
var background = game.addChild(LK.getAsset('background', {
anchorX: 0,
anchorY: 0
}));
background.x = 0;
background.y = 0;
// Play start music on game load
LK.playMusic('startMusic');
// Create alien health display (initially hidden)
alienHealthBar = LK.getAsset('platform', {
anchorX: 0,
anchorY: 0.5
});
alienHealthBar.scaleX = 0.5;
alienHealthBar.scaleY = 0.3;
alienHealthBar.tint = 0xFF0000;
alienHealthBar.x = LK.gui.topRight.x - 300;
alienHealthBar.y = 150;
alienHealthBar.visible = false;
LK.gui.topRight.addChild(alienHealthBar);
alienHealthText = new Text2('ALIEN: 50/50', {
size: 40,
fill: 0xFFFFFF
});
alienHealthText.anchor.set(1, 0.5);
alienHealthText.x = LK.gui.topRight.x - 20;
alienHealthText.y = 150;
alienHealthText.visible = false;
LK.gui.topRight.addChild(alienHealthText);
function initializeGame() {
game.setBackgroundColor(0x87ceeb);
// Destroy existing Mario if it exists
if (mario) {
mario.destroy();
}
mario = game.addChild(new Mario());
mario.x = 300;
mario.y = groundY;
for (var i = 0; i < 15; i++) {
var ground = game.addChild(new Ground());
ground.x = i * 200;
ground.y = groundY;
groundTiles.push(ground);
}
createHearts();
if (!gameOverScreen) {
gameOverScreen = game.addChild(new GameOverScreen());
}
gameStarted = true;
gameOver = false;
startButton.visible = false;
healthInfoText.visible = false;
healthInfoEnglishText.visible = false;
gameSpeed = 10 + (currentLevel - 1) * 3; // Adjust speed based on level
levelTxt.setText('Level ' + currentLevel);
game.setBackgroundColor(0x87ceeb);
LK.stopMusic();
}
function createHearts() {
for (var i = 0; i < maxHealth; i++) {
var heart = LK.getAsset('heart', {
anchorX: 0.5,
anchorY: 0.5
});
heart.x = LK.gui.topRight.x - 60 - i * 45;
heart.y = 60;
hearts.push(heart);
LK.gui.topRight.addChild(heart);
}
}
function updateHearts() {
for (var i = 0; i < hearts.length; i++) {
hearts[i].alpha = i < currentHealth ? 1.0 : 0.3;
}
}
function takeDamage() {
if (currentHealth > 0) {
currentHealth--;
updateHearts();
LK.getSound('hurt').play();
LK.effects.flashScreen(0xff0000, 300);
if (currentHealth <= 0) {
// Show custom game over screen with coin count
gameOverScreen.show(LK.getScore());
gameStarted = false; // Stop game updates
gameOver = true; // Prevent character movement
}
}
}
function nextLevel() {
currentLevel++;
storage.currentLevel = currentLevel;
levelTxt.setText('Level ' + currentLevel);
// Show level announcement
showLevelAnnouncement();
// Increase speed each level
gameSpeed = 10 + (currentLevel - 1) * 3;
// Clear obstacles but keep coins and score
for (var i = 0; i < doors.length; i++) {
doors[i].destroy();
}
doors = [];
doorSpawned = false;
for (var i = 0; i < bombs.length; i++) {
bombs[i].destroy();
}
bombs = [];
for (var i = 0; i < thorns.length; i++) {
thorns[i].destroy();
}
thorns = [];
for (var i = 0; i < platforms.length; i++) {
platforms[i].destroy();
}
platforms = [];
for (var i = 0; i < birds.length; i++) {
birds[i].destroy();
}
birds = [];
// Reset Mario position but keep coins
mario.x = 300;
mario.y = groundY;
mario.velocityY = 0;
mario.isOnGround = true;
mario.isJumping = false;
}
function restartGame() {
// Reset all game variables
currentHealth = maxHealth;
currentLevel = 1;
storage.currentLevel = currentLevel;
doorSpawned = false;
spawnTimer = 0;
gameSpeed = 10;
gameOver = false;
// Clear all objects
for (var i = 0; i < coins.length; i++) {
coins[i].destroy();
}
coins = [];
for (var i = 0; i < bombs.length; i++) {
bombs[i].destroy();
}
bombs = [];
for (var i = 0; i < thorns.length; i++) {
thorns[i].destroy();
}
thorns = [];
for (var i = 0; i < platforms.length; i++) {
platforms[i].destroy();
}
platforms = [];
for (var i = 0; i < doors.length; i++) {
doors[i].destroy();
}
doors = [];
for (var i = 0; i < birds.length; i++) {
birds[i].destroy();
}
birds = [];
// Clear boss battle elements
if (alien) {
alien.destroy();
alien = null;
}
clearBullets();
bossMode = false;
alienHealthBar.visible = false;
alienHealthText.visible = false;
// Reset Mario
mario.x = 300;
mario.y = groundY;
mario.velocityY = 0;
mario.isOnGround = true;
mario.isJumping = false;
// Reset score and UI
LK.setScore(0);
scoreTxt.setText('0');
levelTxt.setText('Level ' + currentLevel);
updateHearts();
gameStarted = false;
startButton.visible = true;
healthInfoText.visible = true;
healthInfoEnglishText.visible = true;
LK.playMusic('startMusic');
}
function spawnDoor() {
if (!doorSpawned) {
var door = game.addChild(new Door());
door.x = 2400; // Spawn further away to give player time
door.y = groundY;
doors.push(door);
doorSpawned = true;
}
}
function startBossBattle() {
bossMode = true;
gameSpeed = 0; // Stop scrolling
// Clear all existing obstacles
clearAllObstacles();
// Spawn alien boss
alien = game.addChild(new Alien());
alien.x = 1600;
alien.y = 1000;
// Show alien health bar
alienHealthBar.visible = true;
alienHealthText.visible = true;
updateAlienHealthBar();
}
function clearAllObstacles() {
for (var i = 0; i < bombs.length; i++) {
bombs[i].destroy();
}
bombs = [];
for (var i = 0; i < thorns.length; i++) {
thorns[i].destroy();
}
thorns = [];
for (var i = 0; i < birds.length; i++) {
birds[i].destroy();
}
birds = [];
for (var i = 0; i < platforms.length; i++) {
platforms[i].destroy();
}
platforms = [];
}
function shootAtPlayer() {
if (alien && mario) {
var bullet = game.addChild(new AlienBullet());
bullet.x = alien.x;
bullet.y = alien.y;
// Calculate direction to player
var dx = mario.x - alien.x;
var dy = mario.y - alien.y;
var distance = Math.sqrt(dx * dx + dy * dy);
bullet.velocityX = dx / distance * 8;
bullet.velocityY = dy / distance * 8;
alienBullets.push(bullet);
}
}
function updateAlienHealthBar() {
if (alien && alienHealthBar && alienHealthText) {
var healthPercent = alien.health / alien.maxHealth;
alienHealthBar.scaleX = 0.5 * healthPercent;
alienHealthText.setText('ALIEN: ' + alien.health + '/' + alien.maxHealth);
}
}
function defeatedAlien() {
bossMode = false;
gameSpeed = 10 + (currentLevel - 1) * 3; // Resume normal speed
// Hide alien health bar
alienHealthBar.visible = false;
alienHealthText.visible = false;
// Clear alien and bullets
if (alien) {
alien.destroy();
alien = null;
}
clearBullets();
// Spawn door to next level
spawnDoor();
}
function clearBullets() {
for (var i = 0; i < alienBullets.length; i++) {
alienBullets[i].destroy();
}
alienBullets = [];
for (var i = 0; i < playerBullets.length; i++) {
playerBullets[i].destroy();
}
playerBullets = [];
}
function spawnObstacle() {
// Don't spawn obstacles if door is active
if (doorSpawned) {
return;
}
var rand = Math.random();
var spawnX = 2200;
if (rand < 0.25) {
var coin = game.addChild(new Coin());
coin.x = spawnX;
coin.y = groundY - 100 - Math.random() * 150;
coins.push(coin);
} else if (rand < 0.45) {
var bomb = game.addChild(new Bomb());
bomb.x = spawnX + Math.random() * 100 + 50; // Add spacing variation
bomb.y = groundY;
bombs.push(bomb);
} else if (rand < 0.65) {
var thorn = game.addChild(new Thorn());
thorn.x = spawnX + Math.random() * 100 + 50; // Add spacing variation
thorn.y = groundY;
thorns.push(thorn);
} else if (rand < 0.85) {
// Spawn platform with coins on top
var platform = game.addChild(new Platform());
platform.x = spawnX + Math.random() * 200 + 100; // Random horizontal position
platform.y = groundY - 200 - Math.random() * 300; // Random height
platforms.push(platform);
// Add 4-6 coins on the platform (spread across the long plank)
var numCoins = 4 + Math.floor(Math.random() * 3);
for (var i = 0; i < numCoins; i++) {
var coin = game.addChild(new Coin());
coin.x = platform.x - 280 + i * 140; // Spread coins across the 600px wide plank
coin.y = platform.y - 60;
coins.push(coin);
}
} else {
// Spawn flying bird
var bird = game.addChild(new Bird());
bird.x = spawnX + Math.random() * 100 + 50;
// Spawn birds either from top or bottom of screen
if (Math.random() < 0.5) {
// Spawn from top at platform level
bird.y = groundY - 200;
bird.verticalDirection = 0; // Fly straight horizontally
} else {
// Spawn from bottom
bird.y = groundY - 100;
bird.verticalDirection = 0; // Fly straight horizontally
}
birds.push(bird);
}
}
function cleanupObjects() {
for (var i = coins.length - 1; i >= 0; i--) {
if (coins[i].x < -100) {
coins[i].destroy();
coins.splice(i, 1);
}
}
for (var i = bombs.length - 1; i >= 0; i--) {
if (bombs[i].x < -100) {
bombs[i].destroy();
bombs.splice(i, 1);
}
}
for (var i = thorns.length - 1; i >= 0; i--) {
if (thorns[i].x < -100) {
thorns[i].destroy();
thorns.splice(i, 1);
}
}
for (var i = platforms.length - 1; i >= 0; i--) {
if (platforms[i].x < -500) {
platforms[i].destroy();
platforms.splice(i, 1);
}
}
for (var i = doors.length - 1; i >= 0; i--) {
if (doors[i].x < -100) {
doors[i].destroy();
doors.splice(i, 1);
}
}
for (var i = birds.length - 1; i >= 0; i--) {
if (birds[i].x < -100) {
birds[i].destroy();
birds.splice(i, 1);
}
}
for (var i = groundTiles.length - 1; i >= 0; i--) {
if (groundTiles[i].x < -400) {
var ground = game.addChild(new Ground());
ground.x = groundTiles[groundTiles.length - 1].x + 200;
ground.y = groundY;
groundTiles.push(ground);
groundTiles[i].destroy();
groundTiles.splice(i, 1);
}
}
}
game.down = function (x, y, obj) {
if (!gameStarted) {
initializeGame();
} else if (!gameOver) {
if (bossMode) {
// Shoot bullet during boss battle
var bullet = game.addChild(new PlayerBullet());
bullet.x = mario.x;
bullet.y = mario.y - 50;
playerBullets.push(bullet);
} else {
mario.jump();
}
}
};
startButton.down = function (x, y, obj) {
initializeGame();
};
var levelAnnouncementTxt = null;
var levelAnnouncementTimer = 0;
function showLevelAnnouncement() {
if (levelAnnouncementTxt) {
LK.gui.center.removeChild(levelAnnouncementTxt);
}
levelAnnouncementTxt = new Text2(currentLevel + '. LEVEL', {
size: 120,
fill: 0xFFD700
});
levelAnnouncementTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(levelAnnouncementTxt);
levelAnnouncementTimer = 120; // Show for 2 seconds at 60fps
}
game.update = function () {
if (!gameStarted) {
return;
}
// Handle level announcement display
if (levelAnnouncementTimer > 0) {
levelAnnouncementTimer--;
if (levelAnnouncementTimer <= 0 && levelAnnouncementTxt) {
LK.gui.center.removeChild(levelAnnouncementTxt);
levelAnnouncementTxt = null;
}
return; // Don't spawn obstacles while showing level announcement
}
spawnTimer++;
if (spawnTimer >= 60) {
// Reduced from 90 to 60 for faster spawning
spawnObstacle();
spawnTimer = 0;
}
if (!bossMode) {
cleanupObjects();
gameSpeed += 0.005;
} else {
// Boss battle bullet cleanup
for (var i = alienBullets.length - 1; i >= 0; i--) {
if (alienBullets[i].x < -100 || alienBullets[i].x > 2200 || alienBullets[i].y < -100 || alienBullets[i].y > 2800) {
alienBullets[i].destroy();
alienBullets.splice(i, 1);
}
}
for (var i = playerBullets.length - 1; i >= 0; i--) {
if (playerBullets[i].x > 2200 || playerBullets[i].x < -100) {
playerBullets[i].destroy();
playerBullets.splice(i, 1);
}
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -6,8 +6,66 @@
/****
* Classes
****/
+var Alien = Container.expand(function () {
+ var self = Container.call(this);
+ var alienGraphics = self.attachAsset('bomb', {
+ // Using bomb asset as alien placeholder
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ alienGraphics.scaleX = 3;
+ alienGraphics.scaleY = 3;
+ alienGraphics.tint = 0x00FF00; // Green tint for alien
+ self.health = 50;
+ self.maxHealth = 50;
+ self.shootTimer = 0;
+ self.moveTimer = 0;
+ self.verticalDirection = 1;
+ self.update = function () {
+ // Move alien up and down
+ self.moveTimer++;
+ if (self.moveTimer >= 60) {
+ self.verticalDirection *= -1;
+ self.moveTimer = 0;
+ }
+ self.y += self.verticalDirection * 2;
+ // Keep alien within bounds
+ if (self.y < 400) self.y = 400;
+ if (self.y > 1800) self.y = 1800;
+ // Shoot at player
+ self.shootTimer++;
+ if (self.shootTimer >= 90) {
+ // Shoot every 1.5 seconds
+ shootAtPlayer();
+ self.shootTimer = 0;
+ }
+ };
+ return self;
+});
+var AlienBullet = Container.expand(function () {
+ var self = Container.call(this);
+ var bulletGraphics = self.attachAsset('thorn', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ bulletGraphics.scaleX = 0.5;
+ bulletGraphics.scaleY = 0.5;
+ bulletGraphics.tint = 0xFF0000; // Red alien bullets
+ self.velocityX = 0;
+ self.velocityY = 0;
+ self.hasHit = false;
+ self.update = function () {
+ self.x += self.velocityX;
+ self.y += self.velocityY;
+ if (!self.hasHit && self.intersects(mario)) {
+ self.hasHit = true;
+ takeDamage();
+ }
+ };
+ return self;
+});
var Bird = Container.expand(function () {
var self = Container.call(this);
var birdGraphics = self.attachAsset('bird', {
anchorX: 0.5,
@@ -56,10 +114,12 @@
LK.setScore(LK.getScore() + 10);
scoreTxt.setText(LK.getScore());
LK.getSound('coin').play();
self.alpha = 0;
- // Check if we collected exactly 200 coins (or multiples of 200)
- if (LK.getScore() % 200 === 0 && LK.getScore() > 0) {
+ // Check if we collected exactly 300 coins to start boss battle
+ if (LK.getScore() === 300) {
+ startBossBattle();
+ } else if (LK.getScore() % 200 === 0 && LK.getScore() > 0 && LK.getScore() !== 300) {
spawnDoor();
}
}
};
@@ -228,8 +288,33 @@
self.x -= gameSpeed;
};
return self;
});
+var PlayerBullet = Container.expand(function () {
+ var self = Container.call(this);
+ var bulletGraphics = self.attachAsset('coin', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ bulletGraphics.scaleX = 0.7;
+ bulletGraphics.scaleY = 0.7;
+ bulletGraphics.tint = 0x0000FF; // Blue player bullets
+ self.velocityX = 15;
+ self.velocityY = 0;
+ self.hasHit = false;
+ self.update = function () {
+ self.x += self.velocityX;
+ if (!self.hasHit && alien && self.intersects(alien)) {
+ self.hasHit = true;
+ alien.health--;
+ if (alien.health <= 0) {
+ defeatedAlien();
+ }
+ updateAlienHealthBar();
+ }
+ };
+ return self;
+});
var Thorn = Container.expand(function () {
var self = Container.call(this);
var thornGraphics = self.attachAsset('thorn', {
anchorX: 0.5,
@@ -282,8 +367,15 @@
levelTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(levelTxt);
levelTxt.x = 120; // Avoid the platform menu icon
levelTxt.y = 20;
+// Boss battle variables
+var alien = null;
+var alienBullets = [];
+var playerBullets = [];
+var bossMode = false;
+var alienHealthBar = null;
+var alienHealthText = null;
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
@@ -319,8 +411,29 @@
background.x = 0;
background.y = 0;
// Play start music on game load
LK.playMusic('startMusic');
+// Create alien health display (initially hidden)
+alienHealthBar = LK.getAsset('platform', {
+ anchorX: 0,
+ anchorY: 0.5
+});
+alienHealthBar.scaleX = 0.5;
+alienHealthBar.scaleY = 0.3;
+alienHealthBar.tint = 0xFF0000;
+alienHealthBar.x = LK.gui.topRight.x - 300;
+alienHealthBar.y = 150;
+alienHealthBar.visible = false;
+LK.gui.topRight.addChild(alienHealthBar);
+alienHealthText = new Text2('ALIEN: 50/50', {
+ size: 40,
+ fill: 0xFFFFFF
+});
+alienHealthText.anchor.set(1, 0.5);
+alienHealthText.x = LK.gui.topRight.x - 20;
+alienHealthText.y = 150;
+alienHealthText.visible = false;
+LK.gui.topRight.addChild(alienHealthText);
function initializeGame() {
game.setBackgroundColor(0x87ceeb);
// Destroy existing Mario if it exists
if (mario) {
@@ -450,8 +563,17 @@
for (var i = 0; i < birds.length; i++) {
birds[i].destroy();
}
birds = [];
+ // Clear boss battle elements
+ if (alien) {
+ alien.destroy();
+ alien = null;
+ }
+ clearBullets();
+ bossMode = false;
+ alienHealthBar.visible = false;
+ alienHealthText.visible = false;
// Reset Mario
mario.x = 300;
mario.y = groundY;
mario.velocityY = 0;
@@ -476,8 +598,86 @@
doors.push(door);
doorSpawned = true;
}
}
+function startBossBattle() {
+ bossMode = true;
+ gameSpeed = 0; // Stop scrolling
+ // Clear all existing obstacles
+ clearAllObstacles();
+ // Spawn alien boss
+ alien = game.addChild(new Alien());
+ alien.x = 1600;
+ alien.y = 1000;
+ // Show alien health bar
+ alienHealthBar.visible = true;
+ alienHealthText.visible = true;
+ updateAlienHealthBar();
+}
+function clearAllObstacles() {
+ for (var i = 0; i < bombs.length; i++) {
+ bombs[i].destroy();
+ }
+ bombs = [];
+ for (var i = 0; i < thorns.length; i++) {
+ thorns[i].destroy();
+ }
+ thorns = [];
+ for (var i = 0; i < birds.length; i++) {
+ birds[i].destroy();
+ }
+ birds = [];
+ for (var i = 0; i < platforms.length; i++) {
+ platforms[i].destroy();
+ }
+ platforms = [];
+}
+function shootAtPlayer() {
+ if (alien && mario) {
+ var bullet = game.addChild(new AlienBullet());
+ bullet.x = alien.x;
+ bullet.y = alien.y;
+ // Calculate direction to player
+ var dx = mario.x - alien.x;
+ var dy = mario.y - alien.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ bullet.velocityX = dx / distance * 8;
+ bullet.velocityY = dy / distance * 8;
+ alienBullets.push(bullet);
+ }
+}
+function updateAlienHealthBar() {
+ if (alien && alienHealthBar && alienHealthText) {
+ var healthPercent = alien.health / alien.maxHealth;
+ alienHealthBar.scaleX = 0.5 * healthPercent;
+ alienHealthText.setText('ALIEN: ' + alien.health + '/' + alien.maxHealth);
+ }
+}
+function defeatedAlien() {
+ bossMode = false;
+ gameSpeed = 10 + (currentLevel - 1) * 3; // Resume normal speed
+ // Hide alien health bar
+ alienHealthBar.visible = false;
+ alienHealthText.visible = false;
+ // Clear alien and bullets
+ if (alien) {
+ alien.destroy();
+ alien = null;
+ }
+ clearBullets();
+ // Spawn door to next level
+ spawnDoor();
+}
+function clearBullets() {
+ for (var i = 0; i < alienBullets.length; i++) {
+ alienBullets[i].destroy();
+ }
+ alienBullets = [];
+ for (var i = 0; i < playerBullets.length; i++) {
+ playerBullets[i].destroy();
+ }
+ playerBullets = [];
+}
function spawnObstacle() {
// Don't spawn obstacles if door is active
if (doorSpawned) {
return;
@@ -581,9 +781,17 @@
game.down = function (x, y, obj) {
if (!gameStarted) {
initializeGame();
} else if (!gameOver) {
- mario.jump();
+ if (bossMode) {
+ // Shoot bullet during boss battle
+ var bullet = game.addChild(new PlayerBullet());
+ bullet.x = mario.x;
+ bullet.y = mario.y - 50;
+ playerBullets.push(bullet);
+ } else {
+ mario.jump();
+ }
}
};
startButton.down = function (x, y, obj) {
initializeGame();
@@ -620,7 +828,23 @@
// Reduced from 90 to 60 for faster spawning
spawnObstacle();
spawnTimer = 0;
}
- cleanupObjects();
- gameSpeed += 0.005;
+ if (!bossMode) {
+ cleanupObjects();
+ gameSpeed += 0.005;
+ } else {
+ // Boss battle bullet cleanup
+ for (var i = alienBullets.length - 1; i >= 0; i--) {
+ if (alienBullets[i].x < -100 || alienBullets[i].x > 2200 || alienBullets[i].y < -100 || alienBullets[i].y > 2800) {
+ alienBullets[i].destroy();
+ alienBullets.splice(i, 1);
+ }
+ }
+ for (var i = playerBullets.length - 1; i >= 0; i--) {
+ if (playerBullets[i].x > 2200 || playerBullets[i].x < -100) {
+ playerBullets[i].destroy();
+ playerBullets.splice(i, 1);
+ }
+ }
+ }
};
\ No newline at end of file
ince bir çimenli zemin. In-Game asset. 2d. High contrast. No shadows
bomb. In-Game asset. 2d. High contrast. No shadows
altın para. In-Game asset. 2d. High contrast. No shadows
dikenler. In-Game asset. 2d. High contrast. No shadows
bulutlu bir hava. In-Game asset. 2d. High contrast. No shadows
portal. In-Game asset. 2d. High contrast. No shadows
sinirli bir uçan kuş. In-Game asset. 2d. High contrast. No shadows
red heart. In-Game asset. 2d. High contrast. No shadows