From 31c073b09c2e27c7c3efd23910e58b8e91e8d4bd Mon Sep 17 00:00:00 2001 From: basilius leta Date: Mon, 15 Dec 2025 20:34:44 +0700 Subject: [PATCH] perubahan logika permainan --- assets/js/game.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/assets/js/game.js b/assets/js/game.js index 92dbd9b..663205f 100644 --- a/assets/js/game.js +++ b/assets/js/game.js @@ -2,7 +2,6 @@ const canvas = document.getElementById("board"); if (!canvas) alert("Canvas tidak ditemukan! ID harus 'board'"); const ctx = canvas.getContext("2d"); -// ensure canvas actual pixel size used for tileSize calculation const CANVAS_W = canvas.width; const CANVAS_H = canvas.height; @@ -20,7 +19,8 @@ let aiPlays = 2; let aiThinkingDelay = 300; let hintsEnabled = (typeof ENABLE_HINTS !== "undefined") ? !!ENABLE_HINTS : true; -/********** SOUND EFFECT **********/ + +// SOUND EFFECTS const SFX = { move: new Audio("assets/sound/move.mp3"), capture: new Audio("assets/sound/capture.mp3") @@ -67,16 +67,15 @@ function resetBoard(){ startTimer(); draw(); - // small defer so UI painted before AI moves + // TRIGGER AI JIKA PERMAINAN DIMULAI OLEH AI if(aiEnabled && currentTurn === aiPlays){ setTimeout(()=> triggerAI(), 120); } } -/********** DRAW **********/ +// MENGGAMBAR PAPAN PADA CANVAS function draw(){ - // safety: re-compute tileSize if canvas resized via CSS (keep consistent) - // (we keep original tileSize computed from initial canvas.width) + // MENGGAMBAR PAPAN ctx.clearRect(0,0,CANVAS_W,CANVAS_H); for(let r=0;r