Merge branch 'main' of https://git-eng.ukwms.ac.id/2526-web/kelompok03-codeplay-Angelica-Rinaldo-Farrel
This commit is contained in:
commit
9dae58f29d
BIN
Background.jpg
Normal file
BIN
Background.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 737 B |
58
Sudoku.php
58
Sudoku.php
@ -5,15 +5,6 @@ if (!isset($_SESSION['username'])) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Sudoku</title>
|
|
||||||
<style>
|
|
||||||
/*CSS kamu tetap sama*/
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Sudoku</title>
|
<title>Sudoku</title>
|
||||||
@ -32,17 +23,15 @@ if (!isset($_SESSION['username'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: 'Roboto', 'Segoe UI', sans-serif;
|
font-family: 'Roboto', 'Segoe UI', sans-serif;
|
||||||
background-color: var(--bg-color);
|
background: url("Background.jpg") no-repeat center center fixed;
|
||||||
color: var(--text-color);
|
background-size: cover;
|
||||||
margin: 0;
|
color: var(--text-color);
|
||||||
padding: 0;
|
margin: 0;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
display: flex;
|
overflow: hidden;
|
||||||
justify-content: center;
|
}
|
||||||
align-items: center;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.screen {
|
.screen {
|
||||||
display: none;
|
display: none;
|
||||||
@ -52,7 +41,7 @@ if (!isset($_SESSION['username'])) {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background-color: var(--bg-color);
|
background-color: transparent;
|
||||||
animation: fadeIn 0.3s ease-in-out;
|
animation: fadeIn 0.3s ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,12 +374,17 @@ if (!isset($_SESSION['username'])) {
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<div id="screen-menu" class="screen active">
|
||||||
|
<img src="Sudoku icon.jpg" alt="Logo" class="logo-img">
|
||||||
|
<div class="app-title">Sudoku</div>
|
||||||
|
|
||||||
|
<button class="btn-main" onclick="showLevelScreen()">Permainan Baru</button>
|
||||||
|
|
||||||
|
<button class="btn-main" onclick="window.location.href='leaderboard.php'">
|
||||||
|
Leaderboard
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="screen-menu" class="screen active">
|
|
||||||
<img src="Sudoku icon.jpg" alt="Logo" class="logo-img">
|
|
||||||
<div class="app-title">Sudoku</div>
|
|
||||||
<button class="btn-main" onclick="showLevelScreen()">Permainan Baru</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="screen-level" class="screen">
|
<div id="screen-level" class="screen">
|
||||||
<div class="level-title">Pilih Tingkat Kesulitan</div>
|
<div class="level-title">Pilih Tingkat Kesulitan</div>
|
||||||
@ -730,7 +724,8 @@ if (!isset($_SESSION['username'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stopTimer();
|
stopTimer();
|
||||||
|
saveScore();
|
||||||
|
|
||||||
let diffText = document.getElementById('difficulty-label').innerText;
|
let diffText = document.getElementById('difficulty-label').innerText;
|
||||||
let timeText = document.getElementById("timer-label").innerText;
|
let timeText = document.getElementById("timer-label").innerText;
|
||||||
|
|
||||||
@ -797,6 +792,15 @@ if (!isset($_SESSION['username'])) {
|
|||||||
if (b[i][j] != 0) { b[i][j] = 0; count--; }
|
if (b[i][j] != 0) { b[i][j] = 0; count--; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function saveScore() {
|
||||||
|
fetch("save_score.php", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||||
|
body: `difficulty=${currentDifficulty}&time=${secondsElapsed}`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
74
leaderboard.php
Normal file
74
leaderboard.php
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'db.php';
|
||||||
|
|
||||||
|
// TES KONEKSI
|
||||||
|
if (!$conn) {
|
||||||
|
die("DB connection failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "
|
||||||
|
SELECT username, difficulty, time_seconds
|
||||||
|
FROM leaderboard_sudoku
|
||||||
|
ORDER BY difficulty, time_seconds ASC
|
||||||
|
LIMIT 10
|
||||||
|
";
|
||||||
|
|
||||||
|
$result = $conn->query($sql);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.leaderboard {
|
||||||
|
background: #1e1e1e;
|
||||||
|
color: white;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 10px;
|
||||||
|
width: 350px;
|
||||||
|
}
|
||||||
|
.leaderboard table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
.leaderboard th, .leaderboard td {
|
||||||
|
padding: 8px;
|
||||||
|
border-bottom: 1px solid #444;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.leaderboard th {
|
||||||
|
background: #333;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="leaderboard">
|
||||||
|
<h3>🏆 Leaderboard</h3>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>User</th>
|
||||||
|
<th>Level</th>
|
||||||
|
<th>Time</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<?php if ($result && $result->num_rows > 0): ?>
|
||||||
|
<?php while ($row = $result->fetch_assoc()): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?= htmlspecialchars($row['username']) ?></td>
|
||||||
|
<td><?= strtoupper($row['difficulty']) ?></td>
|
||||||
|
<td>
|
||||||
|
<?= sprintf(
|
||||||
|
"%02d:%02d",
|
||||||
|
floor($row['time_seconds'] / 60),
|
||||||
|
$row['time_seconds'] % 60
|
||||||
|
) ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endwhile; ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">Belum ada data</td>
|
||||||
|
</tr>
|
||||||
|
<?php endif; ?>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php $conn->close(); ?>
|
||||||
|
|
||||||
13
save_scoee.php
Normal file
13
save_scoee.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require "koneksi.php"; // sesuaikan dengan file koneksi DB kamu
|
||||||
|
|
||||||
|
if (!isset($_SESSION['username'])) exit;
|
||||||
|
|
||||||
|
$username = $_SESSION['username'];
|
||||||
|
$difficulty = $_POST['difficulty'];
|
||||||
|
$time = intval($_POST['time']);
|
||||||
|
|
||||||
|
$stmt = $conn->prepare("INSERT INTO leaderboard_sudoku (username, difficulty, time_seconds) VALUES (?, ?, ?)");
|
||||||
|
$stmt->bind_param("ssi", $username, $difficulty, $time);
|
||||||
|
$stmt->execute();
|
||||||
@ -63,6 +63,15 @@ ALTER TABLE `users`
|
|||||||
--
|
--
|
||||||
ALTER TABLE `users`
|
ALTER TABLE `users`
|
||||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
|
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
|
||||||
|
|
||||||
|
CREATE TABLE leaderboard_sudoku (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
username VARCHAR(50),
|
||||||
|
difficulty VARCHAR(10),
|
||||||
|
time_seconds INT,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user