menambahkan fitur
This commit is contained in:
parent
40d5c3bbc7
commit
8d8cdc5974
353
Sudoku.html
353
Sudoku.html
@ -57,16 +57,37 @@
|
|||||||
animation: fadeIn 0.3s ease-in-out;
|
animation: fadeIn 0.3s ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
.screen.active { display: flex; }
|
.screen.active {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes fadeIn {
|
@keyframes fadeIn {
|
||||||
from { opacity: 0; transform: translateY(10px); }
|
from {
|
||||||
to { opacity: 1; transform: translateY(0); }
|
opacity: 0;
|
||||||
|
transform: translateY(10px);
|
||||||
|
}
|
||||||
|
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*MENU & LEVEL STYLES*/
|
/*MENU & LEVEL STYLES*/
|
||||||
.logo-img { width: 120px; height: 120px; border-radius: 20px; margin-bottom: 15px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
|
.logo-img {
|
||||||
.app-title { font-size: 32px; font-weight: bold; color: darkslategray; margin-bottom: 40px; }
|
width: 120px;
|
||||||
|
height: 120px;
|
||||||
|
border-radius: 20px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-title {
|
||||||
|
font-size: 32px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: darkslategray;
|
||||||
|
margin-bottom: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
.btn-main {
|
.btn-main {
|
||||||
background-color: var(--primary-color);
|
background-color: var(--primary-color);
|
||||||
@ -83,58 +104,257 @@
|
|||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.btn-main:hover { transform: scale(1.05); }
|
|
||||||
|
|
||||||
.level-title { font-size: 24px; margin-bottom: 30px; color: black; }
|
.btn-main:hover {
|
||||||
.btn-level { width: 250px; padding: 15px; margin-bottom: 15px; border: none; border-radius: 15px; font-size: 18px; font-weight: bold; color: white; cursor: pointer; transition: 0.2s; box-shadow: 0 4px 6px lightgray; }
|
transform: scale(1.05);
|
||||||
.btn-level:hover { transform: translateY(-3px); }
|
}
|
||||||
|
|
||||||
|
.level-title {
|
||||||
|
font-size: 24px;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-level {
|
||||||
|
width: 250px;
|
||||||
|
padding: 15px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 15px;
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: white;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: 0.2s;
|
||||||
|
box-shadow: 0 4px 6px lightgray;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-level:hover {
|
||||||
|
transform: translateY(-3px);
|
||||||
|
}
|
||||||
|
|
||||||
/*Warna Tombol Level menggunakan HURUF*/
|
/*Warna Tombol Level menggunakan HURUF*/
|
||||||
.lvl-easy { background-color: limegreen; }
|
.lvl-easy {
|
||||||
.lvl-medium { background-color: dodgerblue; }
|
background-color: limegreen;
|
||||||
.lvl-hard { background-color: red; }
|
}
|
||||||
|
|
||||||
.btn-cancel { margin-top: 20px; background: none; border: 2px solid gray; color: gray; padding: 10px 40px; border-radius: 20px; cursor: pointer; font-weight: bold; }
|
.lvl-medium {
|
||||||
|
background-color: dodgerblue;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lvl-hard {
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-cancel {
|
||||||
|
margin-top: 20px;
|
||||||
|
background: none;
|
||||||
|
border: 2px solid gray;
|
||||||
|
color: gray;
|
||||||
|
padding: 10px 40px;
|
||||||
|
border-radius: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
/*GAME STYLES*/
|
/*GAME STYLES*/
|
||||||
.game-header { width: 100%; max-width: 380px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; padding: 0 10px; box-sizing: border-box; }
|
.game-header {
|
||||||
.btn-back-icon { background: none; border: none; font-size: 28px; cursor: pointer; color: dimgray; padding: 0; }
|
width: 100%;
|
||||||
#difficulty-label { font-size: 18px; font-weight: bold; color: var(--primary-color); text-transform: uppercase; letter-spacing: 1px; }
|
max-width: 380px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
padding: 0 10px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
#board-container { box-shadow: 0 4px 15px lightgray; border-radius: 8px; overflow: hidden; margin-bottom: 20px; }
|
.btn-back-icon {
|
||||||
#board { width: 350px; height: 350px; background-color: var(--board-bg); border: 2px solid var(--thick-border); display: flex; flex-wrap: wrap; }
|
background: none;
|
||||||
|
border: none;
|
||||||
|
font-size: 28px;
|
||||||
|
cursor: pointer;
|
||||||
|
color: dimgray;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.tile { width: 38.4px; height: 38.4px; border: 1px solid var(--border-color); font-size: 20px; font-weight: 500; display: flex; justify-content: center; align-items: center; cursor: pointer; user-select: none; box-sizing: border-box; }
|
#difficulty-label {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: var(--primary-color);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#board-container {
|
||||||
|
box-shadow: 0 4px 15px lightgray;
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#board {
|
||||||
|
width: 350px;
|
||||||
|
height: 350px;
|
||||||
|
background-color: var(--board-bg);
|
||||||
|
border: 2px solid var(--thick-border);
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tile {
|
||||||
|
width: 38.4px;
|
||||||
|
height: 38.4px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 500;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
/*Garis Tebal menggunakan warna darkslategray*/
|
/*Garis Tebal menggunakan warna darkslategray*/
|
||||||
.tile-border-right { border-right: 2px solid var(--thick-border); }
|
.tile-border-right {
|
||||||
.tile-border-bottom { border-bottom: 2px solid var(--thick-border); }
|
border-right: 2px solid var(--thick-border);
|
||||||
|
}
|
||||||
|
|
||||||
.tile-start { color: black; background-color: whitesmoke; cursor: default; font-weight: bold; }
|
.tile-border-bottom {
|
||||||
.tile-user { color: var(--primary-color); }
|
border-bottom: 2px solid var(--thick-border);
|
||||||
.tile-highlight-same { background-color: var(--same-highlight) !important; }
|
}
|
||||||
.tile-selected { border: 3px solid var(--selected-border) !important; z-index: 10; }
|
|
||||||
.tile-error { background-color: var(--error-bg) !important; color: var(--error-text) !important; }
|
.tile-start {
|
||||||
|
color: black;
|
||||||
|
background-color: whitesmoke;
|
||||||
|
cursor: default;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tile-user {
|
||||||
|
color: var(--primary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tile-highlight-same {
|
||||||
|
background-color: var(--same-highlight) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tile-selected {
|
||||||
|
border: 3px solid var(--selected-border) !important;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tile-error {
|
||||||
|
background-color: var(--error-bg) !important;
|
||||||
|
color: var(--error-text) !important;
|
||||||
|
}
|
||||||
|
|
||||||
/*Numpad & Tools*/
|
/*Numpad & Tools*/
|
||||||
#numpad-row { display: flex; flex-wrap: nowrap; justify-content: space-between; width: 100%; max-width: 350px; gap: 5px; }
|
#numpad-row {
|
||||||
.number { flex: 1; height: 55px; border-radius: 8px; display: flex; flex-direction: column; justify-content: center; align-items: center; cursor: pointer; background-color: white; color: var(--primary-color); box-shadow: 0 2px 5px lightgray; transition: transform 0.1s; }
|
display: flex;
|
||||||
.number:active { transform: scale(0.95); background-color: aliceblue; }
|
flex-wrap: nowrap;
|
||||||
.main-num { font-size: 22px; font-weight: bold; }
|
justify-content: space-between;
|
||||||
.count-num { font-size: 10px; color: gray; margin-top: 2px; }
|
width: 100%;
|
||||||
.hidden-key { opacity: 0; pointer-events: none; }
|
max-width: 350px;
|
||||||
|
gap: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
#tools-row { margin-top: 15px; width: 100%; max-width: 350px; display: flex; justify-content: center; gap: 15px; }
|
.number {
|
||||||
.tool-btn { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border-radius: 30px; font-weight: bold; font-size: 14px; cursor: pointer; border: 1px solid lightgray; background-color: white; box-shadow: 0 2px 4px lightgray; transition: 0.2s; flex: 1; }
|
flex: 1;
|
||||||
.tool-btn:active { transform: scale(0.95); }
|
height: 55px;
|
||||||
|
border-radius: 8px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
background-color: white;
|
||||||
|
color: var(--primary-color);
|
||||||
|
box-shadow: 0 2px 5px lightgray;
|
||||||
|
transition: transform 0.1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.number:active {
|
||||||
|
transform: scale(0.95);
|
||||||
|
background-color: aliceblue;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-num {
|
||||||
|
font-size: 22px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.count-num {
|
||||||
|
font-size: 10px;
|
||||||
|
color: gray;
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hidden-key {
|
||||||
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tools-row {
|
||||||
|
margin-top: 15px;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 350px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tool-btn {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 12px 20px;
|
||||||
|
border-radius: 30px;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 14px;
|
||||||
|
cursor: pointer;
|
||||||
|
border: 1px solid lightgray;
|
||||||
|
background-color: white;
|
||||||
|
box-shadow: 0 2px 4px lightgray;
|
||||||
|
transition: 0.2s;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tool-btn:active {
|
||||||
|
transform: scale(0.95);
|
||||||
|
}
|
||||||
|
|
||||||
/*Tombol Hapus*/
|
/*Tombol Hapus*/
|
||||||
.btn-delete { color: red; border-color: pink; }
|
.btn-delete {
|
||||||
|
color: red;
|
||||||
|
border-color: pink;
|
||||||
|
}
|
||||||
|
|
||||||
/*Tombol Bantuan*/
|
/*Tombol Bantuan*/
|
||||||
.btn-hint { color: darkorange; border-color: orange; }
|
.btn-hint {
|
||||||
|
color: darkorange;
|
||||||
|
border-color: orange;
|
||||||
|
}
|
||||||
|
|
||||||
#game-msg { height: 25px; color: green; font-weight: bold; margin-bottom: 10px; font-size: 16px; text-align: center;}
|
/* Style untuk tombol disabled (ketika bantuan habis) */
|
||||||
|
.btn-disabled {
|
||||||
|
background-color: lightgray !important;
|
||||||
|
color: gray !important;
|
||||||
|
border-color: darkgray !important;
|
||||||
|
cursor: not-allowed;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#game-msg {
|
||||||
|
height: 25px;
|
||||||
|
color: green;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
font-size: 16px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
/*FITUR MENANG*/
|
/*FITUR MENANG*/
|
||||||
#win-controls {
|
#win-controls {
|
||||||
@ -156,15 +376,25 @@
|
|||||||
box-shadow: 0 4px 10px lightgray;
|
box-shadow: 0 4px 10px lightgray;
|
||||||
animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
||||||
}
|
}
|
||||||
.btn-play-again:hover { background-color: deepskyblue; }
|
|
||||||
|
|
||||||
@keyframes popIn {
|
.btn-play-again:hover {
|
||||||
from { transform: scale(0); opacity: 0; }
|
background-color: deepskyblue;
|
||||||
to { transform: scale(1); opacity: 1; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes popIn {
|
||||||
|
from {
|
||||||
|
transform: scale(0);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
to {
|
||||||
|
transform: scale(1);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id="screen-menu" class="screen active">
|
<div id="screen-menu" class="screen active">
|
||||||
@ -175,9 +405,12 @@
|
|||||||
|
|
||||||
<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
|
||||||
<button class="btn-level lvl-medium" onclick="startLevel('medium')">MEDIUM<div style="font-size: 12px; font-weight: normal; margin-top: 5px;">Tantangan Standar</div></button>
|
style="font-size: 12px; font-weight: normal; margin-top: 5px;">Santai & Cepat</div></button>
|
||||||
<button class="btn-level lvl-hard" onclick="startLevel('hard')">SULIT<div style="font-size: 12px; font-weight: normal; margin-top: 5px;">Butuh Logika Ekstra</div></button>
|
<button class="btn-level lvl-medium" onclick="startLevel('medium')">MEDIUM<div
|
||||||
|
style="font-size: 12px; font-weight: normal; margin-top: 5px;">Tantangan Standar</div></button>
|
||||||
|
<button class="btn-level lvl-hard" onclick="startLevel('hard')">SULIT<div
|
||||||
|
style="font-size: 12px; font-weight: normal; margin-top: 5px;">Butuh Logika Ekstra</div></button>
|
||||||
<button class="btn-cancel" onclick="showMenuScreen()">Batal</button>
|
<button class="btn-cancel" onclick="showMenuScreen()">Batal</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -208,7 +441,7 @@
|
|||||||
|
|
||||||
<div id="tools-row">
|
<div id="tools-row">
|
||||||
<div class="tool-btn btn-delete" onclick="deleteNumber()"><span>🗑️</span> HAPUS</div>
|
<div class="tool-btn btn-delete" onclick="deleteNumber()"><span>🗑️</span> HAPUS</div>
|
||||||
<div class="tool-btn btn-hint" onclick="getHint()"><span>💡</span> BANTUAN</div>
|
<div id="btn-hint" class="tool-btn btn-hint" onclick="getHint()"><span>💡</span> BANTUAN (3)</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="win-controls">
|
<div id="win-controls">
|
||||||
@ -221,6 +454,7 @@
|
|||||||
var tileSelected = null;
|
var tileSelected = null;
|
||||||
var board = [];
|
var board = [];
|
||||||
var solution = [];
|
var solution = [];
|
||||||
|
var hintsRemaining = 3; // Variabel untuk menyimpan sisa bantuan
|
||||||
|
|
||||||
function switchScreen(screenId) {
|
function switchScreen(screenId) {
|
||||||
document.querySelectorAll('.screen').forEach(s => s.classList.remove('active'));
|
document.querySelectorAll('.screen').forEach(s => s.classList.remove('active'));
|
||||||
@ -244,6 +478,10 @@
|
|||||||
board = JSON.parse(JSON.stringify(solution));
|
board = JSON.parse(JSON.stringify(solution));
|
||||||
removeNumbers(board, holesCount);
|
removeNumbers(board, holesCount);
|
||||||
|
|
||||||
|
// Reset sisa bantuan ke 3 setiap game baru
|
||||||
|
hintsRemaining = 3;
|
||||||
|
updateHintButton();
|
||||||
|
|
||||||
document.getElementById("tools-row").style.display = "flex";
|
document.getElementById("tools-row").style.display = "flex";
|
||||||
document.getElementById("numpad-row").style.display = "flex";
|
document.getElementById("numpad-row").style.display = "flex";
|
||||||
document.getElementById("win-controls").style.display = "none";
|
document.getElementById("win-controls").style.display = "none";
|
||||||
@ -281,6 +519,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fungsi untuk update tampilan tombol bantuan
|
||||||
|
function updateHintButton() {
|
||||||
|
let btnHint = document.getElementById("btn-hint");
|
||||||
|
btnHint.innerHTML = `<span>💡</span> BANTUAN (${hintsRemaining})`;
|
||||||
|
|
||||||
|
// Jika habis, ganti tampilan jadi disabled
|
||||||
|
if(hintsRemaining <= 0) {
|
||||||
|
btnHint.classList.add("btn-disabled");
|
||||||
|
} else {
|
||||||
|
btnHint.classList.remove("btn-disabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateRemainingCounts() {
|
function updateRemainingCounts() {
|
||||||
let counts = Array(10).fill(0);
|
let counts = Array(10).fill(0);
|
||||||
for (let r = 0; r < 9; r++) {
|
for (let r = 0; r < 9; r++) {
|
||||||
@ -357,15 +608,25 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getHint() {
|
function getHint() {
|
||||||
|
// Cek apakah sisa bantuan masih ada
|
||||||
|
if(hintsRemaining <= 0) return;
|
||||||
|
|
||||||
if (!tileSelected) return;
|
if (!tileSelected) return;
|
||||||
if (tileSelected.classList.contains("tile-start")) return;
|
if (tileSelected.classList.contains("tile-start")) return;
|
||||||
|
|
||||||
let coords = tileSelected.id.split("-");
|
let coords = tileSelected.id.split("-");
|
||||||
let r = parseInt(coords[0]);
|
let r = parseInt(coords[0]);
|
||||||
let c = parseInt(coords[1]);
|
let c = parseInt(coords[1]);
|
||||||
let correctNum = solution[r][c];
|
let correctNum = solution[r][c];
|
||||||
|
|
||||||
board[r][c] = correctNum;
|
board[r][c] = correctNum;
|
||||||
tileSelected.innerText = correctNum;
|
tileSelected.innerText = correctNum;
|
||||||
tileSelected.classList.remove("tile-error");
|
tileSelected.classList.remove("tile-error");
|
||||||
|
|
||||||
|
// Kurangi sisa bantuan
|
||||||
|
hintsRemaining--;
|
||||||
|
updateHintButton(); // Update tampilan tombol
|
||||||
|
|
||||||
highlightSameNumbers(correctNum.toString());
|
highlightSameNumbers(correctNum.toString());
|
||||||
updateRemainingCounts();
|
updateRemainingCounts();
|
||||||
checkIfWin();
|
checkIfWin();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user