Compare commits

..

3 Commits
main ... yeri

Author SHA1 Message Date
06ffdaaf7d test 2025-12-01 13:10:03 +07:00
1191fdfca7 update gameover 2025-11-29 21:50:33 +07:00
8d57266b16 update game ga langsung start 2025-11-29 19:38:35 +07:00
12 changed files with 151 additions and 316 deletions

View File

@ -75,6 +75,49 @@
#keluar:hover { #keluar:hover {
background-color: #d32f2f; background-color: #d32f2f;
} }
.starting {
position: absolute;
top: 21px;
left: 51px;
width: 1056px;
height: 480px;
background-color: rgba(100, 100, 100, 0.8);
display: flex;
align-items: center;
justify-content: center;
z-index: 10;
}
#start {
position: absolute;
top: 21px;
left: 51px;
width: 1056px;
height: 480px;
background-color: rgba(100, 100, 100, 0.8);
display: flex;
align-items: center;
justify-content: center;
z-index: 10;
}
.popAwal {
text-align: center;
border-radius: 10px;
background-color: rgb(50, 50, 50);
padding: 30px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
width: 80%;
max-width: 400px;
}
.popAwal h1 {
margin-left: 30px;
margin-right: 25px;
}
#keluar {
background-color: #f44336;
}
#keluar:hover {
background-color: #d32f2f;
}
.icon { .icon {
width: 70px; width: 70px;
height: 70px; height: 70px;

View File

@ -26,10 +26,7 @@
<h1 style="color: red" id="gameover-title">YOU DIED</h1> <h1 style="color: red" id="gameover-title">YOU DIED</h1>
<p id="gameover-score">Score: 0</p> <p id="gameover-score">Score: 0</p>
<button id="ulangi" class="modegame">Main lagi?</button> <button id="ulangi" class="modegame">Main lagi?</button>
<a href="http://localhost/uas_sem_1/index.php"> <button id="keluar" class="modegame">Keluar?</button>
<button id="keluar" class="">Keluar?</button>
</a>
</div> </div>
</div> </div>
<div id="gameover" class="gameover"></div> <div id="gameover" class="gameover"></div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View File

@ -16,6 +16,7 @@
width: 70%; width: 70%;
justify-self: center; justify-self: center;
background-image: url(); background-image: url();
} }
#button { #button {
@ -34,15 +35,13 @@
<body> <body>
<h1>EAT THAT APPLE</h1> <h1>EAT THAT APPLE</h1>
<div class="container"> <div class="container">
<a href="game.html">
<div id="button">Play Game</div> <div id="button">Play Game</div>
</a>
<div id="button">Leaderboard</div> <div id="button">Leaderboard</div>
<div id="button">Logout</div> <div id="button">Quit</div>
</div> </div>
<input type="text">
</body> </body>
<script></script> <script>
</script>
</html> </html>

View File

@ -1,72 +1,26 @@
<?php <?php
// buat inisialisasi session
session_start(); session_start();
// mengecek apakah ada session user yang aktif, jika tidak arahkan ke login.php
if(!isset($_SESSION['users'])) { if(!isset($_SESSION['users'])) {
header('location:login.php'); header('location:login.php'); // arahkan ke login.php
} }
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="id"> <html lang="id">
<style>
body {
background-image: url();
}
h1 {
text-align: center;
margin-top: 10%;
font-size: 85px;
}
.container {
padding: 5px;
border: 2px solid; /* Nanti dihapus */
border-radius: 7pt; /* Nanti dihapus */
width: 70%;
justify-self: center;
background-image: url();
}
#button {
font-size: 35px;
margin-top: 5%;
width: 50%;
margin-bottom: 5%;
border: 1px solid;
border-radius: 3pt;
padding: 2px;
justify-self: center;
text-align: center;
}
</style>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Halaman ke-1</title> <title>Halaman ke-1</title>
</head> </head>
<body style='text-align:center'> <body style='text-align:center'>
<h1>EAT THAT APPLE</h1> <h1>Halaman ke-1</h1>
<!-- <a href="index.php">Home</a> <a href="index.php">Home</a>
<a href="logout.php">Logout</a> --> <a href="logout.php">Logout</a>
<hr> <hr>
<h3>Selamat datang, <?php echo $_SESSION['users']['nama'] ?></h3> <h3>Selamat datang, <?php echo $_SESSION['users']['nama'] ?></h3>
<br> Halaman ini akan tampil setelah user login.
<!-- <h1>EAT THAT APPLE</h1> -->
<div class="container">
<a href="game.html">
<div id="button">Play Game</div>
</a>
<a href="http://localhost/uas_sem_1/leaderboard.php">
<div id="button">Leaderboard</div>
</a>
<a href="http://localhost/uas_sem_1/logout.php">
<div id="button">Logout</div>
</a>
</div>
</body> </body>
</html> </html>

