Skip to content

Commit

Permalink
0.2.2
Browse files Browse the repository at this point in the history
Fixed early game over bug as a consequence of the 2d array being jagged on the sides
  • Loading branch information
TreacherousDev committed Dec 7, 2024
1 parent 1070edd commit b399012
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 15 deletions.
Binary file modified GitHub-Tetris-Chromium/GitHub-Tetris-Chromium.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion GitHub-Tetris-Chromium/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "GitHub Tetris Game",
"version": "0.2.1",
"version": "0.2.2",
"description": "Play Tetris on your GitHub contribution graph.",
"permissions": [
"activeTab",
Expand Down
12 changes: 8 additions & 4 deletions GitHub-Tetris-Chromium/tetris.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const tetrominoes = [
let tetrominoBag = [];
// Active tetromino state
let activeTetromino = [];
let position = { x: 46, y: 3 }; // Start from the right center
let position = { x: 50, y: 3 }; // Start from the right center
let gameOver = false;


Expand All @@ -60,6 +60,8 @@ const getNextTetromino = () => {


const spawnTetromino = () => {
// Spawn a new tetromino
position = { x: 50, y: 3 }; // Reset position
const randomIndex = getNextTetromino(); // Use fair distribution
activeTetromino = tetrominoes[randomIndex].map(block => ({
x: position.x + block.x,
Expand Down Expand Up @@ -230,8 +232,6 @@ const moveTetromino = () => {
// After landing, check and clear full columns and shift left
clearFullColumns();

// Spawn a new tetromino
position = { x: 51, y: 3 }; // Reset position
spawnTetromino();
}
};
Expand Down Expand Up @@ -261,7 +261,6 @@ const dropTetrominoLeft = () => {
clearFullColumns();

// Spawn a new tetromino
position = { x: 51, y: 3 }; // Reset position
spawnTetromino();
};

Expand Down Expand Up @@ -367,18 +366,23 @@ document.addEventListener('keydown', (event) => {

switch (input) {
case 'w':
case 'ArrowUp':
moveTetrominoVertically('up'); // Move up
break;
case 's':
case 'ArrowDown':
moveTetrominoVertically('down'); // Move down
break;
case ' ':
case 'Enter':
dropTetrominoLeft(); // Trigger instant left drop
break;
case 'a':
case 'ArrowLeft':
rotateTetromino('counterclockwise'); // Rotate counterclockwise
break;
case 'd':
case 'ArrowRight':
rotateTetromino('clockwise'); // Rotate clockwise
break;
}
Expand Down
Binary file modified GitHub-Tetris/GitHub-Tetris.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion GitHub-Tetris/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "GitHub Tetris Game",
"version": "0.2.1",
"version": "0.2.2",
"description": "Play Tetris on your GitHub contribution graph.",
"permissions": [
"activeTab",
Expand Down
12 changes: 8 additions & 4 deletions GitHub-Tetris/tetris.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const tetrominoes = [
let tetrominoBag = [];
// Active tetromino state
let activeTetromino = [];
let position = { x: 46, y: 3 }; // Start from the right center
let position = { x: 50, y: 3 }; // Start from the right center
let gameOver = false;


Expand All @@ -60,6 +60,8 @@ const getNextTetromino = () => {


const spawnTetromino = () => {
// Spawn a new tetromino
position = { x: 50, y: 3 }; // Reset position
const randomIndex = getNextTetromino(); // Use fair distribution
activeTetromino = tetrominoes[randomIndex].map(block => ({
x: position.x + block.x,
Expand Down Expand Up @@ -230,8 +232,6 @@ const moveTetromino = () => {
// After landing, check and clear full columns and shift left
clearFullColumns();

// Spawn a new tetromino
position = { x: 51, y: 3 }; // Reset position
spawnTetromino();
}
};
Expand Down Expand Up @@ -261,7 +261,6 @@ const dropTetrominoLeft = () => {
clearFullColumns();

// Spawn a new tetromino
position = { x: 51, y: 3 }; // Reset position
spawnTetromino();
};

Expand Down Expand Up @@ -367,18 +366,23 @@ document.addEventListener('keydown', (event) => {

switch (input) {
case 'w':
case 'ArrowUp':
moveTetrominoVertically('up'); // Move up
break;
case 's':
case 'ArrowDown':
moveTetrominoVertically('down'); // Move down
break;
case ' ':
case 'Enter':
dropTetrominoLeft(); // Trigger instant left drop
break;
case 'a':
case 'ArrowLeft':
rotateTetromino('counterclockwise'); // Rotate counterclockwise
break;
case 'd':
case 'ArrowRight':
rotateTetromino('clockwise'); // Rotate clockwise
break;
}
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "GitHub Tetris Game",
"version": "0.2.1",
"version": "0.2.2",
"description": "Play Tetris on your GitHub contribution graph.",
"permissions": [
"activeTab",
Expand Down
12 changes: 8 additions & 4 deletions tetris.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const tetrominoes = [
let tetrominoBag = [];
// Active tetromino state
let activeTetromino = [];
let position = { x: 46, y: 3 }; // Start from the right center
let position = { x: 50, y: 3 }; // Start from the right center
let gameOver = false;


Expand All @@ -60,6 +60,8 @@ const getNextTetromino = () => {


const spawnTetromino = () => {
// Spawn a new tetromino
position = { x: 50, y: 3 }; // Reset position
const randomIndex = getNextTetromino(); // Use fair distribution
activeTetromino = tetrominoes[randomIndex].map(block => ({
x: position.x + block.x,
Expand Down Expand Up @@ -230,8 +232,6 @@ const moveTetromino = () => {
// After landing, check and clear full columns and shift left
clearFullColumns();

// Spawn a new tetromino
position = { x: 51, y: 3 }; // Reset position
spawnTetromino();
}
};
Expand Down Expand Up @@ -261,7 +261,6 @@ const dropTetrominoLeft = () => {
clearFullColumns();

// Spawn a new tetromino
position = { x: 51, y: 3 }; // Reset position
spawnTetromino();
};

Expand Down Expand Up @@ -367,18 +366,23 @@ document.addEventListener('keydown', (event) => {

switch (input) {
case 'w':
case 'ArrowUp':
moveTetrominoVertically('up'); // Move up
break;
case 's':
case 'ArrowDown':
moveTetrominoVertically('down'); // Move down
break;
case ' ':
case 'Enter':
dropTetrominoLeft(); // Trigger instant left drop
break;
case 'a':
case 'ArrowLeft':
rotateTetromino('counterclockwise'); // Rotate counterclockwise
break;
case 'd':
case 'ArrowRight':
rotateTetromino('clockwise'); // Rotate clockwise
break;
}
Expand Down

0 comments on commit b399012

Please sign in to comment.