diff --git a/gambar/ApelLayer.png b/gambar/ApelLayer.png deleted file mode 100644 index 6e0a485..0000000 Binary files a/gambar/ApelLayer.png and /dev/null differ diff --git a/gambar/BadanHorizontal.png b/gambar/BadanHorizontal.png deleted file mode 100644 index 3e95b8c..0000000 Binary files a/gambar/BadanHorizontal.png and /dev/null differ diff --git a/gambar/BadanVertikal.png b/gambar/BadanVertikal.png deleted file mode 100644 index 112d4cd..0000000 Binary files a/gambar/BadanVertikal.png and /dev/null differ diff --git a/gambar/BelokAtasKanan.png b/gambar/BelokAtasKanan.png deleted file mode 100644 index 6e04606..0000000 Binary files a/gambar/BelokAtasKanan.png and /dev/null differ diff --git a/gambar/BelokAtasKiri.png b/gambar/BelokAtasKiri.png deleted file mode 100644 index 56dbc54..0000000 Binary files a/gambar/BelokAtasKiri.png and /dev/null differ diff --git a/gambar/BelokBawahKanan.png b/gambar/BelokBawahKanan.png deleted file mode 100644 index 02f7449..0000000 Binary files a/gambar/BelokBawahKanan.png and /dev/null differ diff --git a/gambar/BelokBawahKiri.png b/gambar/BelokBawahKiri.png deleted file mode 100644 index aa6a1f9..0000000 Binary files a/gambar/BelokBawahKiri.png and /dev/null differ diff --git a/gambar/BokongHorizontalKanan.png b/gambar/BokongHorizontalKanan.png deleted file mode 100644 index 715a3d7..0000000 Binary files a/gambar/BokongHorizontalKanan.png and /dev/null differ diff --git a/gambar/BokongHorizontalKiri.png b/gambar/BokongHorizontalKiri.png deleted file mode 100644 index 9249679..0000000 Binary files a/gambar/BokongHorizontalKiri.png and /dev/null differ diff --git a/gambar/BokongVertikalAtas.png b/gambar/BokongVertikalAtas.png deleted file mode 100644 index 47d09c8..0000000 Binary files a/gambar/BokongVertikalAtas.png and /dev/null differ diff --git a/gambar/BokongVertikalBawah.png b/gambar/BokongVertikalBawah.png deleted file mode 100644 index 879b900..0000000 Binary files a/gambar/BokongVertikalBawah.png and /dev/null differ diff --git a/gambar/KepalaHorizontalKanan.png b/gambar/KepalaHorizontalKanan.png deleted file mode 100644 index 6fc8cba..0000000 Binary files a/gambar/KepalaHorizontalKanan.png and /dev/null differ diff --git a/gambar/KepalaHorizontalKiri.png b/gambar/KepalaHorizontalKiri.png deleted file mode 100644 index 9b62d18..0000000 Binary files a/gambar/KepalaHorizontalKiri.png and /dev/null differ diff --git a/gambar/KepalaVertikalAtas.png b/gambar/KepalaVertikalAtas.png deleted file mode 100644 index 270012a..0000000 Binary files a/gambar/KepalaVertikalAtas.png and /dev/null differ diff --git a/gambar/KepalaVertikalBawah.png b/gambar/KepalaVertikalBawah.png deleted file mode 100644 index a653ef1..0000000 Binary files a/gambar/KepalaVertikalBawah.png and /dev/null differ diff --git a/gambar/PialaLayer.png b/gambar/PialaLayer.png deleted file mode 100644 index c318312..0000000 Binary files a/gambar/PialaLayer.png and /dev/null differ diff --git a/gambar/Tembok.png b/gambar/Tembok.png deleted file mode 100644 index f544a41..0000000 Binary files a/gambar/Tembok.png and /dev/null differ diff --git a/gambar/daftar.php b/gambar/daftar.php deleted file mode 100644 index b6facd6..0000000 --- a/gambar/daftar.php +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - Halaman: Daftar - - - alert("Selamat, anda berhasil mandaftarkan acc anda!")'; - } else { - echo ''; - } - } - - ?> - -
- - - - - - - - - - - - - - - - - - - - -
-

Pendaftaran User

-
Nama
Username
Password
- - Login -
-
- - - \ No newline at end of file diff --git a/gambar/index.php b/gambar/index.php deleted file mode 100644 index 0ec3d92..0000000 --- a/gambar/index.php +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - Halaman ke-1 - - -

Halaman ke-1

- Home - Logout -
- -

Selamat datang,

- Halaman ini akan tampil setelah user login. - - \ No newline at end of file diff --git a/gambar/koneksi.php b/gambar/koneksi.php deleted file mode 100644 index 18ee0c8..0000000 --- a/gambar/koneksi.php +++ /dev/null @@ -1,4 +0,0 @@ - \ No newline at end of file diff --git a/gambar/login.php b/gambar/login.php deleted file mode 100644 index dce79d1..0000000 --- a/gambar/login.php +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - Halaman: Login - - - 0) { - $data = mysqli_fetch_array($query); - $_SESSION['users'] = $data; - echo ''; - } else { - echo ''; - } - } - ?> - -
- - - - - - - - - - - - - - - - - -
-

