From 8fbb4c15d79e446f2ab74139037954433df1ee51 Mon Sep 17 00:00:00 2001 From: Pedro Ramon77 Date: Tue, 6 Oct 2026 18:54:01 -0300 Subject: [PATCH 1/8] feat: adiciona sistema de recordes ao Tetris --- inde.html | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/inde.html b/inde.html index 87e71f8..901ebd0 100644 --- a/inde.html +++ b/inde.html @@ -12,6 +12,7 @@ #menu p a { text-decoration: none; color: black; } #upcoming { display: block; margin: 0 auto; background-color: #E0E0E0; } #score { color: blue; font-weight: bold; vertical-align: middle; } + #record { color: black; font-weight: bold; vertical-align: middle; } #rows { color: blue; font-weight: bold; vertical-align: middle; } #stats { position: absolute; bottom: 0em; right: 1em; } @media screen and (min-width: 0px) and (min-height: 0px) { #tetris { font-size: 0.75em; width: 250px; } #menu { width: 100px; height: 200px; } #upcoming { width: 50px; height: 50px; } #canvas { width: 100px; height: 200px; } } /* 10px chunks */ @@ -30,8 +31,9 @@ Sorry, this example cannot be run because your browser does not support the <canvas> element @@ -245,8 +247,7 @@ function play() { hide('start'); reset(); paused = false; playing = true; } function pause() {show('start'); paused = true; playing = false;} function restart() {hide('start'); paused = false; playing = true;} - function lose() { show('start'); setVisualScore(); playing = false; } - + function lose() { saveRecord(); show('start'); setVisualScore(); playing = false; } function setVisualScore(n) { vscore = n || score; invalidateScore(); } function setScore(n) { score = n; setVisualScore(n); } function addScore(n) { score = score + n; } @@ -367,6 +368,20 @@ } } + function saveRecord() { + var record = Number(localStorage.getItem('tetrisRecord')) || 0; + if (score > record) { + record = score; + localStorage.setItem('tetrisRecord', record); + } + html('record', ("00000" + record).slice(-5)); + } + + function showRecord() { + var record = Number(localStorage.getItem('tetrisRecord')) || 0; + html('record', ("00000" + record).slice(-5)); + } + //------------------------------------------------------------------------- // RENDERING //------------------------------------------------------------------------- @@ -449,7 +464,7 @@ //------------------------------------------------------------------------- // FINALLY, lets run the game //------------------------------------------------------------------------- - + showRecord(); run(); From 079bf3c9a556bd61b89dff7c13831655f789cd49 Mon Sep 17 00:00:00 2001 From: Pedro Ramon77 Date: Tue, 6 Oct 2026 19:23:50 -0300 Subject: [PATCH 2/8] feat: adiciona destaque visual ao novo recorde --- inde.html | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/inde.html b/inde.html index 901ebd0..0001fcf 100644 --- a/inde.html +++ b/inde.html @@ -12,8 +12,8 @@ #menu p a { text-decoration: none; color: black; } #upcoming { display: block; margin: 0 auto; background-color: #E0E0E0; } #score { color: blue; font-weight: bold; vertical-align: middle; } - #record { color: black; font-weight: bold; vertical-align: middle; } - #rows { color: blue; font-weight: bold; vertical-align: middle; } + #record { color: blue; font-weight: bold; vertical-align: middle; } + #new-record { color: #e60000; font-weight: bold; font-size: 18px; text-align: center; margin: 8px 0; text-transform: uppercase; letter-spacing: 1px; animation: piscar 0.8s infinite; } @keyframes piscar { 0%, 100% { opacity: 1; } 50% { opacity: 0; } } #rows { color: blue; font-weight: bold; vertical-align: middle; } #stats { position: absolute; bottom: 0em; right: 1em; } @media screen and (min-width: 0px) and (min-height: 0px) { #tetris { font-size: 0.75em; width: 250px; } #menu { width: 100px; height: 200px; } #upcoming { width: 50px; height: 50px; } #canvas { width: 100px; height: 200px; } } /* 10px chunks */ @media screen and (min-width: 400px) and (min-height: 400px) { #tetris { font-size: 1.00em; width: 350px; } #menu { width: 150px; height: 300px; } #upcoming { width: 75px; height: 75px; } #canvas { width: 150px; height: 300px; } } /* 15px chunks */ @@ -33,6 +33,7 @@

score: 00000

record: 00000

+

rows: 0

@@ -95,6 +96,7 @@ current, // the current piece next, // the next piece score, // the current score + record, // the current record vscore, // the currently displayed score (it catches up to score in small chunks - like a spinning slot machine) rows, // number of completed rows in the current game step; // how long before current piece drops by 1 row @@ -264,6 +266,7 @@ function reset() { dt = 0; + html('new-record', ''); clearActions(); clearBlocks(); clearRows(); @@ -369,16 +372,21 @@ } function saveRecord() { - var record = Number(localStorage.getItem('tetrisRecord')) || 0; - if (score > record) { + var recordAtual = Number(localStorage.getItem('tetrisRecord')) || 0; + if (score > recordAtual) { record = score; localStorage.setItem('tetrisRecord', record); + html('new-record', 'NEW RECORD !!!'); + } + else { + record = recordAtual; + html('new-record', ''); } html('record', ("00000" + record).slice(-5)); } function showRecord() { - var record = Number(localStorage.getItem('tetrisRecord')) || 0; + record = Number(localStorage.getItem('tetrisRecord')) || 0; html('record', ("00000" + record).slice(-5)); } From c1095534aa5268b14f5da087814113636cccc01e Mon Sep 17 00:00:00 2001 From: Lana Liz Date: Thu, 8 Oct 2026 14:21:37 -0300 Subject: [PATCH 3/8] feat: implementa funcionalidade de Game Over com mensagem centralizada e recordes --- inde.html | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/inde.html b/inde.html index 0001fcf..1988c1f 100644 --- a/inde.html +++ b/inde.html @@ -39,6 +39,7 @@ Sorry, this example cannot be run because your browser does not support the <canvas> element + @@ -246,10 +247,22 @@ // GAME LOGIC //------------------------------------------------------------------------- - function play() { hide('start'); reset(); paused = false; playing = true; } - function pause() {show('start'); paused = true; playing = false;} - function restart() {hide('start'); paused = false; playing = true;} - function lose() { saveRecord(); show('start'); setVisualScore(); playing = false; } + function play() { + hide('start'); + get('gameover').style.display = 'none'; // Esconde a mensagem de Game Over + reset(); + paused = false; + playing = true; + } + function pause() { show('start'); paused = true; playing = false; } + function restart() { hide('start'); get('gameover').style.display = 'none'; paused = false; playing = true; } + function lose() { + saveRecord(); + show('start'); + get('gameover').style.display = 'block'; // Mostra a mensagem de Game Over no meio da tela + setVisualScore(); + playing = false; + } function setVisualScore(n) { vscore = n || score; invalidateScore(); } function setScore(n) { score = n; setVisualScore(n); } function addScore(n) { score = score + n; } From 426189275daf9ad589cb0a3c8b7317f84a080520 Mon Sep 17 00:00:00 2001 From: Lana Liz Date: Thu, 8 Oct 2026 14:47:31 -0300 Subject: [PATCH 4/8] style: ajusta container para centralizar o Game Over exatamente sobre o canvas do jogo --- inde.html | 77 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 58 insertions(+), 19 deletions(-) diff --git a/inde.html b/inde.html index 1988c1f..62405c5 100644 --- a/inde.html +++ b/inde.html @@ -3,18 +3,40 @@ Javascript Tetris