Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d0459d99f8 | |||
| 77de57304e | |||
| df3f478734 | |||
| 77a7a4a342 | |||
| e30ef4a019 | |||
| c2a00e3238 |
@ -26,7 +26,10 @@
|
|||||||
<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>
|
||||||
<button id="keluar" class="modegame">Keluar?</button>
|
<a href="http://localhost/uas_sem_1/index.php">
|
||||||
|
<button id="keluar" class="">Keluar?</button>
|
||||||
|
</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="gameover" class="gameover"></div>
|
<div id="gameover" class="gameover"></div>
|
||||||
|
|||||||
BIN
gameOver/gameOver.png
Normal file
BIN
gameOver/gameOver.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
85
home.html
85
home.html
@ -1,47 +1,48 @@
|
|||||||
<html>
|
<html>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
background-image: url();
|
background-image: url();
|
||||||
}
|
}
|
||||||
h1 {
|
h1 {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: 10%;
|
margin-top: 10%;
|
||||||
font-size: 85px;
|
font-size: 85px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
border: 2px solid; /* Nanti dihapus */
|
border: 2px solid; /* Nanti dihapus */
|
||||||
border-radius: 7pt; /* Nanti dihapus */
|
border-radius: 7pt; /* Nanti dihapus */
|
||||||
width: 70%;
|
width: 70%;
|
||||||
justify-self: center;
|
justify-self: center;
|
||||||
background-image: url();
|
background-image: url();
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#button {
|
#button {
|
||||||
font-size: 35px;
|
font-size: 35px;
|
||||||
margin-top: 5%;
|
margin-top: 5%;
|
||||||
width: 50%;
|
width: 50%;
|
||||||
margin-bottom: 5%;
|
margin-bottom: 5%;
|
||||||
border: 1px solid;
|
border: 1px solid;
|
||||||
border-radius: 3pt;
|
border-radius: 3pt;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
justify-self: center;
|
justify-self: center;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>EAT THAT APPLE</h1>
|
<h1>EAT THAT APPLE</h1>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div id="button">Play Game</div>
|
<a href="game.html">
|
||||||
<div id="button">Leaderboard</div>
|
<div id="button">Play Game</div>
|
||||||
<div id="button">Quit</div>
|
</a>
|
||||||
</div>
|
|
||||||
</body>
|
<div id="button">Leaderboard</div>
|
||||||
|
<div id="button">Logout</div>
|
||||||
|
</div>
|
||||||
|
<input type="text">
|
||||||
|
</body>
|
||||||
|
|
||||||
<script>
|
<script></script>
|
||||||
|
</html>
|
||||||
</script>
|
|
||||||
</html>
|
|
||||||
|
|||||||
78
index.php
78
index.php
@ -1,26 +1,72 @@
|
|||||||
<?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'); // arahkan ke login.php
|
header('location:login.php');
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="id">
|
<html lang="id">
|
||||||
<head>
|
<style>
|
||||||
<meta charset="UTF-8">
|
body {
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
background-image: url();
|
||||||
<title>Halaman ke-1</title>
|
}
|
||||||
</head>
|
h1 {
|
||||||
<body style='text-align:center'>
|
text-align: center;
|
||||||
<h1>Halaman ke-1</h1>
|
margin-top: 10%;
|
||||||
<a href="index.php">Home</a>
|
font-size: 85px;
|
||||||
<a href="logout.php">Logout</a>
|
}
|
||||||
<hr>
|
|
||||||
|
|
||||||
<h3>Selamat datang, <?php echo $_SESSION['users']['nama'] ?></h3>
|
.container {
|
||||||
Halaman ini akan tampil setelah user login.
|
padding: 5px;
|
||||||
</body>
|
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>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Halaman ke-1</title>
|
||||||
|
</head>
|
||||||
|
<body style='text-align:center'>
|
||||||
|
<h1>EAT THAT APPLE</h1>
|
||||||
|
<!-- <a href="index.php">Home</a>
|
||||||
|
<a href="logout.php">Logout</a> -->
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<h3>Selamat datang, <?php echo $_SESSION['users']['nama'] ?></h3>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<!-- <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>
|
||||||
</html>
|
</html>
|
||||||
78
leaderboard.php
Normal file
78
leaderboard.php
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<?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>
|
||||||
105
login.php
105
login.php
@ -1,58 +1,69 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
include "koneksi.php";
|
include "koneksi.php";
|
||||||
|
if(isset($_POST['username'])) {
|
||||||
|
$username = $_POST['username'];
|
||||||
|
$password = md5($_POST['password']);
|
||||||
|
|
||||||
|
$query = mysqli_query($koneksi, "SELECT * FROM users where username='$username' and password='$password'");
|
||||||
|
|
||||||
|
if(mysqli_num_rows($query) > 0) {
|
||||||
|
$data = mysqli_fetch_array($query);
|
||||||
|
$_SESSION['users'] = $data;
|
||||||
|
$_SESSION['username'] = $data = ['username'];
|
||||||
|
echo '<script>location.href="index.php";</script>';
|
||||||
|
} else {
|
||||||
|
echo '<script>alert("Username atau Password tidak sesuai");</script>';
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="id">
|
||||||
<head>
|
<style>
|
||||||
<meta charset="UTF-8">
|
body {
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
background-color: limegreen;
|
||||||
<title>Halaman: Login</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<?php
|
|
||||||
if(isset($_POST['username'])) {
|
|
||||||
$username = $_POST['username'];
|
|
||||||
$password = md5($_POST['password']);
|
|
||||||
|
|
||||||
$query = mysqli_query($koneksi, "SELECT * FROM users where username='$username' and password='$password'");
|
|
||||||
|
|
||||||
if(mysqli_num_rows($query) > 0) {
|
|
||||||
$data = mysqli_fetch_array($query);
|
|
||||||
$_SESSION['users'] = $data;
|
|
||||||
echo '<script>alert("Selamat datang, '.$data['nama'].'"); location.href="index.php";</script>';
|
|
||||||
} else {
|
|
||||||
echo '<script>alert("Username atau Password tidak sesuai");</script>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
?>
|
.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>
|
||||||
|
|
||||||
<form action="" method="post">
|
<div class="login">
|
||||||
<table align="center">
|
<form action="" method="post">
|
||||||
<tr>
|
<table align="center">
|
||||||
<td colspan="2" align="center">
|
<tr>
|
||||||
<h3>Login User</h3>
|
<td colspan="2" align="center">
|
||||||
</td>
|
<h3>Login User</h3>
|
||||||
</tr>
|
</td>
|
||||||
<tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
|
||||||
<td>Username</td>
|
<td></td>
|
||||||
<td><input type="text" name="username"></td>
|
<td><input type="text" name="username" placeholder="Username" style="border: none"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Password</td>
|
<td></td>
|
||||||
<td><input type="password" name="password"></td>
|
<td><input type="password" name="password" placeholder="Password" style="border: none"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>
|
<td>
|
||||||
<button type="submit">Masuk</button>
|
<button type="submit">Masuk</button>
|
||||||
<a href="daftar.php">Daftar</a>
|
<a href="daftar.php">Daftar</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
BIN
login/log.png
Normal file
BIN
login/log.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
BIN
login/login.png
Normal file
BIN
login/login.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
BIN
mapGame/mapgame .png
Normal file
BIN
mapGame/mapgame .png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
BIN
succes/loginSuccess.png
Normal file
BIN
succes/loginSuccess.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
69
users.sql
Normal file
69
users.sql
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
-- 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 */;
|
||||||
Loading…
x
Reference in New Issue
Block a user