Compare commits
No commits in common. "6c0d77d4965c7102b4432c2a807ee6950d1808c4" and "cb96761ae800510f9d394439962537f8eb2c96ca" have entirely different histories.
6c0d77d496
...
cb96761ae8
BIN
Background.jpg
BIN
Background.jpg
Binary file not shown.
|
Before Width: | Height: | Size: 737 B |
36
Sudoku.php
36
Sudoku.php
@ -5,6 +5,15 @@ 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>
|
||||||
@ -24,15 +33,17 @@ if (!isset($_SESSION['username'])) {
|
|||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: 'Roboto', 'Segoe UI', sans-serif;
|
font-family: 'Roboto', 'Segoe UI', sans-serif;
|
||||||
background: url("Background.jpg") no-repeat center center fixed;
|
background-color: var(--bg-color);
|
||||||
background-size: cover;
|
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.screen {
|
.screen {
|
||||||
display: none;
|
display: none;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -41,7 +52,7 @@ if (!isset($_SESSION['username'])) {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background-color: transparent;
|
background-color: var(--bg-color);
|
||||||
animation: fadeIn 0.3s ease-in-out;
|
animation: fadeIn 0.3s ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,18 +385,13 @@ if (!isset($_SESSION['username'])) {
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id="screen-menu" class="screen active">
|
<div id="screen-menu" class="screen active">
|
||||||
<img src="Sudoku icon.jpg" alt="Logo" class="logo-img">
|
<img src="Sudoku icon.jpg" alt="Logo" class="logo-img">
|
||||||
<div class="app-title">Sudoku</div>
|
<div class="app-title">Sudoku</div>
|
||||||
|
|
||||||
<button class="btn-main" onclick="showLevelScreen()">Permainan Baru</button>
|
<button class="btn-main" onclick="showLevelScreen()">Permainan Baru</button>
|
||||||
|
|
||||||
<button class="btn-main" onclick="window.location.href='leaderboard.php'">
|
|
||||||
Leaderboard
|
|
||||||
</button>
|
|
||||||
</div>
|
</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>
|
||||||
<button class="btn-level lvl-easy" onclick="startLevel('easy')">MUDAH<div style="font-size: 12px; font-weight: normal; margin-top: 5px;">Santai & Cepat</div></button>
|
<button class="btn-level lvl-easy" onclick="startLevel('easy')">MUDAH<div style="font-size: 12px; font-weight: normal; margin-top: 5px;">Santai & Cepat</div></button>
|
||||||
@ -724,7 +730,6 @@ 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;
|
||||||
@ -792,15 +797,6 @@ 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>
|
||||||
@ -1,74 +0,0 @@
|
|||||||
<?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(); ?>
|
|
||||||
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
<?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,15 +63,6 @@ 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