← → ↑ ↓ — управление · Enter — новая игра

Flower Builder
Para: 0 | Alan: 1
//================== PART 2 ================== // EV SİSTEMİ (BLOKLARLA İNŞA) let blocks=[]; let selectedItem="flowerBlock"; // BLOK SATIN ALMA function buyItem(type, cost){ if(money>=cost){ money-=cost; document.getElementById("money").innerText=money; if(type==="flowerBlock"){ selectedItem="flowerBlock"; } if(type==="chair"){ selectedItem="chair"; blocks.push({type:"chair",x:200,y:200}); } } } // BLOK KOYMA document.addEventListener("click",e=>{ if(selectedItem==="flowerBlock" && money>=5){ money-=5; blocks.push({ type:"flowerBlock", x:player.x, y:player.y }); document.getElementById("money").innerText=money; } }); // BLOKLARI ÇİZ function drawBlocks(){ for(let b of blocks){ if(b.type==="flowerBlock"){ ctx.fillStyle="green"; ctx.fillRect(b.x,b.y,20,20); } if(b.type==="chair"){ ctx.fillStyle="brown"; ctx.fillRect(b.x,b.y,20,20); } } } // EV ALANI BÜYÜTME SINIRI function limitArea(){ let max=area*150; if(player.x>max)player.x=max; if(player.y>max)player.y=max; } // LOOP GÜNCELLE function loop(){ collect(); limitArea(); draw(); drawBlocks(); requestAnimationFrame(loop); }loop(); /================== PART 3 ================== // SUNUCU DEĞERLENDİRME SİSTEMİ function evaluateHouse(){ let score = 0; // blok sayısı for(let b of blocks){ if(b.type==="flowerBlock") score += 1; if(b.type==="chair") score += 5; } // alan bonusu score += area * 10; // rastgele “sunucu puanı hissi” score += Math.floor(Math.random()*10); return score; } // EV SATIŞ SİSTEMİ function sellHouse(){ let result = evaluateHouse(); let reward = result * 2; money += reward; blocks = []; area = 1; spawnFlowers(); document.getElementById("money").innerText = money; document.getElementById("area").innerText = area; alert("Sunucu puanı: " + result + " | Kazanç: " + reward); } // SATIŞ TUŞU document.addEventListener("keydown",e=>{ if(e.key==="s"){ sellHouse(); } }); // SON GAME LOOP (TEK MERKEZ) function loop(){ collect(); limitArea(); draw(); drawBlocks(); // küçük UI güncelleme document.getElementById("money").innerText = money; document.getElementById("area").innerText = area; requestAnimationFrame(loop); } loop();//================== PART 4 ================== // DEKOR SİSTEMİ (MASA - YATAK - LAMBA) let decorShop = [ {type:"table",cost:30}, {type:"bed",cost:60}, {type:"lamp",cost:40} ]; // SATIN AL VE KOY function buyDecor(type,cost){ if(money < cost) return; money -= cost; let x = player.x + Math.random()*30; let y = player.y + Math.random()*30; blocks.push({ type:type, x:x, y:y }); } // ÇİZİM GÜNCELLEME function drawBlocks(){ for(let b of blocks){ if(b.type==="flowerBlock"){ ctx.fillStyle="#4caf50"; ctx.fillRect(b.x,b.y,18,18); } if(b.type==="chair"){ ctx.fillStyle="#8d6e63"; ctx.fillRect(b.x,b.y,18,18); } if(b.type==="table"){ ctx.fillStyle="#6d4c41"; ctx.fillRect(b.x,b.y,25,15); } if(b.type==="bed"){ ctx.fillStyle="#e57373"; ctx.fillRect(b.x,b.y,30,15); } if(b.type==="lamp"){ ctx.fillStyle="#fff176"; ctx.beginPath(); ctx.arc(b.x,b.y,8,0,Math.PI*2); ctx.fill(); } } } // OTOMATİK PARA KAZANMA (EV GELİRİ) function houseIncome(){ let income = 0; for(let b of blocks){ if(b.type!=="flowerBlock"){ income += 0.05; } } money += income; } // UPDATE LOOP function loop(){ collect(); limitArea(); houseIncome(); draw(); drawBlocks(); document.getElementById("money").innerText = Math.floor(money); document.getElementById("area").innerText = area; requestAnimationFrame(loop); } loop();//================== PART 4 ================== // DEKOR SİSTEMİ (MASA - YATAK - LAMBA) let decorShop = [ {type:"table",cost:30}, {type:"bed",cost:60}, {type:"lamp",cost:40} ]; // SATIN AL VE KOY function buyDecor(type,cost){ if(money < cost) return; money -= cost; let x = player.x + Math.random()*30; let y = player.y + Math.random()*30; blocks.push({ type:type, x:x, y:y }); } // ÇİZİM GÜNCELLEME function drawBlocks(){ for(let b of blocks){ if(b.type==="flowerBlock"){ ctx.fillStyle="#4caf50"; ctx.fillRect(b.x,b.y,18,18); } if(b.type==="chair"){ ctx.fillStyle="#8d6e63"; ctx.fillRect(b.x,b.y,18,18); } if(b.type==="table"){ ctx.fillStyle="#6d4c41"; ctx.fillRect(b.x,b.y,25,15); } if(b.type==="bed"){ ctx.fillStyle="#e57373"; ctx.fillRect(b.x,b.y,30,15); } if(b.type==="lamp"){ ctx.fillStyle="#fff176"; ctx.beginPath(); ctx.arc(b.x,b.y,8,0,Math.PI*2); ctx.fill(); } } } // OTOMATİK PARA KAZANMA (EV GELİRİ) function houseIncome(){ let income = 0; for(let b of blocks){ if(b.type!=="flowerBlock"){ income += 0.05; } } money += income; } // UPDATE LOOP function loop(){ collect(); limitArea(); houseIncome(); draw(); drawBlocks(); document.getElementById("money").innerText = Math.floor(money); document.getElementById("area").innerText = area; requestAnimationFrame(loop); } loop();//================== FINAL PART ================== // UZAYAN ALAN SİSTEMİ (GERÇEK BÜYÜME) function expandArea(){ if(money >= area * 80){ money -= area * 80; area++; spawnFlowers(); } } // DAHA ZOR ÇİÇEK ÜRETİMİ function spawnFlowers(){ flowers=[]; let count = 15 + area * 5; for(let i=0;i=0;i--){ let f = flowers[i]; let dx = player.x - f.x; let dy = player.y - f.y; if(Math.sqrt(dx*dx+dy*dy) < 20){ money += f.value * area; flowers.splice(i,1); } } } // ÇİÇEK ÇİZİMİ function drawFlowers(){ for(let f of flowers){ ctx.fillStyle = "pink"; ctx.beginPath(); ctx.arc(f.x,f.y,6,0,Math.PI*2); ctx.fill(); } } // FINAL LOOP (TEMİZ VE STABİL) function loop(){ collect(); expandArea(); draw(); drawFlowers(); drawBlocks(); document.getElementById("money").innerText = Math.floor(money); document.getElementById("area").innerText = area; requestAnimationFrame(loop); } loop(); // ================== FINAL CONTROLS + GAME FIX ================== // HAREKET SİSTEMİ (YUMUŞAK + STABİL) window.addEventListener("keydown",(e)=>{ let speed = 10; switch(e.key){ case "ArrowUp": player.y -= speed; break; case "ArrowDown": player.y += speed; break; case "ArrowLeft": player.x -= speed; break; case "ArrowRight": player.x += speed; break; } }); // SINIRLAR (EKRANDAN ÇIKMASIN) function clampPlayer(){ if(player.x < 0) player.x = 0; if(player.y < 0) player.y = 0; if(player.x > window.innerWidth) player.x = window.innerWidth; if(player.y > window.innerHeight) player.y = window.innerHeight; } // ÇİÇEK TOPLAMA (GÜVENLİ) function collect(){ for(let i = flowers.length - 1; i >= 0; i--){ let f = flowers[i]; let dx = player.x - f.x; let dy = player.y - f.y; if(Math.sqrt(dx*dx + dy*dy) < 18){ money += f.value; flowers.splice(i,1); } } } // BÜYÜME SİSTEMİ function expandArea(){ if(money >= area * 90){ money -= area * 90; area++; spawnFlowers(); } } // ANA OYUN DÖNGÜSÜ (SON HAL) function loop(){ clampPlayer(); collect(); expandArea(); render(); document.getElementById("money").innerText = Math.floor(money); document.getElementById("area").innerText = area; requestAnimationFrame(loop); } // TEK BAŞLATMA if(!window.__GAME_STARTED__){ window.__GAME_STARTED__ = true; loop(); } // ================== FINAL MERGE + PLAYABLE CORE ================== // ================== FINAL CLEAN VERSION (STABLE GAME) ================== Flower Game FIX
Para: 0 | Alan: 1