View File

@ -1,78 +0,0 @@
<?php
session_start();
require_once "koneksi.php";
if (isset($_SESSION['username'])) {
$nama = $_SESSION['username'];
} else {
$nama = "";
}
$score = 0;
if (!empty($nama)) {
$getScore = "SELECT score FROM users WHERE username = '$nama'";
$resultMe = mysqli_query($koneksi, $getScore);
if ($resultMe && mysqli_num_rows($resultMe) > 0) {
$row = mysqli_fetch_assoc($resultMe);
$score = $row['score'];
}
}
$sql = "SELECT username, score FROM users ORDER BY score DESC LIMIT 10";
$result = mysqli_query($koneksi, $sql);
$leaderboard = [];
if($result) {
$leaderboard = mysqli_fetch_all($result, MYSQLI_ASSOC);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Leaderboard</title>
<link rel="stylesheet" href="">
<link rel="stylesheet" href="">
</head>
<body>
<table>
<thead>
<tr>
<th>#</th>
<th>Username</th>
<th>Score</th>
</tr>
</thead>
<tbody>
<?php
$peringkat = 1;
if (!empty($leaderboard)) {
foreach ($leaderboard as $pemain):
?>
<tr>
<td><?php echo $peringkat; ?></td>
<td><?php echo htmlspecialchars($pemain['username']); ?></td>
<td><?php echo $pemain['score']; ?> PTS</td>
</tr>
<?php
$peringkat++;
endforeach;
} else {
echo '<tr><td colspan="3" style="text-align: center;">Belum ada Pemain</td></tr>';
}
?>
</tbody>
</table>
</body>
</html>

View File

@ -1,7 +1,17 @@
<?php <?php
session_start(); session_start();
include "koneksi.php"; include "koneksi.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Halaman: Login</title>
</head>
<body>
<?php
if(isset($_POST['username'])) { if(isset($_POST['username'])) {
$username = $_POST['username']; $username = $_POST['username'];
$password = md5($_POST['password']); $password = md5($_POST['password']);
@ -11,32 +21,13 @@ if(isset($_POST['username'])) {
if(mysqli_num_rows($query) > 0) { if(mysqli_num_rows($query) > 0) {
$data = mysqli_fetch_array($query); $data = mysqli_fetch_array($query);
$_SESSION['users'] = $data; $_SESSION['users'] = $data;
$_SESSION['username'] = $data = ['username']; echo '<script>alert("Selamat datang, '.$data['nama'].'"); location.href="index.php";</script>';
echo '<script>location.href="index.php";</script>';
} else { } else {
echo '<script>alert("Username atau Password tidak sesuai");</script>'; echo '<script>alert("Username atau Password tidak sesuai");</script>';
} }
} }
?> ?>
<!DOCTYPE html>
<html lang="id">
<style>
body {
background-color: limegreen;
}
.login {
background-image: url('login/log.png');
}
</style>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Halaman: Login</title>
</head>
<body>
<div class="login">
<form action="" method="post"> <form action="" method="post">
<table align="center"> <table align="center">
<tr> <tr>
@ -46,12 +37,12 @@ if(isset($_POST['username'])) {
</tr> </tr>
<tr> <tr>
<td></td> <td>Username</td>
<td><input type="text" name="username" placeholder="Username" style="border: none"></td> <td><input type="text" name="username"></td>
</tr> </tr>
<tr> <tr>
<td></td> <td>Password</td>
<td><input type="password" name="password" placeholder="Password" style="border: none"></td> <td><input type="password" name="password"></td>
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
@ -62,8 +53,6 @@ if(isset($_POST['username'])) {
</tr> </tr>
</table> </table>
</form> </form>
</div>
</body> </body>
</html> </html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

View File

@ -1,69 +0,0 @@
-- phpMyAdmin SQL Dump
-- version 5.2.0
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: Dec 03, 2025 at 05:17 AM
-- Server version: 8.0.30
-- PHP Version: 8.1.10
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `game`
--
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id_user` int NOT NULL,
`nama` varchar(255) DEFAULT NULL,
`username` varchar(225) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`score` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id_user`, `nama`, `username`, `password`, `score`) VALUES
(1, 'Chris Daud Koroh', 'daudkoroh', '88d602f1ad6d62b9a11c688ab47fed22', 20),
(2, 'Zefanya Isaac', 'zefanya', 'de413c0365e3c88d8b3315f9d90b98ae', 68);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id_user`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id_user` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;