Login User

-
Username
Password
- - Daftar -
-
- - - \ No newline at end of file diff --git a/gambar/logout.php b/gambar/logout.php deleted file mode 100644 index 99fdf0c..0000000 --- a/gambar/logout.php +++ /dev/null @@ -1,9 +0,0 @@ - - \ No newline at end of file diff --git a/game.html b/game.html index 76970c5..123bc35 100644 --- a/game.html +++ b/game.html @@ -80,9 +80,7 @@
-
- Controls:
Movement: W A S D

-
+
Controls:
Movement: W A S D

@@ -105,21 +103,33 @@ //generate gambar external var KepalaUlarImage = new Image(); - KepalaUlarImage.src = "image/KepalaVertikalAtas.png"; // kepala ular + KepalaUlarImage.src = "image/KepalaHorizontalKanan.png"; + var KepalAtas = new Image(); + KepalAtas.src = "image/KepalaVertikalAtas.png"; + var KepalaBawah = new Image(); + KepalaBawah.src = "image/KepalaVertikalBawah.png"; + var KepalaKiri = new Image(); + KepalaKiri.src = "image/KepalaHorizontalKiri.png"; + var KepalaKanan = new Image(); + KepalaKanan.src = "image/KepalaHorizontalKanan.png"; + // ↑ kepala ular + var BadanUlarImage = new Image(); - BadanUlarImage.src = "image/BadanVertikal.png"; // badan ular awal + BadanUlarImage.src = "image/BadanVertikal.png"; + // ↑ badan ular + var ApelImage = new Image(); ApelImage.src = "image/ApelLayer.png"; // Apel var TembokImage = new Image(); TembokImage.src = "image/Tembok.png"; // Tembok Batagor -//D:\PROYEK UAS\Game ULAR\gambar\Tembok.png + //D:\PROYEK UAS\Game ULAR\gambar\Tembok.png //set posisi ular dan Apel var Ular = { x: 400, y: 400, dx: grid, dy: 0, cells: [], maxCells: 4 }; var Apel = { x: 0, y: 0 }; var Tembok = []; - UpdateScore(-1); + UpdateScore(0); RandomizeApel(); RandomSpawnWall(); @@ -143,8 +153,10 @@ Ular.maxCells = 4; Ular.dx = grid; Ular.dy = 0; + Tembok = []; RandomizeApel(); - UpdateScore(-1); + UpdateScore(0); + RandomSpawnWall(); } } else { InputKeyboard(); @@ -183,13 +195,20 @@ if (TembokX === Apel.x && TembokY === Apel.y) { kosong = false; } + + for (var i = 0; i < Tembok.length; i++) { + if (Tembok[i].x === TembokX && Tembok[i].y === TembokY) { + kosong = false; + break; + } + } } while (kosong === false); - Tembok.push({x:TembokX, y:TembokY}) + Tembok.push({ x: TembokX, y: TembokY }); } - //nambah tembok tiap score +10 + //nambah tembok tiap score kelipatan ... berapa enaknya ya? 😁 function PenambahanTembok() { - if (score > 0 && score % 10 === 0 && Tembok.length < (score/10)) { + if (Tembok.length < Math.floor(score / 2)) { RandomSpawnWall(); } } @@ -205,8 +224,8 @@ highscore + "
Speed: " + speed; - - PenambahanTembok(); + + PenambahanTembok(); } //gameover countdown @@ -224,10 +243,36 @@ function IntiGame() { //buat gambarnya bisa keluar content.drawImage(ApelImage, Apel.x, Apel.y, grid, grid); - - Tembok.forEach(function(bata) { + Tembok.forEach(function (bata) { content.drawImage(TembokImage, bata.x, bata.y, grid, grid); - }) + }); + + Ular.cells.forEach(function (cell, index) { + if (index === 0) { + // Logika Pemilihan Gambar Kepala Ular + var posisiKepalaImage; + if (Ular.dx === grid) { + // KANAN + posisiKepalaImage = KepalaKanan; + } else if (Ular.dx === -grid) { + // KIRI + posisiKepalaImage = KepalaKiri; + } else if (Ular.dy === -grid) { + // ATAS + posisiKepalaImage = KepalAtas; + } else if (Ular.dy === grid) { + // BAWAH + posisiKepalaImage = KepalaBawah; + } else { + // Default, misalnya saat game baru mulai (dx=grid, dy=0, atau default awal) + posisiKepalaImage = KepalaKanan; + } + + content.drawImage(posisiKepalaImage, cell.x, cell.y, grid, grid); + } else { + content.drawImage(BadanUlarImage, cell.x, cell.y, grid, grid); + } + }); //bagian generate ular Ular.cells.forEach(function (cell, index) { @@ -246,10 +291,10 @@ //tabrak tembok = mati if (index === 0) { - Tembok.forEach(function(bata) { - if (cell.x === wall.x && cell.y === wall.y) { - GameOver(); - } + Tembok.forEach(function (bata) { + if (cell.x === bata.x && cell.y === bata.y) { + GameOver(); + } }); }