diff --git a/GameLogic.js b/GameLogic.js index 0bd607b..85f0940 100644 --- a/GameLogic.js +++ b/GameLogic.js @@ -336,35 +336,5 @@ : speed; }); } - - function updatedatabase(scoreBaru) { - // 1. Buat objek data yang akan dikirim - const KirimScore = { - action: 'SaveScore', // Identifier untuk PHP - score: scoreBaru - }; - - // 2. Gunakan Fetch API untuk mengirim permintaan POST - fetch('score.php', { // Ganti dengan nama file PHP Anda - method: 'POST', - headers: { - 'Content-Type': 'application/json' // Beri tahu server bahwa yang dikirim adalah JSON - }, - body: JSON.stringify(KirimScore) // Konversi data JS menjadi string JSON - }) - .then(response => response.json()) // Ubah respons server kembali menjadi objek JS - .then(data => { - // 3. Tangani respons dari PHP - if (data.status === 'success') { - console.log('Score berhasil disimpan:', data.message); - // Lakukan sesuatu (misalnya: tampilkan pesan sukses di UI) - } else { - console.error('Gagal menyimpan score:', data.message); - } - }) - .catch(error => { - console.error('Terjadi kesalahan koneksi:', error); - }); -} InputKeyboard(); gameLoop(); \ No newline at end of file diff --git a/gameOver/gameOver.png b/gameOver/gameOver.png new file mode 100644 index 0000000..2cefafe Binary files /dev/null and b/gameOver/gameOver.png differ diff --git a/home.html b/home.html new file mode 100644 index 0000000..35629ef --- /dev/null +++ b/home.html @@ -0,0 +1,48 @@ + + + + +

EAT THAT APPLE

+
+ +
Play Game
+
+ +
Leaderboard
+
Logout
+
+ + + + + diff --git a/login.php b/login.php index a65bf50..602e4b5 100644 --- a/login.php +++ b/login.php @@ -20,39 +20,50 @@ if(isset($_POST['username'])) { ?> - - - - - Halaman: Login - - + + + + + + Halaman: Login + + -
- - - - - +
+ +
-

Login User

-
+ + + + - - - - - - - - - - - -
+

Login User

+
- - Daftar -
-
+ + + + + + + + + + + + Daftar + + + + + + - + \ No newline at end of file diff --git a/login/log.png b/login/log.png new file mode 100644 index 0000000..316ff70 Binary files /dev/null and b/login/log.png differ diff --git a/login/login.png b/login/login.png new file mode 100644 index 0000000..316ff70 Binary files /dev/null and b/login/login.png differ diff --git a/mapGame/mapgame .png b/mapGame/mapgame .png new file mode 100644 index 0000000..a6cae96 Binary files /dev/null and b/mapGame/mapgame .png differ diff --git a/score.php b/score.php deleted file mode 100644 index ed7fe70..0000000 --- a/score.php +++ /dev/null @@ -1,59 +0,0 @@ - PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - PDO::ATTR_EMULATE_PREPARES => false, -]; - -try { - $pdo = new PDO($dsn, $user, $pass, $options); -} catch (\PDOException $e) { - http_response_code(500); // Internal Server Error - echo json_encode(['status' => 'error', 'message' => 'Gagal koneksi database.']); - exit; -} - -// --- 2. Ambil Data dari JavaScript (AJAX) --- -$data = json_decode(file_get_contents('php://input'), true); - -if (!isset($data['action']) || $data['action'] !== 'simpan_score') { - http_response_code(400); // Bad Request - echo json_encode(['status' => 'error', 'message' => 'Aksi tidak valid.']); - exit; -} - -$score = filter_var($data['score'] ?? 0, FILTER_SANITIZE_NUMBER_INT); -$userId = 1; // Contoh: Asumsikan ID pengguna 1 (Anda harus mengambilnya dari sesi atau input) - -if (!is_numeric($score) || $score < 0) { - http_response_code(400); - echo json_encode(['status' => 'error', 'message' => 'Score tidak valid.']); - exit; -} - -// --- 3. Simpan ke Database (menggunakan Prepared Statements) --- -try { - $sql = "INSERT INTO scores (user_id, score, created_at) VALUES (?, ?, NOW())"; - $stmt = $pdo->prepare($sql); - $stmt->execute([$userId, $score]); - - // Berikan respons sukses ke JavaScript - echo json_encode(['status' => 'success', 'message' => 'Score berhasil disimpan.']); - -} catch (\PDOException $e) { - http_response_code(500); - echo json_encode(['status' => 'error', 'message' => 'Gagal menyimpan score ke DB: ' . $e->getMessage()]); -} - -?> \ No newline at end of file diff --git a/succes/loginSuccess.png b/succes/loginSuccess.png new file mode 100644 index 0000000..f2fc52c Binary files /dev/null and b/succes/loginSuccess.png differ