Rogue
Uzman
- Katılım
- 23 Eylül 2024
- Mesajlar
- 945
- Çözümler
- 1
- Beğeniler
- 1.036
Yapay zeka'ya (Grok ve Deepseek karışık) sadece promptlar vererek Space Invaders klonu bir oyun yaptırdım. Oyunu alttaki siteye girip, attığım kodu kopyalayıp sol tarafa yapıştır yapıp test edebilirsiniz. Boss falan var 500 puanda bir geliyor, daha da bir şeyler eklemek istedim ama çok uğraştırıyor oyunu bozup duruyor. Biraz uğraşılsa daha iyi şeyler çıkar kesin. Konu altında siz de yaptırdığınız kodları paylaşıp ortaya çıkan oyunlara bakabiliriz. Kullandığınız yapay zekaya HTML dilinde oyun kodu yaz diyerek istediğiniz oyunu anlatmanız lazım.
HTML:
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Space Invaders – YENİ DÜŞMAN TİPLERİ!</title>
<style>
:root {
--player-color: #2a2a4a;
--enemy-color-1: #ff3366;
--enemy-color-2: #3366ff;
--enemy-color-3: #33ff66;
--enemy-color-4: #ffcc00;
--boss-color: #aa00ff;
--text-color: #0f0;
--boss-text-color: #f0f;
--warning-color: #ff0;
}
body {
margin:0;
background:#000;
overflow:hidden;
font-family: Arial, sans-serif;
touch-action: none;
user-select: none;
}
canvas {
display:block;
cursor: none;
}
#ui {
position:absolute;
top:10px;
left:10px;
color:var(--text-color);
font:bold 24px Arial;
text-shadow:0 0 10px var(--text-color);
z-index:10;
background: rgba(0,0,0,0.5);
padding: 10px;
border-radius: 5px;
}
#bossui {
position:absolute;
top:10px;
right:10px;
color:var(--boss-text-color);
font:bold 24px Arial;
text-shadow:0 0 10px var(--boss-text-color);
z-index:10;
display:none;
background: rgba(0,0,0,0.5);
padding: 10px;
border-radius: 5px;
}
#gameover {
position:absolute;
top:50%;
left:50%;
transform:translate(-50%,-50%);
color:#f00;
font:bold 60px Arial;
text-align:center;
display:none;
text-shadow:0 0 20px #f00;
z-index:20;
background: rgba(0,0,0,0.8);
padding: 40px;
border-radius: 15px;
border: 3px solid #f00;
}
button {
margin-top:20px;
padding:15px 30px;
font-size:24px;
background:#0f0;
color:#000;
border:none;
border-radius:10px;
cursor:pointer;
transition: all 0.3s;
}
button:hover {
background: #0c0;
transform: scale(1.05);
}
#instructions {
position: absolute;
bottom: 10px;
left: 10px;
color: var(--text-color);
font: 16px Arial;
background: rgba(0,0,0,0.5);
padding: 10px;
border-radius: 5px;
max-width: 300px;
}
#bossWarning {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: var(--boss-text-color);
font: bold 48px Arial;
text-align: center;
display: none;
text-shadow: 0 0 20px var(--boss-text-color);
z-index: 15;
background: rgba(0,0,0,0.8);
padding: 30px;
border-radius: 15px;
border: 3px solid var(--boss-text-color);
animation: pulse 1s infinite;
}
@keyframes pulse {
0% { transform: translate(-50%, -50%) scale(1); }
50% { transform: translate(-50%, -50%) scale(1.05); }
100% { transform: translate(-50%, -50%) scale(1); }
}
#level {
position: absolute;
top: 10px;
left: 50%;
transform: translateX(-50%);
color: var(--warning-color);
font: bold 24px Arial;
text-shadow: 0 0 10px var(--warning-color);
z-index: 10;
background: rgba(0,0,0,0.5);
padding: 10px;
border-radius: 5px;
display: none;
}
/* Mobil optimizasyonları */
@media (max-width: 768px) {
#ui, #bossui, #level {
font-size: 18px;
padding: 8px;
}
#gameover {
font-size: 40px;
padding: 20px;
}
#bossWarning {
font-size: 32px;
padding: 20px;
}
button {
padding: 12px 24px;
font-size: 20px;
}
}
</style>
</head>
<body>
<div id="ui">
Can: <span id="can">5</span> | Skor: <span id="skor">0</span><br>
Silah: <span id="silah">1</span> Süre: <span id="sure">--</span>
</div>
<div id="bossui">
BOSS HP: <span id="bosshp">50/50</span>
</div>
<div id="level">
Seviye: <span id="levelNum">1</span>
</div>
<div id="bossWarning">
BOSS GELİYOR!
</div>
<div id="gameover">
OYUN BİTTİ!<br><br>
Skorun: <span id="sonuc">0</span><br>
<button onclick="yeniden()">YENİDEN BAŞLA</button>
</div>
<div id="instructions">
Hareket: Fare/Touch<br>
Ateş: Tıklama/Tap<br>
Power-up'ları topla!
</div>
<canvas id="c"></canvas>
<script>
// Canvas ve context
const canvas = document.getElementById('c');
const ctx = canvas.getContext('2d');
canvas.width = innerWidth;
canvas.height = innerHeight;
// === YENİ DÜŞMAN TANIMLARI ===
const DUSMAN_TIPLERI = [
{
ad: "Saldırgan Uzaylı",
renk: "#ff3366",
detayRenk: "#ff99aa",
gozRenk: "#00ff00",
hiz: 0.8,
hp: 3,
atesOran: 0.018,
atesGecikme: 170,
puan: 10,
ozellik: "Hızlı ateş eder"
},
{
ad: "Zırhlı Uzaylı",
renk: "#3366ff",
detayRenk: "#6699ff",
gozRenk: "#ffff00",
hiz: 0.5,
hp: 5,
atesOran: 0.012,
atesGecikme: 250,
puan: 15,
ozellik: "Yüksek can, yavaş hareket"
},
{
ad: "Hızlı Avcı",
renk: "#33ff66",
detayRenk: "#99ffaa",
gozRenk: "#ff00ff",
hiz: 1.2,
hp: 2,
atesOran: 0.025,
atesGecikme: 120,
puan: 12,
ozellik: "Çok hızlı, az can"
},
{
ad: "Ölüm Gemisi",
renk: "#ffcc00",
detayRenk: "#ffdd55",
gozRenk: "#00ffff",
hiz: 0.7,
hp: 4,
atesOran: 0.020,
atesGecikme: 150,
puan: 18,
ozellik: "Güçlü ve dengeli"
},
{
ad: "Kabus Savaşçısı",
renk: "#cc33ff",
detayRenk: "#dd99ff",
gozRenk: "#ff5500",
hiz: 0.9,
hp: 6,
atesOran: 0.015,
atesGecikme: 200,
puan: 25,
ozellik: "Çok güçlü, nadir görülür"
}
];
// === SES SİSTEMİ ===
let audioCtx = null;
function initAudio() {
if (!audioCtx) {
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
audioCtx.resume();
}
}
let musicInterval = null;
function startMusic() {
initAudio();
if (musicInterval) clearInterval(musicInterval);
const notes = [330,330,392,330,523,494,392];
let i = 0;
musicInterval = setInterval(() => {
const o = audioCtx.createOscillator();
o.type='square';
o.frequency.value=notes[i++%7];
const g = audioCtx.createGain();
g.gain.setValueAtTime(0.07,audioCtx.currentTime);
g.gain.exponentialRampToValueAtTime(0.001,audioCtx.currentTime+0.15);
o.connect(g).connect(audioCtx.destination);
o.start();
o.stop(audioCtx.currentTime+0.15);
}, 320);
}
function stopMusic() {
if(musicInterval) clearInterval(musicInterval);
musicInterval=null;
}
// === OYUN DEĞİŞKENLERİ ===
let oyuncu = {x:canvas.width/2-40, y:canvas.height-120, w:80, h:80};
let mermiler=[], dusmanMermileri=[], dusmanlar=[], powerups=[], patlamalar=[];
let boss = null;
let bossActive = false;
let fareX = oyuncu.x + 40;
let can=5, skor=0, oyunBitti=false, silahLevel=1, powerupTimer=0;
let yildizlar=[];
let motorParlaklik = 0;
let motorParlaklikArtis = true;
let motorPartikuller = [];
let level = 1;
let bossSpawnScore = 500;
let bossSpawned = false;
let bossWarningActive = false;
let bossOlduruldu = false;
// Yıldızları oluştur
for(let i=0;i<300;i++) yildizlar.push({x:Math.random()*canvas.width,y:Math.random()*canvas.height,r:Math.random()*1.5+0.5,hiz:Math.random()*0.4+0.2});
// === YENİ DÜŞMAN ÇİZİM FONKSİYONLARI ===
function uzayliGemisiCiz(x, y, w, h, tur) {
ctx.save();
const dusmanTipi = DUSMAN_TIPLERI[tur];
// Ana gövde - farklı şekiller
ctx.fillStyle = dusmanTipi.renk;
ctx.shadowColor = dusmanTipi.renk;
ctx.shadowBlur = 15;
if (tur === 0) {
// Saldırgan Uzaylı - Klasik uzaylı
ctx.beginPath();
ctx.ellipse(x + w/2, y + h/2, w/2, h/2, 0, 0, Math.PI * 2);
ctx.fill();
} else if (tur === 1) {
// Zırhlı Uzaylı - Dikdörtgen gövde
ctx.fillRect(x, y, w, h);
} else if (tur === 2) {
// Hızlı Avcı - Üçgen form
ctx.beginPath();
ctx.moveTo(x + w/2, y);
ctx.lineTo(x + w, y + h);
ctx.lineTo(x, y + h);
ctx.closePath();
ctx.fill();
} else if (tur === 3) {
// Ölüm Gemisi - Altıgen
ctx.beginPath();
for(let i = 0; i < 6; i++) {
const angle = (i * 60) * Math.PI / 180;
const px = x + w/2 + Math.cos(angle) * w/2;
const py = y + h/2 + Math.sin(angle) * h/2;
if(i === 0) ctx.moveTo(px, py);
else ctx.lineTo(px, py);
}
ctx.closePath();
ctx.fill();
} else {
// Kabus Savaşçısı - Yıldız formu
ctx.beginPath();
for(let i = 0; i < 10; i++) {
const angle = (i * 36) * Math.PI / 180;
const radius = i % 2 === 0 ? w/2 : w/4;
const px = x + w/2 + Math.cos(angle) * radius;
const py = y + h/2 + Math.sin(angle) * radius;
if(i === 0) ctx.moveTo(px, py);
else ctx.lineTo(px, py);
}
ctx.closePath();
ctx.fill();
}
// Detaylar
ctx.fillStyle = dusmanTipi.detayRenk;
ctx.shadowBlur = 8;
// Gözler - farklı konumlar
if (tur === 0 || tur === 1) {
// Klasik gözler
ctx.fillStyle = dusmanTipi.gozRenk;
ctx.beginPath();
ctx.arc(x + w/2 - 8, y + h/2 - 5, 6, 0, Math.PI * 2);
ctx.fill();
ctx.beginPath();
ctx.arc(x + w/2 + 8, y + h/2 - 5, 6, 0, Math.PI * 2);
ctx.fill();
} else if (tur === 2) {
// Tek göz
ctx.fillStyle = dusmanTipi.gozRenk;
ctx.beginPath();
ctx.arc(x + w/2, y + h/2, 8, 0, Math.PI * 2);
ctx.fill();
} else if (tur === 3) {
// Çoklu gözler
for(let i = -1; i <= 1; i++) {
ctx.fillStyle = dusmanTipi.gozRenk;
ctx.beginPath();
ctx.arc(x + w/2 + i*12, y + h/2, 4, 0, Math.PI * 2);
ctx.fill();
}
} else {
// Kabus gözleri
ctx.fillStyle = dusmanTipi.gozRenk;
ctx.beginPath();
ctx.arc(x + w/2 - 10, y + h/2 - 8, 5, 0, Math.PI * 2);
ctx.fill();
ctx.beginPath();
ctx.arc(x + w/2 + 10, y + h/2 - 8, 5, 0, Math.PI * 2);
ctx.fill();
ctx.beginPath();
ctx.arc(x + w/2, y + h/2 + 10, 4, 0, Math.PI * 2);
ctx.fill();
}
// Silah/detay çizgileri
ctx.strokeStyle = dusmanTipi.detayRenk;
ctx.lineWidth = 2;
if (tur === 0) {
// Saldırgan Uzaylı - antenler
ctx.beginPath();
ctx.moveTo(x + w/2 - 12, y + h/2 - 10);
ctx.lineTo(x + w/2 - 18, y + 5);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(x + w/2 + 12, y + h/2 - 10);
ctx.lineTo(x + w/2 + 18, y + 5);
ctx.stroke();
} else if (tur === 1) {
// Zırhlı Uzaylı - zırh plakaları
ctx.strokeRect(x + 5, y + 5, w - 10, h - 10);
ctx.strokeRect(x + 10, y + 10, w - 20, h - 20);
} else if (tur === 2) {
// Hızlı Avcı - kanatlar
ctx.beginPath();
ctx.moveTo(x + w/2, y + h/2);
ctx.lineTo(x, y + h);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(x + w/2, y + h/2);
ctx.lineTo(x + w, y + h);
ctx.stroke();
} else if (tur === 3) {
// Ölüm Gemisi - silah uçları
for(let i = 0; i < 4; i++) {
const angle = (i * 90) * Math.PI / 180;
ctx.beginPath();
ctx.moveTo(x + w/2, y + h/2);
ctx.lineTo(x + w/2 + Math.cos(angle) * w/2, y + h/2 + Math.sin(angle) * h/2);
ctx.stroke();
}
} else {
// Kabus Savaşçısı - dikenler
for(let i = 0; i < 8; i++) {
const angle = (i * 45) * Math.PI / 180;
ctx.beginPath();
ctx.moveTo(x + w/2, y + h/2);
ctx.lineTo(x + w/2 + Math.cos(angle) * w/2, y + h/2 + Math.sin(angle) * h/2);
ctx.stroke();
}
}
ctx.shadowBlur = 0;
ctx.restore();
}
// Motor partikül sistemi
function motorPartikulOlustur() {
for(let i = 0; i < 3; i++) {
motorPartikuller.push({
x: oyuncu.x + 40 + (Math.random() - 0.5) * 20,
y: oyuncu.y + 80,
vx: (Math.random() - 0.5) * 2,
vy: Math.random() * 3 + 2,
life: 20 + Math.random() * 20,
size: Math.random() * 4 + 2
});
}
}
// PATLAMA FONKSİYONU
function patlama(x,y,büyük=false){
patlamaSesi(büyük);
const adet=büyük?20:8;
const hız=büyük?12:6;
for(let i=0;i<adet;i++){
patlamalar.push({
x,y,
vx:(Math.random()-0.5)*hız,
vy:(Math.random()-0.5)*hız,
life:büyük?80:40,
maxLife:büyük?80:40,
r:Math.random()*3+2
});
}
}
function bossOlustur(){
if(bossActive || bossWarningActive) return;
// Boss uyarısı göster
bossWarningActive = true;
bossSpawned = true;
document.getElementById('bossWarning').style.display = 'block';
setTimeout(() => {
bossWarningActive = false;
document.getElementById('bossWarning').style.display = 'none';
boss = {
x: canvas.width / 2 - 100,
y: -150,
w: 200,
h: 120,
hp: 50 + (level - 1) * 10,
maxHp: 50 + (level - 1) * 10,
vy: 1.2,
hareketTimer: 0,
atesTimer: 120,
atesDelay: 90 - (level - 1) * 5
};
bossActive = true;
bossGirisSesi();
document.getElementById('bossui').style.display = 'block';
setTimeout(ekranSars, 500);
document.getElementById('level').style.display = 'block';
document.getElementById('levelNum').textContent = level;
}, 2000);
}
function atesEt(){
if(oyunBitti) return;
silahSesi(silahLevel);
const mx=oyuncu.x+40, my=oyuncu.y, s=13;
if(silahLevel===1) mermiler.push({x:mx-3,y:my,w:6,h:20,vx:0,vy:-s});
else if(silahLevel===2){
mermiler.push({x:mx-18,y:my,w:6,h:20,vx:0,vy:-s});
mermiler.push({x:mx+12,y:my,w:6,h:20,vx:0,vy:-s});
}
else if(silahLevel===3) for(let i=-1;i<=1;i++) mermiler.push({x:mx+i*22,y:my,w:6,h:20,vx:0,vy:-s});
else if(silahLevel>=4) for(let i=-2;i<=2;i++){
const a=i*20*Math.PI/180;
mermiler.push({x:mx,y:my,w:6,h:20,vx:Math.sin(a)*8,vy:-Math.cos(a)*s});
}
}
function powerupOlustur(x,y){
if(Math.random()<0.38){
const tip = Math.random()<0.25 ? 5 : Math.floor(Math.random()*4)+1;
powerups.push({x,y,w:46,h:46,tip,hiz:1.3});
}
}
// YENİ DÜŞMAN OLUŞTURMA
function dusmanOlustur(){
if(bossActive || bossWarningActive) return;
// Düşman tipini seç - Kabus Savaşçısı daha nadir
let tur;
if (Math.random() < 0.1) {
tur = 4; // %10 şansla Kabus Savaşçısı
} else {
tur = Math.floor(Math.random() * 4); // Diğer tipler
}
const dusmanTipi = DUSMAN_TIPLERI[tur];
const baseSpeed = dusmanTipi.hiz + Math.random()*0.7;
const levelSpeedBonus = (level - 1) * 0.2;
dusmanlar.push({
x:Math.random()*(canvas.width-70),
y:-80,
w:60,
h:50,
hiz: baseSpeed + levelSpeedBonus,
atesZaman:dusmanTipi.atesGecikme + Math.random()*180,
hp:dusmanTipi.hp + Math.floor((level - 1) / 2),
tur: tur
});
}
// SES FONKSİYONLARI
function silahSesi(level) {
initAudio();
const t = audioCtx.currentTime;
if(level===1){
const o=audioCtx.createOscillator();
o.type='square';
o.frequency.setValueAtTime(1100,t);
o.frequency.exponentialRampToValueAtTime(550,t+0.1);
const g=audioCtx.createGain();
g.gain.setValueAtTime(0.25,t);
g.gain.exponentialRampToValueAtTime(0.001,t+0.12);
o.connect(g).connect(audioCtx.destination);
o.start(t);
o.stop(t+0.12);
}
else if(level===2){
[-0.6,0.6].forEach(pan=>{
const o=audioCtx.createOscillator();
o.type='triangle';
o.frequency.value=880;
const g=audioCtx.createGain();
g.gain.setValueAtTime(0.2,t);
g.gain.exponentialRampToValueAtTime(0.001,t+0.15);
const p=audioCtx.createStereoPanner();
p.pan.value=pan;
o.connect(g).connect(p).connect(audioCtx.destination);
o.start(t);
o.stop(t+0.15);
});
}
else if(level===3){
[800,1000,1200].forEach((f,i)=>{
const o=audioCtx.createOscillator();
o.type='sawtooth';
o.frequency.value=f;
const g=audioCtx.createGain();
g.gain.setValueAtTime(0.22,t+i*0.04);
g.gain.exponentialRampToValueAtTime(0.001,t+i*0.04+0.14);
o.connect(g).connect(audioCtx.destination);
o.start(t+i*0.04);
o.stop(t+i*0.04+0.14);
});
}
else if(level>=4){
const o=audioCtx.createOscillator();
o.type='sawtooth';
o.frequency.setValueAtTime(300,t);
o.frequency.exponentialRampToValueAtTime(1500,t+0.08);
o.frequency.exponentialRampToValueAtTime(150,t+0.3);
const g=audioCtx.createGain();
g.gain.setValueAtTime(0.4,t);
g.gain.exponentialRampToValueAtTime(0.001,t+0.35);
const f=audioCtx.createBiquadFilter();
f.type='lowpass';
f.frequency.setValueAtTime(4000,t);
f.frequency.exponentialRampToValueAtTime(400,t+0.3);
o.connect(f).connect(g).connect(audioCtx.destination);
o.start(t);
o.stop(t+0.35);
}
}
function patlamaSesi(büyük=false) {
initAudio();
const vol = büyük?0.55:0.32;
const buffer = audioCtx.createBuffer(1, audioCtx.sampleRate*0.25, audioCtx.sampleRate);
const data = buffer.getChannelData(0);
for(let i=0;i<data.length;i++) data[i]=(Math.random()*2-1)*(1-i/data.length)**3;
const noise=audioCtx.createBufferSource();
noise.buffer=buffer;
const g=audioCtx.createGain();
g.gain.setValueAtTime(vol,audioCtx.currentTime);
g.gain.exponentialRampToValueAtTime(0.01,audioCtx.currentTime+0.25);
noise.connect(g).connect(audioCtx.destination);
noise.start();
}
function bossGirisSesi() {
initAudio();
const t = audioCtx.currentTime;
[220,330,440,660].forEach((f,i)=>{
const o=audioCtx.createOscillator();
o.type='sawtooth';
o.frequency.value=f;
const g=audioCtx.createGain();
g.gain.setValueAtTime(0.4,t+i*0.1);
g.gain.exponentialRampToValueAtTime(0.001,t+i*0.1+0.6);
o.connect(g).connect(audioCtx.destination);
o.start(t+i*0.1);
o.stop(t+i*0.1+0.6);
});
}
function bossAtesSesi() {
initAudio();
const t = audioCtx.currentTime;
[5,7,9].forEach((cnt,i)=>{
setTimeout(()=>{
const o=audioCtx.createOscillator();
o.type='sawtooth';
o.frequency.setValueAtTime(600,t);
o.frequency.exponentialRampToValueAtTime(80,t+0.3);
const g=audioCtx.createGain();
g.gain.setValueAtTime(0.35,t);
g.gain.exponentialRampToValueAtTime(0.001,t+0.35);
o.connect(g).connect(audioCtx.destination);
o.start(t);
o.stop(t+0.35);
}, i*50);
});
document.body.style.background='#400000';
setTimeout(()=>document.body.style.background='#200000',100);
setTimeout(()=>document.body.style.background='',200);
}
function powerupSesi(tip) {
initAudio();
const t=audioCtx.currentTime;
if(tip===5){
[660,880,1100].forEach((f,i)=>{
const o=audioCtx.createOscillator();
o.type='sine';
o.frequency.value=f;
const g=audioCtx.createGain();
g.gain.setValueAtTime(0.35,t+i*0.07);
g.gain.exponentialRampToValueAtTime(0.001,t+i*0.07+0.3);
o.connect(g).connect(audioCtx.destination);
o.start(t+i*0.07);
o.stop(t+i*0.07+0.3);
});
} else {
[700,900,1100,1400].forEach((f,i)=>{
const o=audioCtx.createOscillator();
o.type='sine';
o.frequency.value=f;
const g=audioCtx.createGain();
g.gain.setValueAtTime(0.2,t+i*0.05);
g.gain.exponentialRampToValueAtTime(0.001,t+i*0.05+0.25);
o.connect(g).connect(audioCtx.destination);
o.start(t+i*0.05);
o.stop(t+i*0.05+0.25);
});
}
}
function dusmanAtesSesi() {
initAudio();
const t=audioCtx.currentTime;
const o=audioCtx.createOscillator();
o.type='square';
o.frequency.setValueAtTime(380+Math.random()*100,t);
o.frequency.exponentialRampToValueAtTime(110,t+0.20);
const g=audioCtx.createGain();
g.gain.setValueAtTime(0.24,t);
g.gain.exponentialRampToValueAtTime(0.001,t+0.24);
o.connect(g).connect(audioCtx.destination);
o.start(t);
o.stop(t+0.24);
document.body.style.background='#200000';
setTimeout(()=>document.body.style.background='',70);
}
function ekranSars() {
let güç=14, sayac=0;
function sars(){
if(sayac++>14){
document.body.style.transform='';
return;
}
const x=(Math.random()-0.5)*güç, y=(Math.random()-0.5)*güç;
document.body.style.transform=`translate(${x}px,${y}px)`;
güç*=0.79;
setTimeout(sars,45);
}
sars();
}
// DETAYLI UZAY GEMİSİ ÇİZİMİ
function detayliUzayGemisiCiz(x, y) {
const genislik = 80;
const yukseklik = 80;
// Motor parlaklık animasyonu
if (motorParlaklikArtis) {
motorParlaklik += 0.08;
if (motorParlaklik >= 1) motorParlaklikArtis = false;
} else {
motorParlaklik -= 0.08;
if (motorParlaklik <= 0.4) motorParlaklikArtis = true;
}
// Ana gövde - füze şeklinde
ctx.fillStyle = '#2a2a4a';
ctx.shadowColor = '#4466ff';
ctx.shadowBlur = 20;
ctx.beginPath();
ctx.moveTo(x + genislik/2, y);
ctx.bezierCurveTo(
x + genislik, y + yukseklik/3,
x + genislik, y + yukseklik*2/3,
x + genislik/2, y + yukseklik
);
ctx.bezierCurveTo(
x, y + yukseklik*2/3,
x, y + yukseklik/3,
x + genislik/2, y
);
ctx.closePath();
ctx.fill();
// Kanatlar
ctx.fillStyle = '#1a1a3a';
ctx.beginPath();
ctx.moveTo(x + genislik/2 - 15, y + yukseklik/2);
ctx.lineTo(x, y + yukseklik - 10);
ctx.lineTo(x + genislik/2 - 5, y + yukseklik - 5);
ctx.closePath();
ctx.fill();
ctx.beginPath();
ctx.moveTo(x + genislik/2 + 15, y + yukseklik/2);
ctx.lineTo(x + genislik, y + yukseklik - 10);
ctx.lineTo(x + genislik/2 + 5, y + yukseklik - 5);
ctx.closePath();
ctx.fill();
// Ön kanatçıklar
ctx.fillStyle = '#333355';
ctx.beginPath();
ctx.moveTo(x + genislik/2 - 10, y + 20);
ctx.lineTo(x + 10, y + 40);
ctx.lineTo(x + genislik/2 - 5, y + 35);
ctx.closePath();
ctx.fill();
ctx.beginPath();
ctx.moveTo(x + genislik/2 + 10, y + 20);
ctx.lineTo(x + genislik - 10, y + 40);
ctx.lineTo(x + genislik/2 + 5, y + 35);
ctx.closePath();
ctx.fill();
// Köprü/kokpit
ctx.fillStyle = '#3a3a6a';
ctx.beginPath();
ctx.arc(x + genislik/2, y + 25, 15, 0, Math.PI, true);
ctx.fill();
// Kokpit camı
ctx.fillStyle = '#00ddff';
ctx.shadowColor = '#00ffff';
ctx.shadowBlur = 15;
ctx.beginPath();
ctx.arc(x + genislik/2, y + 20, 8, 0, Math.PI, true);
ctx.fill();
// Işıklandırma detayları
ctx.strokeStyle = '#4466ff';
ctx.lineWidth = 2;
ctx.shadowBlur = 10;
ctx.beginPath();
ctx.moveTo(x + genislik/2, y + 10);
ctx.lineTo(x + genislik/2, y + 15);
ctx.stroke();
// Motor bölümü
ctx.fillStyle = '#444466';
ctx.beginPath();
ctx.rect(x + 25, y + yukseklik - 15, 30, 10);
ctx.fill();
// Ana motor
const motorRenk = `rgba(255, ${100 + motorParlaklik * 155}, 0, ${0.8 + motorParlaklik * 0.2})`;
ctx.fillStyle = motorRenk;
ctx.shadowColor = '#ff5500';
ctx.shadowBlur = 25 + motorParlaklik * 15;
ctx.beginPath();
ctx.moveTo(x + 30, y + yukseklik - 5);
ctx.lineTo(x + 50, y + yukseklik - 5);
ctx.lineTo(x + 40, y + yukseklik + 30);
ctx.closePath();
ctx.fill();
// Yan motorlar
ctx.fillStyle = `rgba(255, ${150 + motorParlaklik * 105}, 50, ${0.6 + motorParlaklik * 0.3})`;
ctx.beginPath();
ctx.moveTo(x + 15, y + yukseklik - 10);
ctx.lineTo(x + 20, y + yukseklik - 10);
ctx.lineTo(x + 17, y + yukseklik + 20);
ctx.closePath();
ctx.fill();
ctx.beginPath();
ctx.moveTo(x + 60, y + yukseklik - 10);
ctx.lineTo(x + 65, y + yukseklik - 10);
ctx.lineTo(x + 62, y + yukseklik + 20);
ctx.closePath();
ctx.fill();
ctx.shadowBlur = 0;
}
// Motor partiküllerini çiz
function motorPartikulleriniCiz() {
for(let i = motorPartikuller.length - 1; i >= 0; i--) {
let p = motorPartikuller[i];
p.x += p.vx;
p.y += p.vy;
p.life--;
ctx.globalAlpha = p.life / 40;
ctx.fillStyle = `rgba(255, ${100 + Math.random() * 100}, 0, 0.8)`;
ctx.shadowColor = '#ff5500';
ctx.shadowBlur = 10;
ctx.beginPath();
ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
ctx.fill();
if(p.life <= 0) {
motorPartikuller.splice(i, 1);
}
}
ctx.globalAlpha = 1;
ctx.shadowBlur = 0;
}
// OYUN DÖNGÜSÜ
function oyun(){
if(powerupTimer>0){
powerupTimer-=16;
if(powerupTimer<=0){
silahLevel=1;
powerupTimer=0;
}
}
document.getElementById('can').textContent=can;
document.getElementById('skor').textContent=skor;
document.getElementById('silah').textContent=silahLevel;
document.getElementById('sure').textContent=powerupTimer>0?Math.ceil(powerupTimer/1000)+'s':'--';
// Arka plan
ctx.fillStyle='#000811';
ctx.fillRect(0,0,canvas.width,canvas.height);
// Yıldızlar
yildizlar.forEach(s=>{
s.y+=s.hiz;
if(s.y>canvas.height) s.y=-10;
ctx.globalAlpha=0.6+Math.random()*0.4;
ctx.fillStyle='#fff';
ctx.fillRect(s.x,s.y,s.r,s.r*3);
});
ctx.globalAlpha=1;
if(oyunBitti){
document.getElementById('gameover').style.display='block';
document.getElementById('sonuc').textContent=skor;
stopMusic();
requestAnimationFrame(oyun);
return;
}
// Oyuncu hareketi
let hedef=fareX-40;
if(hedef<0) hedef=0;
if(hedef>canvas.width-80) hedef=canvas.width-80;
oyuncu.x += (hedef-oyuncu.x)*0.3;
// Motor partikül oluştur
if(Math.random() < 0.6) {
motorPartikulOlustur();
}
// Oyuncu çizimi
detayliUzayGemisiCiz(oyuncu.x, oyuncu.y);
motorPartikulleriniCiz();
// Mermiler
for(let i=mermiler.length-1;i>=0;i--){
let m=mermiler[i];
m.x+=m.vx;
m.y+=m.vy;
ctx.fillStyle='#00ff00';
ctx.shadowColor='#00ff00';
ctx.shadowBlur=15;
ctx.fillRect(m.x,m.y,m.w,m.h);
if(m.y<-30) mermiler.splice(i,1);
}
ctx.shadowBlur=0;
// POWER-UPLAR
for(let i=powerups.length-1;i>=0;i--){
let p=powerups[i];
p.y+=p.hiz;
if(p.tip===5){
ctx.fillStyle='#ff3333';
ctx.shadowColor='#ff0000';
ctx.shadowBlur=35;
ctx.fillRect(p.x-23,p.y-23,p.w,p.h);
ctx.fillStyle='#fff';
ctx.font='bold 52px Arial';
ctx.textAlign='center';
ctx.textBaseline='middle';
ctx.fillText('♥', p.x, p.y);
} else {
ctx.fillStyle='#ffff00';
ctx.shadowColor='#ffff00';
ctx.shadowBlur=40;
ctx.fillRect(p.x-23,p.y-23,p.w,p.h);
ctx.fillStyle='#000';
ctx.font='bold 48px Arial';
ctx.textAlign='center';
ctx.textBaseline='middle';
ctx.fillText('★', p.x, p.y);
}
ctx.shadowBlur=0;
if(p.x<oyuncu.x+80 && p.x+46>oyuncu.x && p.y<oyuncu.y+80 && p.y+46>oyuncu.y){
if(p.tip===5){
if(can<5) can++;
} else {
silahLevel = p.tip + 1;
if(silahLevel>5) silahLevel=5;
powerupTimer=10000;
}
powerupSesi(p.tip);
powerups.splice(i,1);
}
if(p.y>canvas.height+50) powerups.splice(i,1);
}
// Patlamalar
for(let i=patlamalar.length-1;i>=0;i--){
let p=patlamalar[i];
p.x+=p.vx;
p.y+=p.vy;
p.life--;
p.r+=0.2;
ctx.globalAlpha=p.life/p.maxLife;
ctx.fillStyle='#ffaa00';
ctx.shadowColor='#ff4400';
ctx.shadowBlur=15;
ctx.beginPath();
ctx.arc(p.x,p.y,p.r,0,Math.PI*2);
ctx.fill();
if(p.life<=0) patlamalar.splice(i,1);
}
ctx.globalAlpha=1;
ctx.shadowBlur=0;
// BOSS KONTROLÜ
if(!bossActive && !bossWarningActive && !bossSpawned && skor >= bossSpawnScore && !bossOlduruldu) {
bossOlustur();
}
// BOSS GÜNCELLEME
if(bossActive && boss){
boss.hareketTimer++;
boss.y += boss.vy;
if(boss.y > 150) boss.y = 150;
const hedefX = oyuncu.x + 40 - boss.x - 100;
boss.x += Math.sin(boss.hareketTimer * 0.04) * 3 + hedefX * 0.015;
if(boss.x < 20) boss.x = 20;
if(boss.x > canvas.width - boss.w - 20) boss.x = canvas.width - boss.w - 20;
// HP Bar
const hpOran = boss.hp / boss.maxHp;
ctx.fillStyle='#333';
ctx.fillRect(boss.x, boss.y - 25, boss.w, 8);
ctx.fillStyle= hpOran > 0.5 ? '#0f0' : hpOran > 0.25 ? '#ff0' : '#f00';
ctx.shadowColor=ctx.fillStyle;
ctx.shadowBlur=10;
ctx.fillRect(boss.x, boss.y - 25, boss.w * hpOran, 8);
ctx.shadowBlur=0;
// Boss Çizim
ctx.fillStyle='#aa00ff';
ctx.shadowColor='#ff00ff';
ctx.shadowBlur=40;
ctx.beginPath();
ctx.moveTo(boss.x + 100, boss.y);
ctx.lineTo(boss.x + 20, boss.y + 80);
ctx.lineTo(boss.x + 50, boss.y + 120);
ctx.lineTo(boss.x + 150, boss.y + 120);
ctx.lineTo(boss.x + 180, boss.y + 80);
ctx.closePath();
ctx.fill();
ctx.fillStyle='#ffff88';
ctx.shadowColor='#ffff00';
ctx.shadowBlur=25;
ctx.beginPath();
ctx.arc(boss.x + 100, boss.y + 20, 25, 0, Math.PI*2);
ctx.fill();
ctx.shadowBlur=0;
// Boss Ateş
boss.atesTimer--;
if(boss.atesTimer <= 0){
bossAtesSesi();
const mx = boss.x + 100, my = boss.y + 80;
for(let i = -2; i <= 2; i++){
const a = i * 15 * Math.PI / 180;
dusmanMermileri.push({
x: mx,
y: my,
w: 8,
h: 22,
vx: Math.sin(a) * 5,
vy: Math.cos(a) * 6.5,
bossMermi: true
});
}
boss.atesTimer = boss.atesDelay;
boss.atesDelay = Math.max(45, boss.atesDelay - 2);
}
document.getElementById('bosshp').textContent = `${boss.hp}/${boss.maxHp}`;
// Mermi çarpması BOSS'a
for(let j=mermiler.length-1; j>=0; j--){
let m = mermiler[j];
if(m.x + m.w > boss.x && m.x < boss.x + boss.w && m.y + m.h > boss.y && m.y < boss.y + boss.h){
mermiler.splice(j,1);
boss.hp -= 1;
if(Math.random() < 0.3) {
patlama(m.x + 3, m.y + 10, false);
}
if(boss.hp <= 0){
// BOSS ÖLDÜ
skor += 500;
level++;
bossSpawnScore += 500;
bossSpawned = false;
bossActive = false;
bossOlduruldu = true;
patlama(boss.x + 100, boss.y + 60, true);
powerupOlustur(boss.x + 100, boss.y + 60);
if(Math.random() < 0.7) powerupOlustur(boss.x + 50, boss.y + 60);
if(Math.random() < 0.7) powerupOlustur(boss.x + 150, boss.y + 60);
boss = null;
document.getElementById('bossui').style.display = 'none';
document.getElementById('level').style.display = 'none';
for(let k=0; k<3; k++) setTimeout(ekranSars, k*300);
break;
}
}
}
} else {
document.getElementById('bossui').style.display = 'none';
}
// Düşman oluşturma
if(!bossActive && !bossWarningActive && Math.random()<0.008 + skor/200000) dusmanOlustur();
// YENİ DÜŞMANLAR
for(let i=dusmanlar.length-1; i>=0; i--){
let d = dusmanlar[i];
const dusmanTipi = DUSMAN_TIPLERI[d.tur];
d.y += d.hiz;
d.atesZaman--;
// Can çubuğu
ctx.fillStyle='#f00';
ctx.fillRect(d.x+5,d.y-12,50*(d.hp/dusmanTipi.hp),6);
// Uzaylı gemisi çiz
uzayliGemisiCiz(d.x, d.y, d.w, d.h, d.tur);
// Ateş - farklı düşmanlar farklı ateş oranlarına sahip
if(d.atesZaman<=0 && Math.random()<dusmanTipi.atesOran){
dusmanMermileri.push({x:d.x+27,y:d.y+40,w:6,h:18,hiz:4.8});
dusmanAtesSesi();
d.atesZaman=dusmanTipi.atesGecikme+Math.random()*220;
}
// Mermi çarpması
for(let j=mermiler.length-1; j>=0; j--){
let m = mermiler[j];
if(m.x < d.x+d.w && m.x+m.w > d.x && m.y < d.y+d.h && m.y+m.h > d.y){
mermiler.splice(j,1);
d.hp--;
if(d.hp <= 0){
skor += dusmanTipi.puan;
patlama(d.x + d.w/2, d.y + d.h/2);
powerupOlustur(d.x + d.w/2, d.y + d.h/2);
dusmanlar.splice(i,1);
} else {
if(Math.random() < 0.5) {
patlama(m.x + 3, m.y + 10, false);
}
}
break;
}
}
// Düşman aşağı inince hasar
if (d.y + d.h >= oyuncu.y) {
ekranSars();
patlama(oyuncu.x + 40, oyuncu.y + 40);
can--;
dusmanlar.splice(i, 1);
if (can <= 0) {
oyunBitti = true;
ekranSars();
patlama(oyuncu.x + 40, oyuncu.y + 40, true);
}
continue;
}
if (d.y > canvas.height + 50) {
dusmanlar.splice(i, 1);
}
}
// DÜŞMAN ve BOSS MERMİLERİ
for(let i=dusmanMermileri.length-1;i>=0;i--){
let dm=dusmanMermileri[i];
dm.x += dm.vx || 0;
dm.y += dm.vy || dm.hiz;
const mermiRenk = dm.bossMermi ? '#ff4400' : '#ff0000';
ctx.fillStyle=mermiRenk;
ctx.shadowColor=mermiRenk;
ctx.shadowBlur= dm.bossMermi ? 18 : 12;
ctx.fillRect(dm.x,dm.y,dm.w,dm.h);
ctx.shadowBlur=0;
if(dm.x<oyuncu.x+80&&dm.x+dm.w>oyuncu.x&&dm.y<oyuncu.y+80&&dm.y+dm.h>oyuncu.y){
ekranSars();
patlama(oyuncu.x+40,oyuncu.y+40, dm.bossMermi);
can--;
dusmanMermileri.splice(i,1);
if(can<=0){
oyunBitti=true;
ekranSars();
patlama(oyuncu.x+40,oyuncu.y+40,true);
}
}
if(dm.y>canvas.height) dusmanMermileri.splice(i,1);
}
requestAnimationFrame(oyun);
}
// EVENT LISTENERS
canvas.addEventListener('click', atesEt);
canvas.addEventListener('touchstart', e=>{e.preventDefault(); atesEt();});
canvas.addEventListener('mousemove', e=>fareX=e.clientX);
canvas.addEventListener('touchmove', e=>{e.preventDefault(); if(e.touches.length) fareX=e.touches[0].clientX;});
function yeniden(){
mermiler=[];
dusmanMermileri=[];
dusmanlar=[];
powerups=[];
patlamalar=[];
motorPartikuller = [];
boss = null;
bossActive = false;
bossWarningActive = false;
bossSpawned = false;
bossOlduruldu = false;
level = 1;
bossSpawnScore = 500;
can=5;
skor=0;
oyunBitti=false;
silahLevel=1;
powerupTimer=0;
oyuncu.x=canvas.width/2-40;
document.getElementById('gameover').style.display='none';
document.getElementById('bossui').style.display='none';
document.getElementById('bossWarning').style.display='none';
document.getElementById('level').style.display='none';
document.body.style.transform='';
document.body.style.background='';
stopMusic();
setTimeout(startMusic,600);
}
window.onresize = ()=>{
canvas.width=innerWidth;
canvas.height=innerHeight;
oyuncu.y=canvas.height-120;
oyuncu.x=canvas.width/2-40;
};
// Oyunu başlat
startMusic();
oyun();
</script>
</body>
</html>
Son düzenleme: