<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<title>Mini Brawl Arenası</title>
<style>
body {
margin: 0;
background-color: #1e272e;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
color: white;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
user-select: none;
}
canvas {
background-color: #2f3640;
border: 4px solid #fbc531;
border-radius: 12px;
box-shadow: 0 0 25px rgba(251, 197, 49, 0.4);
cursor: crosshair;
}
#ui {
display: flex;
gap: 25px;
margin-bottom: 12px;
font-size: 20px;
font-weight: bold;
}
.badge {
background: #353b48;
padding: 8px 16px;
border-radius: 8px;
border: 2px solid #718093;
}
#superStatus { color: #fbc531; }
p { margin-top: 10px; color: #dcdde1; font-size: 14px; }
</style>
</head>
<body>
<div id="ui">
<div class="badge">❤️ Can: <span id="hp">100</span></div>
<div class="badge">💎 Elmas: <span id="gems">0</span> / 10</div>
<div class="badge" id="superStatus">⚡ Süper: %0</div>
</div>
<canvas id="gameCanvas" width="800" height="500"></canvas>
<p><b>Hareket:</b> W, A, S, D veya Yön Tuşları | <b>Ateş Et:</b> Sol Tık | <b>Süper Güç:</b> Sağ Tık veya Boşluk (Space)</p>
<script>
const canvas = document.getElementById("gameCanvas");
const ctx = canvas.getContext("2d");
let player = { x: 400, y: 250, radius: 18, speed: 4, hp: 100, maxHp: 100, gems: 0, superCharge: 0, color: "#00a8ff" };
let bullets = [];
let enemyBullets = [];
let enemies = [];
let gems = [];
let walls = [
{ x: 180, y: 120, w: 40, h: 120 },
{ x: 580, y: 120, w: 40, h: 120 },
{ x: 180, y: 280, w: 40, h: 120 },
{ x: 580, y: 280, w: 40, h: 120 },
{ x: 350, y: 150, w: 100, h: 30 },
{ x: 350, y: 320, w: 100, h: 30 }
];
let keys = {};
let mouse = { x: 0, y: 0 };
let gameOver = false;
window.addEventListener("keydown", e => {
keys[e.key.toLowerCase()] = true;
if (e.code === "Space") useSuper();
});
window.addEventListener("keyup", e => keys[e.key.toLowerCase()] = false);
canvas.addEventListener("mousemove", e => {
const rect = canvas.getBoundingClientRect();
mouse.x = e.clientX - rect.left;
mouse.y = e.clientY - rect.top;
});
canvas.addEventListener("mousedown", e => {
if (gameOver) { resetGame(); return; }
if (e.button === 0) shoot(player.x, player.y, Math.atan2(mouse.y - player.y, mouse.x - player.x), false, 10, "#fbc531");
if (e.button === 2) useSuper();
});
canvas.addEventListener("contextmenu", e => e.preventDefault());
function useSuper() {
if (player.superCharge >= 100 && !gameOver) {
player.superCharge = 0;
for (let i = 0; i < 12; i++) {
let angle = (Math.PI * 2 / 12) * i;
shoot(player.x, player.y, angle, false, 16, "#ff4757");
}
}
}
function shoot(x, y, angle, isEnemy, radius, color) {
let arr = isEnemy ? enemyBullets : bullets;
arr.push({ x: x, y: y, vx: Math.cos(angle) * 7, vy: Math.sin(angle) * 7, radius: radius || 6, color: color });
}
function spawnEnemy() {
if (enemies.length < 4 && !gameOver) {
let side = Math.floor(Math.random() * 4);
let x = side === 0 ? 30 : side === 1 ? 770 : Math.random() * 800;
let y = side === 2 ? 30 : side === 3 ? 470 : Math.random() * 500;
enemies.push({ x: x, y: y, radius: 18, speed: 1.8, hp: 60, cooldown: 90, color: "#e84118" });
}
}
function spawnGem() {
if (gems.length < 3 && !gameOver) {
gems.push({ x: 380 + Math.random() * 40, y: 230 + Math.random() * 40, radius: 8 });
}
}
function checkWallCollision(x, y, r) {
for (let w of walls) {
if (x + r > w.x && x - r < w.x + w.w && y + r > w.y && y - r < w.y + w.h) return true;
}
return false;
}
function resetGame() {
player = { x: 400, y: 250, radius: 18, speed: 4, hp: 100, maxHp: 100, gems: 0, superCharge: 0, color: "#00a8ff" };
bullets = []; enemyBullets = []; enemies = []; gems = [];
gameOver = false;
}
setInterval(spawnEnemy, 2500);
setInterval(spawnGem, 3000);
function update() {
if (gameOver) return;
let nextX = player.x;
let nextY = player.y;
if (keys["w"] || keys["arrowup"]) nextY -= player.speed;
if (keys["s"] || keys["arrowdown"]) nextY += player.speed;
if (keys["a"] || keys["arrowleft"]) nextX -= player.speed;
if (keys["d"] || keys["arrowright"]) nextX += player.speed;
if (nextX > player.radius && nextX < canvas.width - player.radius && !checkWallCollision(nextX, player.y, player.radius)) player.x = nextX;
if (nextY > player.radius && nextY < canvas.height - player.radius && !checkWallCollision(player.x, nextY, player.radius)) player.y = nextY;
bullets.forEach((b, i) => {
b.x += b.vx; b.y += b.vy;
if (checkWallCollision(b.x, b.y, b.radius) || b.x < 0 || b.x > canvas.width || b.y < 0 || b.y > canvas.height) bullets.splice(i, 1);
});
enemyBullets.forEach((b, i) => {
b.x += b.vx; b.y += b.vy;
if (Math.hypot(b.x - player.x, b.y - player.y) < b.radius + player.radius) {
player.hp -= 12;
enemyBullets.splice(i, 1);
if (player.hp <= 0) { player.hp = 0; gameOver = true; }
} else if (checkWallCollision(b.x, b.y, b.radius) || b.x < 0 || b.x > canvas.width || b.y < 0 || b.y > canvas.height) {
enemyBullets.splice(i, 1);
}
});
enemies.forEach((en, ei) => {
let angle = Math.atan2(player.y - en.y, player.x - en.x);
let ex = en.x + Math.cos(angle) * en.speed;
let ey = en.y + Math.sin(angle) * en.speed;
if (!checkWallCollision(ex, en.y, en.radius)) en.x = ex;
if (!checkWallCollision(en.x, ey, en.radius)) en.y = ey;
en.cooldown--;
if (en.cooldown <= 0) {
shoot(en.x, en.y, angle, true, 6, "#ff7979");
en.cooldown = 110;
}
bullets.forEach((b, bi) => {
if (Math.hypot(b.x - en.x, b.y - en.y) < b.radius + en.radius) {
en.hp -= 20;
bullets.splice(bi, 1);
player.superCharge = Math.min(100, player.superCharge + 25);
if (en.hp <= 0) {
gems.push({ x: en.x, y: en.y, radius: 8 });
enemies.splice(ei, 1);
}
}
});
});
gems.forEach((g, i) => {
if (Math.hypot(player.x - g.x, player.y - g.y) < player.radius + g.radius) {
player.gems++;
player.hp = Math.min(player.maxHp, player.hp + 10);
gems.splice(i, 1);
if (player.gems >= 10) gameOver = true;
}
});
document.getElementById("hp").innerText = player.hp;
document.getElementById("gems").innerText = player.gems;
document.getElementById("superStatus").innerText = player.superCharge >= 100 ? "⚡ SÜPER HAZIR!" : `⚡ Süper: %${player.superCharge}`;
}
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Duvarlar
ctx.fillStyle = "#7f8fa6";
walls.forEach(w => ctx.fillRect(w.x, w.y, w.w, w.h));
// Elmaslar
gems.forEach(g => {
ctx.beginPath();
ctx.arc(g.x, g.y, g.radius, 0, Math.PI * 2);
ctx.fillStyle = "#9c88ff";
ctx.fill();
ctx.strokeStyle = "white";
ctx.stroke();
});
// Oyuncu
ctx.beginPath();
ctx.arc(player.x, player.y, player.radius, 0, Math.PI * 2);
ctx.fillStyle = player.color;
ctx.fill();
ctx.lineWidth = 3;
ctx.strokeStyle = player.superCharge >= 100 ? "#fbc531" : "white";
ctx.stroke();
// Düşmanlar
enemies.forEach(en => {
ctx.beginPath();
ctx.arc(en.x, en.y, en.radius, 0, Math.PI * 2);
ctx.fillStyle = en.color;
ctx.fill();
ctx.fillStyle = "white";
ctx.font = "12px Arial";
ctx.fillText(en.hp, en.x - 8, en.y - 22);
});
// Mermiler
[...bullets, ...enemyBullets].forEach(b => {
ctx.beginPath();
ctx.arc(b.x, b.y, b.radius, 0, Math.PI * 2);
ctx.fillStyle = b.color;
ctx.fill();
});
if (gameOver) {
ctx.fillStyle = "rgba(0,0,0,0.75)";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "#fbc531";
ctx.font = "bold 40px Segoe UI";
ctx.textAlign = "center";
ctx.fillText(player.gems >= 10 ? "🏆 KAZANDIN! 10 ELMAS TOPLADIN!" : "💥 YENİLDİN!", canvas.width / 2, canvas.height / 2 - 10);
ctx.fillStyle = "white";
ctx.font = "20px Segoe UI";
ctx.fillText("Tekrar oynamak için ekrana tıkla", canvas.width / 2, canvas.height / 2 + 35);
ctx.textAlign = "left";
}
}
function loop() {
update();
draw();
requestAnimationFrame(loop);
}
loop();
</script>
</body>
</html>
1
1
9KB
9KB
149.0ms
304.0ms
156.0ms