User prompt
Upgrade menüsünde silah yerine health yazısı olsun bu upgradeyi yaptığımda karakterimin canına 2 can eklensin karakterim 10 canla değil 5 canla başlasın health upgrade coin ise 20 harcasın ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Başla tuşuna bastığımda coinlerim silinmesin
User prompt
Oyunun gameover olmasını istemiyorum eğer canım biter ve ölürsem başlangıç ekranına dönsün
User prompt
Healthbar büyücünün hemen altında yer alsın ve daha küçük yapıda olsun
User prompt
Düşmanlar büyücüye vurduğunda gameover olup oyun tamamen kapanmasın. Büyücüye bir health bar ekle düşmanlar vurdukça healthbardan düşsün toplam 10 can olsun
User prompt
Oyun bittiğinde coinlerim kaydedilsin her oyun sonunda coinler stacklensin ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Hüç yerine power hız yerine speed yazsın. BAŞLA yazısını daha yukarıya upgrade yazısını ise ekranın alt kısmına koy
User prompt
Upgrade ekranını daha büyük bir ekran yap
User prompt
Hız için fast güç için power silah için weapons assetlerini kullan
User prompt
Upgrade kısmında her bir sekmenin yanına bir asset ekle background içinde bir asset ekle farklı renkte dizayn edelim
User prompt
Başla butonunu bir ui içerisine yerleştir ve altına bir upgrade butonu ekle upgrade bastığımda yeni pencere içerisinde hız hüç silah ve geri butonu olsun
User prompt
Başla butonuna bastığımda oyun yenilensin canavarlar baştan gelsin
User prompt
Oyun açıldığında score yazısının altına ve büyücünün üzerine konumlanmış bir start butonu olsun bu butona tıklamadan oyun başlamasın
User prompt
Büyücüyü ekranın merkezi olarak kabul et. Açılış ekranını oraya koy
User prompt
Açılış ekranı ekranın ortasında olsun ve tam ekranı kaplasın
User prompt
Oyuna bir açılış ekranı ekleyelim burada start ve upgrade ekranları olsun.
User prompt
Oyuna bir açılış ekranı ekleyelim burada start ve upgrade ekranları olsun.
User prompt
Fireball yalnızca ekran içerisinde ilerleyebilsin bazen ekranda vurmadığım canavarlar için bile score puanı geliyor
User prompt
Pausegame çalışmıyor oyun duraklatılmıyor düzelt
User prompt
Shop ekranı açıldığında oyun duraklatılsın
User prompt
Fireball yalnızca ekran içerisinde ilerleyebilsin bazen ekranda vurmadığım canavarlar için bile score puanı geliyor
User prompt
Score 25 e ulaştığında oyun duraklatılsın
User prompt
Oyun durdurulmadı. O skora ulaşıldığında oyun duraklatılsın ve shop açılsın
User prompt
Please fix the bug: 'TypeError: LK.pause is not a function. (In 'LK.pause()', 'LK.pause' is undefined)' in or related to this line: 'LK.pause();' Line Number: 653
User prompt
Score puanı 25 olduğunda bir ekran açılsın ve oyun duraklatılsın. Bu ekranda itemler satılsın mesela can doldurma, silah geliştirme vb gibi
/****
* Classes
****/
// Coin class: represents coins dropped by enemies when destroyed
var Coin = Container.expand(function () {
var self = Container.call(this);
// Create a gold coin visual (using a yellow circle)
var coinSprite = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
// Coin movement properties
self.vx = 0;
self.vy = 0;
self.gravity = 0;
self.collected = false;
// Track last position for event triggers
self.lastX = 0;
self.lastY = 0;
self.lastWasIntersecting = false;
self.update = function () {
// No gravity or bounce logic needed
// Remove coin if it leaves the screen horizontally
if (self.x < -50 || self.x > 2048 + 50) {
self.destroy();
}
// Pulsate slightly for visual effect
var t = LK.ticks || Date.now();
var scale = 1 + 0.1 * Math.sin(t * 0.1);
if (self.children && self.children.length > 0) {
self.children[0].scale.x = scale;
self.children[0].scale.y = scale;
}
self.lastX = self.x;
self.lastY = self.y;
};
return self;
});
// Enemy class: represents an enemy that moves toward the wizard
var Enemy = Container.expand(function () {
var self = Container.call(this);
// Attach a unique enemy asset (pixel blue monster)
var enemySprite = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
// Enemy speed and direction
self.vx = 0;
self.vy = 0;
// Track last position for event triggers
self.lastX = 0;
self.lastY = 0;
self.health = 1; // Enemy1: 1 hit to kill
self.type = 1;
self.update = function () {
self.x += self.vx;
self.y += self.vy;
// Pulsate scale for movement effect
var t = LK.ticks || Date.now(); // fallback for safety
var scale = 1 + 0.15 * Math.sin((t + self.x + self.y) * 0.05);
if (self.children && self.children.length > 0) {
self.children[0].scale.x = scale;
self.children[0].scale.y = scale;
}
// Remove enemy if it leaves the screen
if (self.x < -100 || self.x > 2048 + 100 || self.y < -100 || self.y > 2732 + 100) {
self.destroy();
}
self.lastX = self.x;
self.lastY = self.y;
};
return self;
});
// Enemy2: needs 2 fireballs to die
var Enemy2 = Container.expand(function () {
var self = Container.call(this);
var enemySprite = self.attachAsset('enemy2', {
anchorX: 0.5,
anchorY: 0.5
});
self.vx = 0;
self.vy = 0;
self.lastX = 0;
self.lastY = 0;
self.health = 2;
self.type = 2;
self.update = function () {
self.x += self.vx;
self.y += self.vy;
var t = LK.ticks || Date.now();
var scale = 1 + 0.18 * Math.sin((t + self.x + self.y) * 0.06);
if (self.children && self.children.length > 0) {
self.children[0].scale.x = scale;
self.children[0].scale.y = scale;
}
if (self.x < -100 || self.x > 2048 + 100 || self.y < -100 || self.y > 2732 + 100) {
self.destroy();
}
self.lastX = self.x;
self.lastY = self.y;
};
return self;
});
// Enemy3: needs 3 fireballs to die
var Enemy3 = Container.expand(function () {
var self = Container.call(this);
var enemySprite = self.attachAsset('enemy3', {
anchorX: 0.5,
anchorY: 0.5
});
self.vx = 0;
self.vy = 0;
self.lastX = 0;
self.lastY = 0;
self.health = 3;
self.type = 3;
self.update = function () {
self.x += self.vx;
self.y += self.vy;
var t = LK.ticks || Date.now();
var scale = 1 + 0.22 * Math.sin((t + self.x + self.y) * 0.07);
if (self.children && self.children.length > 0) {
self.children[0].scale.x = scale;
self.children[0].scale.y = scale;
}
if (self.x < -100 || self.x > 2048 + 100 || self.y < -100 || self.y > 2732 + 100) {
self.destroy();
}
self.lastX = self.x;
self.lastY = self.y;
};
return self;
});
// Explosion class: shows a quick explosion effect at (x, y)
var Explosion = Container.expand(function () {
var self = Container.call(this);
var sprite = self.attachAsset('explosion', {
anchorX: 0.5,
anchorY: 0.5
});
// Initial scale and alpha
sprite.scale.x = 0.5;
sprite.scale.y = 0.5;
sprite.alpha = 1;
// Animate explosion: grow and fade out
var duration = 18; // frames (~0.3s)
var frame = 0;
self.update = function () {
frame++;
// Grow and fade
var progress = frame / duration;
sprite.scale.x = 0.5 + 1.2 * progress;
sprite.scale.y = 0.5 + 1.2 * progress;
sprite.alpha = 1 - progress;
if (frame >= duration) {
self.destroy();
}
};
return self;
});
// Fireball class: represents a fireball shot by the wizard
var Fireball = Container.expand(function () {
var self = Container.call(this);
// Attach fireball asset (pixel fireball)
var fireballSprite = self.attachAsset('fireball', {
anchorX: 0.5,
anchorY: 0.5
});
// Fireball speed and direction
self.vx = 0;
self.vy = 0;
// Track last position for event triggers
self.lastX = 0;
self.lastY = 0;
self.update = function () {
self.x += self.vx;
self.y += self.vy;
// Remove fireball if it leaves the screen
if (self.x < -100 || self.x > 2048 + 100 || self.y < -100 || self.y > 2732 + 100) {
self.destroy();
}
self.lastX = self.x;
self.lastY = self.y;
};
return self;
});
// Wizard class: represents the player character
var Wizard = Container.expand(function () {
var self = Container.call(this);
// Attach wizard asset (blue hat, pixel style)
var wizardSprite = self.attachAsset('wizard', {
anchorX: 0.5,
anchorY: 0.5
});
// Track last position for event triggers
self.lastX = 0;
self.lastY = 0;
// Update method (called every tick)
self.update = function () {
// No movement logic here; wizard is moved by mouse/touch
self.lastX = self.x;
self.lastY = self.y;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Explosion asset for enemy death effect
;
// Add background image to the game scene
var background = LK.getAsset('background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
width: 2048,
height: 2732
});
game.addChild(background);
// --- Game Code for Pixel Wizard: Blue Hat Adventure ---
// Create wizard instance and add to game
var wizard = new Wizard();
game.addChild(wizard);
// Center wizard on screen at start
wizard.x = 2048 / 2;
wizard.y = 2732 / 2;
// --- START & UPGRADE BUTTON UI LOGIC ---
var gameStarted = false;
// UI container for start and upgrade buttons
var startUiContainer = new Container();
// Create start button asset (simple box with text)
var startButtonWidth = 420;
var startButtonHeight = 140;
var startButton = new Container();
var startButtonBg = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
width: startButtonWidth,
height: startButtonHeight,
color: 0x1e90ff
});
startButtonBg.alpha = 0.92;
startButton.addChild(startButtonBg);
var startButtonText = new Text2("BAŞLA", {
size: 80,
fill: "#fff"
});
startButtonText.anchor.set(0.5, 0.5);
startButtonText.x = 0;
startButtonText.y = 0;
startButton.addChild(startButtonText);
// Create upgrade button below start button
var upgradeButtonWidth = 420;
var upgradeButtonHeight = 110;
var upgradeButton = new Container();
var upgradeButtonBg = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
width: upgradeButtonWidth,
height: upgradeButtonHeight,
color: 0x2ecc71
});
upgradeButtonBg.alpha = 0.92;
upgradeButton.addChild(upgradeButtonBg);
var upgradeButtonText = new Text2("UPGRADE", {
size: 60,
fill: "#fff"
});
upgradeButtonText.anchor.set(0.5, 0.5);
upgradeButtonText.x = 0;
upgradeButtonText.y = 0;
upgradeButton.addChild(upgradeButtonText);
// Position start and upgrade buttons in the UI container
startButton.x = 0;
startButton.y = 0;
upgradeButton.x = 0;
upgradeButton.y = startButton.y + startButtonHeight / 2 + 30 + upgradeButtonHeight / 2;
// Add both buttons to the UI container
startUiContainer.addChild(startButton);
startUiContainer.addChild(upgradeButton);
// Position the UI container: horizontally centered, just below score and above wizard
startUiContainer.x = 2048 / 2;
startUiContainer.y = wizard.y - 180;
// Add to game
game.addChild(startUiContainer);
// Block input until start is pressed
function blockGameInput() {
game.move = function () {};
game.down = function () {};
game.up = function () {};
isFiring = false;
if (fireInterval) {
LK.clearInterval(fireInterval);
fireInterval = null;
}
}
blockGameInput();
// --- UPGRADE WINDOW LOGIC ---
var upgradeWindow = null;
function showUpgradeWindow() {
if (upgradeWindow && !upgradeWindow.destroyed) return;
upgradeWindow = new Container();
// Window background
var winW = 700,
winH = 700;
var winBg = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
width: winW,
height: winH,
color: 0x222244
});
winBg.alpha = 0.97;
upgradeWindow.addChild(winBg);
// Title
var title = new Text2("UPGRADE", {
size: 70,
fill: "#fff"
});
title.anchor.set(0.5, 0);
title.x = 0;
title.y = -winH / 2 + 40;
upgradeWindow.addChild(title);
// Button helper
function makeUpgradeBtn(label, y, color) {
var btn = new Container();
var btnBg = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
width: 420,
height: 110,
color: color
});
btnBg.alpha = 0.93;
btn.addChild(btnBg);
var btnText = new Text2(label, {
size: 60,
fill: "#fff"
});
btnText.anchor.set(0.5, 0.5);
btnText.x = 0;
btnText.y = 0;
btn.addChild(btnText);
btn.x = 0;
btn.y = y;
return btn;
}
// Hız, Hüç, Silah, Geri buttons
var btnSpacing = 130;
var btns = [];
var btnLabels = [{
label: "HIZ",
color: 0x3498db
}, {
label: "HÜÇ",
color: 0xe67e22
}, {
label: "SİLAH",
color: 0x9b59b6
}];
for (var i = 0; i < btnLabels.length; i++) {
var btn = makeUpgradeBtn(btnLabels[i].label, -60 + i * btnSpacing, btnLabels[i].color);
upgradeWindow.addChild(btn);
btns.push(btn);
}
// Geri button
var geriBtn = makeUpgradeBtn("GERİ", 320, 0x888888);
upgradeWindow.addChild(geriBtn);
// Geri closes window
geriBtn.down = function () {
if (upgradeWindow && !upgradeWindow.destroyed) {
upgradeWindow.destroy();
upgradeWindow = null;
}
};
// Center window
upgradeWindow.x = 2048 / 2;
upgradeWindow.y = 2732 / 2;
game.addChild(upgradeWindow);
}
// Upgrade button interaction
upgradeButton.down = function (x, y, obj) {
if (upgradeWindow && !upgradeWindow.destroyed) return;
showUpgradeWindow();
};
// Start button interaction
startButton.down = function (x, y, obj) {
if (gameStarted) return;
gameStarted = true;
// Remove start UI container (removes both start and upgrade buttons)
if (startUiContainer && !startUiContainer.destroyed) {
startUiContainer.destroy();
}
// --- RESET GAME STATE ---
// Remove all enemies, fireballs, coins from game and arrays
for (var i = enemies.length - 1; i >= 0; i--) {
if (enemies[i] && !enemies[i].destroyed) enemies[i].destroy();
enemies.splice(i, 1);
}
for (var i = fireballs.length - 1; i >= 0; i--) {
if (fireballs[i] && !fireballs[i].destroyed) fireballs[i].destroy();
fireballs.splice(i, 1);
}
for (var i = coins.length - 1; i >= 0; i--) {
if (coins[i] && !coins[i].destroyed) coins[i].destroy();
coins.splice(i, 1);
}
// Reset score and coin count
score = 0;
coinCount = 0;
scoreText.setText("Score: 0");
coinText.setText("0");
// Center wizard
wizard.x = 2048 / 2;
wizard.y = 2732 / 2;
if (wizard.children && wizard.children.length > 0) {
wizard.children[0].rotation = Math.PI; // face left
}
// Enable game input
game.move = originalGameMove;
game.down = originalGameDown;
game.up = originalGameUp;
};
// Save original handlers for restoration
var originalGameMove = function originalGameMove(x, y, obj) {
// Wizard is fixed; do nothing
// Calculate angle from wizard to pointer/touch and rotate wizard sprite
var dx = x - wizard.x;
var dy = y - wizard.y;
var angle = Math.atan2(dy, dx);
// Wizard's default asset faces left, so add Math.PI to rotate to correct direction
if (wizard.children && wizard.children.length > 0) {
wizard.children[0].rotation = angle + Math.PI;
}
// If firing, update direction for continuous fire
if (isFiring) {
lastFireX = x;
lastFireY = y;
}
};
var originalGameDown = function originalGameDown(x, y, obj) {
isFiring = true;
lastFireX = x;
lastFireY = y;
shootFireballAt(x, y);
if (fireInterval) LK.clearInterval(fireInterval);
fireInterval = LK.setInterval(function () {
if (isFiring) {
shootFireballAt(lastFireX, lastFireY);
}
}, 180);
};
var originalGameUp = function originalGameUp(x, y, obj) {
isFiring = false;
if (fireInterval) {
LK.clearInterval(fireInterval);
fireInterval = null;
}
};
// Array to hold all fireballs
var fireballs = [];
// Helper: get direction vector from wizard to (x, y)
function getDirection(fromX, fromY, toX, toY, speed) {
var dx = toX - fromX;
var dy = toY - fromY;
var len = Math.sqrt(dx * dx + dy * dy);
if (len === 0) return {
vx: 0,
vy: 0
};
return {
vx: dx / len * speed,
vy: dy / len * speed
};
}
// Dragging wizard with mouse/touch (disabled)
var dragging = false;
// Move handler: wizard does not move
game.move = function (x, y, obj) {
// Wizard is fixed; do nothing
// Calculate angle from wizard to pointer/touch and rotate wizard sprite
var dx = x - wizard.x;
var dy = y - wizard.y;
var angle = Math.atan2(dy, dx);
// Wizard's default asset faces left, so add Math.PI to rotate to correct direction
if (wizard.children && wizard.children.length > 0) {
wizard.children[0].rotation = angle + Math.PI;
}
// If firing, update direction for continuous fire
if (isFiring) {
lastFireX = x;
lastFireY = y;
}
};
// Track if fire is being held
var isFiring = false;
var fireInterval = null;
var lastFireX = 0;
var lastFireY = 0;
// Helper to shoot a fireball toward (x, y)
function shootFireballAt(x, y) {
var fireball = new Fireball();
fireball.x = wizard.x;
fireball.y = wizard.y;
var dir = getDirection(wizard.x, wizard.y, x, y, 8);
fireball.vx = dir.vx;
fireball.vy = dir.vy;
var angle = Math.atan2(dir.vy, dir.vx);
if (fireball.children && fireball.children.length > 0) {
fireball.children[0].rotation = angle;
}
if (wizard.children && wizard.children.length > 0) {
wizard.children[0].rotation = Math.atan2(y - wizard.y, x - wizard.x) + Math.PI;
}
fireballs.push(fireball);
game.addChild(fireball);
LK.getSound('fire').play();
}
// Down handler: start firing repeatedly
game.down = function (x, y, obj) {
isFiring = true;
lastFireX = x;
lastFireY = y;
shootFireballAt(x, y);
if (fireInterval) LK.clearInterval(fireInterval);
fireInterval = LK.setInterval(function () {
if (isFiring) {
shootFireballAt(lastFireX, lastFireY);
}
}, 180); // fire every 180ms (about 5.5 shots/sec)
};
// Up handler: stop firing
game.up = function (x, y, obj) {
isFiring = false;
if (fireInterval) {
LK.clearInterval(fireInterval);
fireInterval = null;
}
};
// Array to hold all enemies
var enemies = [];
// Array to hold all coins
var coins = [];
// Score variable
var score = 0;
// Score text
var scoreText = new Text2("Score: 0", {
size: 100,
fill: "#fff"
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
// After scoreText and wizard are positioned, update startUiContainer position
if (typeof startUiContainer !== "undefined" && startUiContainer && typeof wizard !== "undefined" && wizard) {
// Place UI container between score and wizard, but not overlapping either
startUiContainer.x = 2048 / 2;
startUiContainer.y = wizard.y - 180;
}
// Coin icon and coin count text
var coinIcon = LK.getAsset('coin', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 1.2
});
var coinCount = 0;
var coinText = new Text2("0", {
size: 90,
fill: 0xFFD700
});
coinText.anchor.set(0, 0);
// Position coin icon and text to the right of the score
// We'll update their position after first render in game.update
LK.gui.top.addChild(coinIcon);
LK.gui.top.addChild(coinText);
// Helper: spawn an enemy at a random edge, moving toward wizard
function spawnEnemy() {
// Determine which enemy types are available based on score
var availableTypes = [1];
if (score >= 10) availableTypes.push(2);
if (score >= 20) availableTypes.push(3);
// Randomly pick an available type
var typeIdx = Math.floor(Math.random() * availableTypes.length);
var enemyType = availableTypes[typeIdx];
var enemy;
if (enemyType === 1) {
enemy = new Enemy();
} else if (enemyType === 2) {
enemy = new Enemy2();
} else {
enemy = new Enemy3();
}
// Randomly pick an edge: 0=top, 1=bottom, 2=left, 3=right
var edge = Math.floor(Math.random() * 4);
var ex, ey;
if (edge === 0) {
// top
ex = Math.random() * 2048;
ey = -50;
} else if (edge === 1) {
// bottom
ex = Math.random() * 2048;
ey = 2732 + 50;
} else if (edge === 2) {
// left
ex = -50;
ey = Math.random() * 2732;
} else {
// right
ex = 2048 + 50;
ey = Math.random() * 2732;
}
enemy.x = ex;
enemy.y = ey;
// Move toward wizard
var dir = getDirection(ex, ey, wizard.x, wizard.y, 2.5 + Math.random() * 1.5); // randomize speed a bit
enemy.vx = dir.vx;
enemy.vy = dir.vy;
enemies.push(enemy);
game.addChild(enemy);
}
// Enemy spawn timer
var enemySpawnTimer = LK.setInterval(function () {
spawnEnemy();
}, 1200);
// Game update: update wizard, fireballs, enemies, handle collisions, and scoring
game.update = function () {
// If game not started, only update startButton and wizard visuals
if (!gameStarted) {
if (wizard.update) wizard.update();
// Animate start button (pulse effect)
if (typeof startButton !== "undefined" && startButton && startButton.children && startButton.children.length > 0) {
var t = LK.ticks || Date.now();
var scale = 1 + 0.06 * Math.sin(t * 0.12);
startButton.scale.x = scale;
startButton.scale.y = scale;
}
return;
}
// Update wizard
if (wizard.update) wizard.update();
// Update fireballs and remove destroyed ones
for (var i = fireballs.length - 1; i >= 0; i--) {
var fb = fireballs[i];
if (fb.update) fb.update();
if (fb.destroyed) {
fireballs.splice(i, 1);
}
}
// Update coins and remove destroyed ones
for (var c = coins.length - 1; c >= 0; c--) {
var coin = coins[c];
// Move coin directly toward wizard
var dx = wizard.x - coin.x;
var dy = wizard.y - coin.y;
var dist = Math.sqrt(dx * dx + dy * dy);
var speed = 22; // Fast enough to feel instant, but visible
if (dist > 1) {
coin.x += dx / dist * Math.min(speed, dist);
coin.y += dy / dist * Math.min(speed, dist);
} else {
coin.x = wizard.x;
coin.y = wizard.y;
}
// Check collision with wizard (collect coin)
if (coin.lastWasIntersecting === undefined) coin.lastWasIntersecting = false;
var coinIntersecting = coin.intersects(wizard);
if (!coin.lastWasIntersecting && coinIntersecting) {
// Do not add to score when collecting coin
coinCount += 1;
coinText.setText("" + coinCount);
// Create gain effect (use gain asset instead of explosion)
var gainEffect = LK.getAsset('gain', {
anchorX: 0.5,
anchorY: 0.5,
x: coin.x,
y: coin.y,
scaleX: 1,
scaleY: 1,
alpha: 1
});
game.addChild(gainEffect);
// Animate gain effect: scale up and fade out, then destroy
(function (effect) {
var frames = 24;
var frame = 0;
effect.update = function () {
frame++;
effect.scale.x = 1 + 0.5 * (frame / frames);
effect.scale.y = 1 + 0.5 * (frame / frames);
effect.alpha = 1 - frame / frames;
if (frame >= frames) {
effect.destroy();
}
};
})(gainEffect);
// Create +N asset effect at wizard position
var plusAmount = 1;
if (coin.hasOwnProperty('amount')) {
plusAmount = coin.amount;
}
var plusText = new Text2("+" + plusAmount, {
size: 90,
fill: 0xFFD700
});
plusText.anchor.set(0.5, 0.5);
plusText.x = wizard.x;
plusText.y = wizard.y;
game.addChild(plusText);
// Animate +N asset: move up and fade out, then destroy
(function (txt) {
var startY = txt.y;
var frames = 36;
var frame = 0;
txt.alpha = 1;
txt.update = function () {
frame++;
txt.y = startY - frame * 2.2;
txt.alpha = 1 - frame / frames;
if (frame >= frames) {
txt.destroy();
}
};
})(plusText);
// Remove coin
coin.destroy();
coins.splice(c, 1);
continue;
}
coin.lastWasIntersecting = coinIntersecting;
}
// Position coin icon and text next to score text (right side)
if (scoreText.parent && coinIcon.parent && coinText.parent) {
// Get scoreText bounds in GUI coordinates
var scoreBounds = scoreText.getBounds();
// Place coin icon to the right of score text, with a small gap
coinIcon.x = scoreText.x + scoreBounds.width / 2 + coinIcon.width * 0.7;
coinIcon.y = scoreText.y + coinIcon.height * 0.45;
// Place coinText to the right of coin icon
coinText.x = coinIcon.x + coinIcon.width * 0.7;
coinText.y = scoreText.y + coinIcon.height * 0.1;
}
// Update enemies and remove destroyed ones
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (enemy.update) enemy.update();
if (enemy.destroyed) {
enemies.splice(j, 1);
continue;
}
// Check collision with wizard (game over)
if (enemy.lastWasIntersecting === undefined) enemy.lastWasIntersecting = false;
var nowIntersecting = enemy.intersects(wizard);
if (!enemy.lastWasIntersecting && nowIntersecting) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
enemy.lastWasIntersecting = nowIntersecting;
// Check collision with fireballs
for (var k = fireballs.length - 1; k >= 0; k--) {
var fb = fireballs[k];
if (enemy['fb' + k + '_lastIntersecting'] === undefined) enemy['fb' + k + '_lastIntersecting'] = false;
var fbIntersect = enemy.intersects(fb);
// Only allow collision if fireball is inside the visible screen
var fireballOnScreen = fb.x >= 0 && fb.x <= 2048 && fb.y >= 0 && fb.y <= 2732;
if (!enemy['fb' + k + '_lastIntersecting'] && fbIntersect && fireballOnScreen) {
// Decrease enemy health
enemy.health -= 1;
// Destroy fireball
fb.destroy();
fireballs.splice(k, 1);
// If enemy health reaches 0, destroy enemy and increase score
if (enemy.health <= 0) {
// Spawn explosion at enemy position
var explosion = new Explosion();
explosion.x = enemy.x;
explosion.y = enemy.y;
game.addChild(explosion);
// Determine coin count and plus text based on enemy type
var coinAmount = 1;
if (enemy.type === 2) coinAmount = 2;
if (enemy.type === 3) coinAmount = 3;
// Drop the correct number of coins
for (var cc = 0; cc < coinAmount; cc++) {
var coin = new Coin();
coin.x = enemy.x;
coin.y = enemy.y;
coin.vx = 0;
coin.vy = 0;
coin.gravity = 0;
// For multi-coin drops, only the first coin will show +N at wizard
if (cc === 0) {
coin.amount = coinAmount;
}
coins.push(coin);
game.addChild(coin);
}
// Play dead sound
LK.getSound('dead').play();
enemy.destroy();
enemies.splice(j, 1);
score += 1;
scoreText.setText("Score: " + score);
// (Removed: +N effect at enemy death. Now shown at wizard when coin is collected)
break;
}
}
enemy['fb' + k + '_lastIntersecting'] = fbIntersect;
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -232,10 +232,12 @@
game.addChild(wizard);
// Center wizard on screen at start
wizard.x = 2048 / 2;
wizard.y = 2732 / 2;
-// --- START BUTTON LOGIC ---
+// --- START & UPGRADE BUTTON UI LOGIC ---
var gameStarted = false;
+// UI container for start and upgrade buttons
+var startUiContainer = new Container();
// Create start button asset (simple box with text)
var startButtonWidth = 420;
var startButtonHeight = 140;
var startButton = new Container();
@@ -255,15 +257,42 @@
startButtonText.anchor.set(0.5, 0.5);
startButtonText.x = 0;
startButtonText.y = 0;
startButton.addChild(startButtonText);
-// Position start button: horizontally centered, just below score and above wizard
-// We'll update its position after scoreText is created and wizard is positioned
-// For now, set to center of screen
-startButton.x = 2048 / 2;
-startButton.y = wizard.y - 180;
+// Create upgrade button below start button
+var upgradeButtonWidth = 420;
+var upgradeButtonHeight = 110;
+var upgradeButton = new Container();
+var upgradeButtonBg = LK.getAsset('background', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: upgradeButtonWidth,
+ height: upgradeButtonHeight,
+ color: 0x2ecc71
+});
+upgradeButtonBg.alpha = 0.92;
+upgradeButton.addChild(upgradeButtonBg);
+var upgradeButtonText = new Text2("UPGRADE", {
+ size: 60,
+ fill: "#fff"
+});
+upgradeButtonText.anchor.set(0.5, 0.5);
+upgradeButtonText.x = 0;
+upgradeButtonText.y = 0;
+upgradeButton.addChild(upgradeButtonText);
+// Position start and upgrade buttons in the UI container
+startButton.x = 0;
+startButton.y = 0;
+upgradeButton.x = 0;
+upgradeButton.y = startButton.y + startButtonHeight / 2 + 30 + upgradeButtonHeight / 2;
+// Add both buttons to the UI container
+startUiContainer.addChild(startButton);
+startUiContainer.addChild(upgradeButton);
+// Position the UI container: horizontally centered, just below score and above wizard
+startUiContainer.x = 2048 / 2;
+startUiContainer.y = wizard.y - 180;
// Add to game
-game.addChild(startButton);
+game.addChild(startUiContainer);
// Block input until start is pressed
function blockGameInput() {
game.move = function () {};
game.down = function () {};
@@ -274,14 +303,104 @@
fireInterval = null;
}
}
blockGameInput();
+// --- UPGRADE WINDOW LOGIC ---
+var upgradeWindow = null;
+function showUpgradeWindow() {
+ if (upgradeWindow && !upgradeWindow.destroyed) return;
+ upgradeWindow = new Container();
+ // Window background
+ var winW = 700,
+ winH = 700;
+ var winBg = LK.getAsset('background', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: winW,
+ height: winH,
+ color: 0x222244
+ });
+ winBg.alpha = 0.97;
+ upgradeWindow.addChild(winBg);
+ // Title
+ var title = new Text2("UPGRADE", {
+ size: 70,
+ fill: "#fff"
+ });
+ title.anchor.set(0.5, 0);
+ title.x = 0;
+ title.y = -winH / 2 + 40;
+ upgradeWindow.addChild(title);
+ // Button helper
+ function makeUpgradeBtn(label, y, color) {
+ var btn = new Container();
+ var btnBg = LK.getAsset('background', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: 420,
+ height: 110,
+ color: color
+ });
+ btnBg.alpha = 0.93;
+ btn.addChild(btnBg);
+ var btnText = new Text2(label, {
+ size: 60,
+ fill: "#fff"
+ });
+ btnText.anchor.set(0.5, 0.5);
+ btnText.x = 0;
+ btnText.y = 0;
+ btn.addChild(btnText);
+ btn.x = 0;
+ btn.y = y;
+ return btn;
+ }
+ // Hız, Hüç, Silah, Geri buttons
+ var btnSpacing = 130;
+ var btns = [];
+ var btnLabels = [{
+ label: "HIZ",
+ color: 0x3498db
+ }, {
+ label: "HÜÇ",
+ color: 0xe67e22
+ }, {
+ label: "SİLAH",
+ color: 0x9b59b6
+ }];
+ for (var i = 0; i < btnLabels.length; i++) {
+ var btn = makeUpgradeBtn(btnLabels[i].label, -60 + i * btnSpacing, btnLabels[i].color);
+ upgradeWindow.addChild(btn);
+ btns.push(btn);
+ }
+ // Geri button
+ var geriBtn = makeUpgradeBtn("GERİ", 320, 0x888888);
+ upgradeWindow.addChild(geriBtn);
+ // Geri closes window
+ geriBtn.down = function () {
+ if (upgradeWindow && !upgradeWindow.destroyed) {
+ upgradeWindow.destroy();
+ upgradeWindow = null;
+ }
+ };
+ // Center window
+ upgradeWindow.x = 2048 / 2;
+ upgradeWindow.y = 2732 / 2;
+ game.addChild(upgradeWindow);
+}
+// Upgrade button interaction
+upgradeButton.down = function (x, y, obj) {
+ if (upgradeWindow && !upgradeWindow.destroyed) return;
+ showUpgradeWindow();
+};
// Start button interaction
startButton.down = function (x, y, obj) {
if (gameStarted) return;
gameStarted = true;
- // Remove start button
- startButton.destroy();
+ // Remove start UI container (removes both start and upgrade buttons)
+ if (startUiContainer && !startUiContainer.destroyed) {
+ startUiContainer.destroy();
+ }
// --- RESET GAME STATE ---
// Remove all enemies, fireballs, coins from game and arrays
for (var i = enemies.length - 1; i >= 0; i--) {
if (enemies[i] && !enemies[i].destroyed) enemies[i].destroy();
@@ -439,15 +558,13 @@
fill: "#fff"
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
-// After scoreText and wizard are positioned, update startButton position
-if (typeof startButton !== "undefined" && startButton && typeof wizard !== "undefined" && wizard) {
- // Place start button between score and wizard, but not overlapping either
- // Place it about 120px below the score text, and about 120px above wizard
- startButton.x = 2048 / 2;
- // ScoreText is in GUI, wizard is in game coordinates, so use wizard.y for vertical reference
- startButton.y = wizard.y - 180;
+// After scoreText and wizard are positioned, update startUiContainer position
+if (typeof startUiContainer !== "undefined" && startUiContainer && typeof wizard !== "undefined" && wizard) {
+ // Place UI container between score and wizard, but not overlapping either
+ startUiContainer.x = 2048 / 2;
+ startUiContainer.y = wizard.y - 180;
}
// Coin icon and coin count text
var coinIcon = LK.getAsset('coin', {
anchorX: 0.5,
get an enemy in the form of slime. In-Game asset. 2d. High contrast. No shadows
get an enemy in the form of slime. In-Game asset. 2d. High contrast. No shadows
Let there be a mini machine gun and let this gun be pixel shaped. In-Game asset. 2d. High contrast. No shadows
a bullet but yellow and pixel. In-Game asset. 2d. High contrast. No shadows
slime explosion. In-Game asset. 2d. High contrast. No shadows
Change eyes like red
+ gain coin effect. In-Game asset. 2d. High contrast. No shadows
Fast bullet upgrade. In-Game asset. 2d. High contrast. No shadows
Upgrade power bullet. In-Game asset. 2d. High contrast. No shadows
Health + icon pixels. In-Game asset. 2d. High contrast. No shadows
Handgun pixel its look left. In-Game asset. 2d. High contrast. No shadows
işaretli alanı siyaha boya
pixel shuriken but 8 edges. In-Game asset. 2d. High contrast. No shadows
shotgun pixel and look left side. In-Game asset. 2d. High contrast. No shadows
submachine gun look left. In-Game asset. 2d. High contrast. No shadows
mp5 gun pixel. In-Game asset. 2d. High contrast. No shadows
Minigun bullet pixel. In-Game asset. 2d. High contrast. No shadows
Eliptic neon laser bullet. In-Game asset. 2d. High contrast. No shadows. Pixel
slime but have metalic helmet. In-Game asset. 2d. High contrast. No shadows
a slime boss enemy very strict. In-Game asset. 2d. High contrast. No shadows
create mirror view a bit smaller
add a dragon baby on top of gun
a goblin slime which have backpack fully coins. In-Game asset. 2d. High contrast. No shadows
Disappear smoke pixel. In-Game asset. 2d. High contrast. No shadows
Coin pile pixel. In-Game asset. 2d. High contrast. No shadows
fire left to right pixel. In-Game asset. 2d. High contrast. No shadows
Slime enemy healer. In-Game asset. 2d. High contrast. No shadows
Healt restore pixel. In-Game asset. 2d. High contrast. No shadows
Ammo +1 upgrade. In-Game asset. 2d. High contrast. No shadows
Type SLOW bottom of the amblem
Fire ball pixel
boss slime but like fire and dangereous. In-Game asset. 2d. High contrast. No shadows
Add body of this slime