baru game

This commit is contained in:
JERRY F 2025-11-24 13:54:52 +07:00
parent 9a32dfa6a9
commit 0e7035e018
23 changed files with 163 additions and 4 deletions

BIN
gambar/ApelLayer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 B

BIN
gambar/BadanHorizontal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 B

BIN
gambar/BadanVertikal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

BIN
gambar/BelokAtasKanan.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 B

BIN
gambar/BelokAtasKiri.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 B

BIN
gambar/BelokBawahKanan.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 B

BIN
gambar/BelokBawahKiri.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 B

BIN
gambar/PialaLayer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 B

BIN
gambar/Tembok.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

60
gambar/daftar.php Normal file
View File

@ -0,0 +1,60 @@
<?php
session_start();
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: Daftar</title>
</head>
<body>
<?php
if(isset($_POST['username'])) {
$nama = $_POST['nama'];
$username = $_POST['username'];
$password = md5($_POST['password']);
$query = mysqli_query($koneksi, "INSERT INTO users(nama, username, password) value('$nama', '$username', '$password')");
if($query) {
echo '<script>alert("Selamat, anda berhasil mandaftarkan acc anda!")</script>';
} else {
echo '<script>alert("Maaf, pendaftaraan acc mu gagal")</script>';
}
}
?>
<form action="" method="post">
<table align="center">
<tr>
<td colspan="2" align="center">
<h3>Pendaftaran User</h3>
</td>
</tr>
<tr>
<td>Nama</td>
<td><input type="text" name="nama"></td>
</tr>
<tr>
<td>Username</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td></td>
<td>
<button type="submit">Daftarkan acc</button>
<a href="login.php">Login</a>
</td>
</tr>
</table>
</form>
</body>
</html>

26
gambar/index.php Normal file
View File

@ -0,0 +1,26 @@
<?php
// buat inisialisasi session
session_start();
// mengecek apakah ada session user yang aktif, jika tidak arahkan ke login.php
if(!isset($_SESSION['users'])) {
header('location:login.php'); // arahkan ke login.php
}
?>
<!DOCTYPE html>
<html lang="id">
<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>Halaman ke-1</h1>
<a href="index.php">Home</a>
<a href="logout.php">Logout</a>
<hr>
<h3>Selamat datang, <?php echo $_SESSION['users']['nama'] ?></h3>
Halaman ini akan tampil setelah user login.
</body>
</html>

4
gambar/koneksi.php Normal file
View File

@ -0,0 +1,4 @@
<?php
$koneksi = mysqli_connect("localhost", "root", "", "game") or die ('database tidak terhubung');
?>

58
gambar/login.php Normal file
View File

@ -0,0 +1,58 @@
<?php
session_start();
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'])) {
$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>';
}
}
?>
<form action="" method="post">
<table align="center">
<tr>
<td colspan="2" align="center">
<h3>Login User</h3>
</td>
</tr>
<tr>
<td>Username</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td></td>
<td>
<button type="submit">Masuk</button>
<a href="daftar.php">Daftar</a>
</td>
</tr>
</table>
</form>
</body>
</html>

9
gambar/logout.php Normal file
View File

@ -0,0 +1,9 @@
<?php
session_start();
session_destroy();
// header('location:login.php');
?>
<script type="text/javascript">
alert('Selamat anda berhasil Logout.');
location.href = "login.php"
</script>

View File

@ -105,13 +105,15 @@
//generate gambar external
var KepalaUlarImage = new Image();
KepalaUlarImage.src = "KepalaVertikalAtas.png"; // kepala ular
KepalaUlarImage.src = "image/KepalaVertikalAtas.png"; // kepala ular
var BadanUlarImage = new Image();
BadanUlarImage.src = "BadanVertikal.png"; // badan ular awal
BadanUlarImage.src = "image/BadanVertikal.png"; // badan ular awal
var ApelImage = new Image();
ApelImage.src = "ApelLayer.png"; // Apel
ApelImage.src = "image/ApelLayer.png"; // Apel
var TembokImage = new Image();
TembokImage.src = "Tembok.png"; // Tembok Batagor
TembokImage.src = "image/Tembok.png"; // Tembok Batagor
//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 };