Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 06ffdaaf7d | |||
| 1191fdfca7 | |||
| 8d57266b16 |
@ -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;
|
||||||
@ -125,7 +168,7 @@
|
|||||||
font-family: "Pixelify Sans", sans-serif;
|
font-family: "Pixelify Sans", sans-serif;
|
||||||
font-optical-sizing: auto;
|
font-optical-sizing: auto;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
#mode-normal {
|
#mode-normal {
|
||||||
background-color: #73e4c2;
|
background-color: #73e4c2;
|
||||||
|
|||||||
@ -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>
|
||||||
@ -56,4 +53,4 @@
|
|||||||
<!-- akhir html body -->
|
<!-- akhir html body -->
|
||||||
<script src="GameLogic.js"></script>
|
<script src="GameLogic.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB |
85
home.html
85
home.html
@ -1,48 +1,47 @@
|
|||||||
<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">
|
||||||
<a href="game.html">
|
<div id="button">Play Game</div>
|
||||||
<div id="button">Play Game</div>
|
<div id="button">Leaderboard</div>
|
||||||
</a>
|
<div id="button">Quit</div>
|
||||||
|
</div>
|
||||||
<div id="button">Leaderboard</div>
|
</body>
|
||||||
<div id="button">Logout</div>
|
|
||||||
</div>
|
|
||||||
<input type="text">
|
|
||||||
</body>
|
|
||||||
|
|
||||||
<script></script>
|
<script>
|
||||||
</html>
|
|
||||||
|
</script>
|
||||||
|
</html>
|
||||||
78
index.php
78
index.php
@ -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>
|
<head>
|
||||||
body {
|
<meta charset="UTF-8">
|
||||||
background-image: url();
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
}
|
<title>Halaman ke-1</title>
|
||||||
h1 {
|
</head>
|
||||||
text-align: center;
|
<body style='text-align:center'>
|
||||||
margin-top: 10%;
|
<h1>Halaman ke-1</h1>
|
||||||
font-size: 85px;
|
<a href="index.php">Home</a>
|
||||||
}
|
<a href="logout.php">Logout</a>
|
||||||
|
<hr>
|
||||||
|
|
||||||
.container {
|
<h3>Selamat datang, <?php echo $_SESSION['users']['nama'] ?></h3>
|
||||||
padding: 5px;
|
Halaman ini akan tampil setelah user login.
|
||||||
border: 2px solid; /* Nanti dihapus */
|
</body>
|
||||||
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>
|
||||||
@ -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>
|
|
||||||
105
login.php
105
login.php
@ -1,69 +1,58 @@
|
|||||||
|
|
||||||
<?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="id">
|
<html lang="en">
|
||||||
<style>
|
<head>
|
||||||
body {
|
<meta charset="UTF-8">
|
||||||
background-color: limegreen;
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<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>
|
|
||||||
|
|
||||||
<div class="login">
|
<form action="" method="post">
|
||||||
<form action="" method="post">
|
<table align="center">
|
||||||
<table align="center">
|
<tr>
|
||||||
<tr>
|
<td colspan="2" align="center">
|
||||||
<td colspan="2" align="center">
|
<h3>Login User</h3>
|
||||||
<h3>Login User</h3>
|
</td>
|
||||||
</td>
|
</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>
|
||||||
<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
BIN
login/log.png
Binary file not shown.
|
Before Width: | Height: | Size: 13 KiB |
BIN
login/login.png
BIN
login/login.png
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 |
69
users.sql
69
users.sql
@ -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 */;
|
|
||||||
Loading…
x
Reference in New Issue
Block a user