little changes
This commit is contained in:
parent
55da5e6b28
commit
2cd305fee0
@ -41,13 +41,9 @@ div {
|
|||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-content: center;
|
align-content: center;
|
||||||
margin: 4vmin;
|
margin: 2vmin auto;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
column-gap: 1vmin;
|
column-gap: 2vmin;
|
||||||
}
|
|
||||||
|
|
||||||
div * {
|
|
||||||
margin: auto 2vmin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldset {
|
fieldset {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
.locked-mino {
|
.locked-mino {
|
||||||
background: rgba(242, 255, 255, 0.5);
|
background: rgba(242, 255, 255, 0.5);
|
||||||
|
border-color: rgba(242, 255, 255, 0.7);
|
||||||
}
|
}
|
||||||
|
|
||||||
.cleared-line {
|
.cleared-line {
|
||||||
|
@ -95,11 +95,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<button type="button" onclick="hideSettings()">RETOUR</button>
|
<button type="button" onclick="hideSettings()">RETOUR</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="start">
|
<fieldset id="start">
|
||||||
|
<legend>Nouvelle partie</legend>
|
||||||
<label for="startLevel">Niveau</label>
|
<label for="startLevel">Niveau</label>
|
||||||
<input type="number" id="startLevel" min="1" max="15" step="1">
|
<input type="number" id="startLevel" min="1" max="15" step="1">
|
||||||
<button id="startButton" type="button" onclick="start()" disabled>JOUER</button>
|
<button id="startButton" type="button" onclick="newGame()" disabled>JOUER</button>
|
||||||
</div>
|
</fieldset>
|
||||||
<div>
|
<div>
|
||||||
<button id="settingsButton" type="button" onclick="showSettings()" disabled>OPTIONS</button>
|
<button id="settingsButton" type="button" onclick="showSettings()" disabled>OPTIONS</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -206,7 +206,6 @@ class MinoesTable {
|
|||||||
constructor(id, rows, columns) {
|
constructor(id, rows, columns) {
|
||||||
this.rows = rows
|
this.rows = rows
|
||||||
this.columns = columns
|
this.columns = columns
|
||||||
this.piece = null
|
|
||||||
this.table = document.getElementById(id)
|
this.table = document.getElementById(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,6 +232,10 @@ class HoldQueue extends MinoesTable {
|
|||||||
super("hold", HOLD_ROWS, HOLD_COLUMNS)
|
super("hold", HOLD_ROWS, HOLD_COLUMNS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newGame() {
|
||||||
|
this.piece = null
|
||||||
|
}
|
||||||
|
|
||||||
draw() {
|
draw() {
|
||||||
this.clearTable()
|
this.clearTable()
|
||||||
if (this.piece && state != STATE.PAUSED)
|
if (this.piece && state != STATE.PAUSED)
|
||||||
@ -244,6 +247,9 @@ class HoldQueue extends MinoesTable {
|
|||||||
class Matrix extends MinoesTable {
|
class Matrix extends MinoesTable {
|
||||||
constructor() {
|
constructor() {
|
||||||
super("matrix", MATRIX_ROWS, MATRIX_COLUMNS)
|
super("matrix", MATRIX_ROWS, MATRIX_COLUMNS)
|
||||||
|
}
|
||||||
|
|
||||||
|
newGame() {
|
||||||
this.lockedMinoes = Array.from(Array(MATRIX_ROWS+3), row => Array(MATRIX_COLUMNS))
|
this.lockedMinoes = Array.from(Array(MATRIX_ROWS+3), row => Array(MATRIX_COLUMNS))
|
||||||
this.piece = null
|
this.piece = null
|
||||||
this.clearedLines = []
|
this.clearedLines = []
|
||||||
@ -303,6 +309,9 @@ class Matrix extends MinoesTable {
|
|||||||
class NextQueue extends MinoesTable {
|
class NextQueue extends MinoesTable {
|
||||||
constructor() {
|
constructor() {
|
||||||
super("next", NEXT_ROWS, NEXT_COLUMNS)
|
super("next", NEXT_ROWS, NEXT_COLUMNS)
|
||||||
|
}
|
||||||
|
|
||||||
|
newGame() {
|
||||||
this.pieces = Array.from({length: NEXT_PIECES}, (v, k) => new Tetromino(NEXT_PIECES_POSITIONS[k]))
|
this.pieces = Array.from({length: NEXT_PIECES}, (v, k) => new Tetromino(NEXT_PIECES_POSITIONS[k]))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,12 +340,18 @@ class Stats {
|
|||||||
this.levelCell = document.getElementById("level")
|
this.levelCell = document.getElementById("level")
|
||||||
this.goalCell = document.getElementById("goal")
|
this.goalCell = document.getElementById("goal")
|
||||||
this.clearedLinesCell = document.getElementById("clearedLines")
|
this.clearedLinesCell = document.getElementById("clearedLines")
|
||||||
this._score = 0
|
|
||||||
this.highScore = Number(localStorage.getItem('highScore'))
|
this.highScore = Number(localStorage.getItem('highScore'))
|
||||||
this.highScoreCell.innerHTML = this.highScore.toLocaleString()
|
this.highScoreCell.innerText = this.highScore.toLocaleString()
|
||||||
|
}
|
||||||
|
|
||||||
|
newGame() {
|
||||||
|
this.score = 0
|
||||||
this.goal = 0
|
this.goal = 0
|
||||||
|
this.goalCell.innerText = this.goal
|
||||||
this.clearedLines = 0
|
this.clearedLines = 0
|
||||||
|
this.clearedLinesCell.innerText = this.clearedLines
|
||||||
this.time = 0
|
this.time = 0
|
||||||
|
this.timeCell.innerText = timeFormat(0)
|
||||||
this.combo = -1
|
this.combo = -1
|
||||||
this.lockDelay = LOCK_DELAY
|
this.lockDelay = LOCK_DELAY
|
||||||
this.fallPeriod = FALL_PERIOD
|
this.fallPeriod = FALL_PERIOD
|
||||||
@ -349,10 +364,10 @@ class Stats {
|
|||||||
set score(score) {
|
set score(score) {
|
||||||
if (score != NaN) {
|
if (score != NaN) {
|
||||||
this._score = score
|
this._score = score
|
||||||
this.scoreCell.innerHTML = this._score.toLocaleString()
|
this.scoreCell.innerText = this._score.toLocaleString()
|
||||||
if (score > this.highScore)
|
if (score > this.highScore)
|
||||||
this.highScore = score
|
this.highScore = score
|
||||||
this.highScoreCell.innerHTML = this.highScore.toLocaleString()
|
this.highScoreCell.innerText = this.highScore.toLocaleString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,10 +376,10 @@ class Stats {
|
|||||||
this.level = level
|
this.level = level
|
||||||
else
|
else
|
||||||
this.level++
|
this.level++
|
||||||
this.levelCell.innerHTML = this.level
|
this.levelCell.innerText = this.level
|
||||||
printTempTexts(`LEVEL<br/>${this.level}`)
|
printTempTexts(`LEVEL<br/>${this.level}`)
|
||||||
this.goal += 5 * this.level
|
this.goal += 5 * this.level
|
||||||
this.goalCell.innerHTML = this.goal
|
this.goalCell.innerText = this.goal
|
||||||
if (this.level <= 20)
|
if (this.level <= 20)
|
||||||
this.fallPeriod = 1000 * Math.pow(0.8 - ((this.level - 1) * 0.007), this.level - 1)
|
this.fallPeriod = 1000 * Math.pow(0.8 - ((this.level - 1) * 0.007), this.level - 1)
|
||||||
if (this.level > 15)
|
if (this.level > 15)
|
||||||
@ -386,10 +401,10 @@ class Stats {
|
|||||||
|
|
||||||
if (clearedLines || tSpin) {
|
if (clearedLines || tSpin) {
|
||||||
this.clearedLines += clearedLines
|
this.clearedLines += clearedLines
|
||||||
this.clearedLinesCell.innerHTML = clearedLines
|
this.clearedLinesCell.innerText = clearedLines
|
||||||
patternScore = SCORES[clearedLines][tSpin]
|
patternScore = SCORES[clearedLines][tSpin]
|
||||||
this.goal -= patternScore
|
this.goal -= patternScore
|
||||||
this.goalCell.innerHTML = this.goal
|
this.goalCell.innerText = this.goal
|
||||||
patternScore *= 100 * this.level
|
patternScore *= 100 * this.level
|
||||||
patternName = patternName.join("\n")
|
patternName = patternName.join("\n")
|
||||||
}
|
}
|
||||||
@ -410,9 +425,14 @@ class Stats {
|
|||||||
|
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
function start() {
|
function newGame() {
|
||||||
document.getElementById("startButton").blur()
|
document.getElementById("startButton").blur()
|
||||||
|
|
||||||
|
holdQueue.newGame()
|
||||||
|
matrix.newGame()
|
||||||
|
nextQueue.newGame()
|
||||||
|
stats.newGame()
|
||||||
|
|
||||||
var startLevel = document.getElementById("startLevel").value
|
var startLevel = document.getElementById("startLevel").value
|
||||||
localStorage.setItem("startLevel", startLevel)
|
localStorage.setItem("startLevel", startLevel)
|
||||||
|
|
||||||
@ -610,7 +630,7 @@ function gameOver() {
|
|||||||
XHR.open('POST', 'inleaderboard.php')
|
XHR.open('POST', 'inleaderboard.php')
|
||||||
XHR.send(FD)
|
XHR.send(FD)
|
||||||
|
|
||||||
document.getElementById("game").style.display = "none"
|
document.getElementById("game").style.display = "grid"
|
||||||
document.getElementById("settings").style.display = "none"
|
document.getElementById("settings").style.display = "none"
|
||||||
document.getElementById("start").style.display = "flex"
|
document.getElementById("start").style.display = "flex"
|
||||||
document.getElementById("settingsButton").style.display = "flex"
|
document.getElementById("settingsButton").style.display = "flex"
|
||||||
@ -760,7 +780,7 @@ function delTempTexts(self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function clock() {
|
function clock() {
|
||||||
stats.timeCell.innerHTML = timeFormat(1000 * ++stats.time)
|
stats.timeCell.innerText = timeFormat(1000 * ++stats.time)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getKeyName(action) {
|
function getKeyName(action) {
|
||||||
|
Reference in New Issue
Block a user