Skip to content

Commit

Permalink
Merge pull request #5005 from pavitraag/super_tetris
Browse files Browse the repository at this point in the history
Added Super tetris game
  • Loading branch information
kunjgit authored Jul 31, 2024
2 parents 1d4de1f + 232d6a6 commit 0c07353
Show file tree
Hide file tree
Showing 6 changed files with 804 additions and 2 deletions.
41 changes: 41 additions & 0 deletions Games/Super_tetris/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Tetris Game

A classic Tetris game built with HTML, CSS, and JavaScript. The goal is to manipulate tetrominoes to form complete lines without gaps, which then disappear, granting points.

## Features
- Interactive gameplay with keyboard controls.
- Falling tetrominoes of various shapes.
- Scoring system that awards points for clearing lines.
- Increasing difficulty as more lines are cleared.

## How to Play

1. Open the game in your web browser.
2. Use the arrow keys to move and rotate the falling tetrominoes:
- Left Arrow: Move left.
- Right Arrow: Move right.
- Down Arrow: Move down faster.
- Up Arrow: Rotate the tetromino.
3. Complete horizontal lines to score points and clear the lines from the board.
4. The game ends when the tetrominoes stack up to the top of the board.

### Installation

1. Clone the repository or download the files.
2. Open the `index.html` file in your preferred web browser.

### Files

- `index.html`: The main HTML file that contains the structure of the game.
- `style.css`: The CSS file that styles the game.
- `script.js`: The JavaScript file that contains the game logic.

### Usage

1. Open `index.html` in your browser.
2. Use the arrow keys to control the falling tetrominoes.
3. Form complete lines to score points.
4. The game speed increases as you clear more lines.

<img width="451" alt="image" src="https://github.com/user-attachments/assets/4a045122-d384-4a76-b41f-7cc06b365d3f">

15 changes: 15 additions & 0 deletions Games/Super_tetris/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tetris Game</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>

<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.4/p5.min.js"></script>
<script src="pieces.js"></script>
<script src="script.js"></script>
</body>
</html>
230 changes: 230 additions & 0 deletions Games/Super_tetris/pieces.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
function orientPoints(pieceType, rotation) {
let results = [];
switch (pieceType) {
case 0:
switch (rotation) {
case 0:
results = [
[-2, 0],
[-1, 0],
[0, 0],
[1, 0]
];
break;
case 1:
results = [
[0, -1],
[0, 0],
[0, 1],
[0, 2]
];
break;
case 2:
results = [
[-2, 1],
[-1, 1],
[0, 1],
[1, 1]
];
break;
case 3:
results = [
[-1, -1],
[-1, 0],
[-1, 1],
[-1, 2]
];
break;
}
break;
case 1:
switch (rotation) {
case 0:
results = [
[-2, -1],
[-2, 0],
[-1, 0],
[0, 0]
];
break;
case 1:
results = [
[-1, -1],
[-1, 0],
[-1, 1],
[0, -1]
];
break;
case 2:
results = [
[-2, 0],
[-1, 0],
[0, 0],
[0, 1]
];
break;
case 3:
results = [
[-1, -1],
[-1, 0],
[-1, 1],
[-2, 1]
];
break;
}
break;
case 2:
switch (rotation) {
case 0:
results = [
[-2, 0],
[-1, 0],
[0, 0],
[0, -1]
];
break;
case 1:
results = [
[-1, -1],
[-1, 0],
[-1, 1],
[0, 1]
];
break;
case 2:
results = [
[-2, 0],
[-2, 1],
[-1, 0],
[0, 0]
];
break;
case 3:
results = [
[-2, -1],
[-1, -1],
[-1, 0],
[-1, 1]
];
break;
}
break;
case 3:
results = [
[-1, -1],
[0, -1],
[-1, 0],
[0, 0]
];
break;
case 4:
switch (rotation) {
case 0:
results = [
[-1, -1],
[-2, 0],
[-1, 0],
[0, -1]
];
break;
case 1:
results = [
[-1, -1],
[-1, 0],
[0, 0],
[0, 1]
];
break;
case 2:
results = [
[-1, 0],
[-2, 1],
[-1, 1],
[0, 0]
];
break;
case 3:
results = [
[-2, -1],
[-2, 0],
[-1, 0],
[-1, 1]
];
break;
}
break;
case 5:
switch (rotation) {
case 0:
results = [
[-1, 0],
[0, 0],
[1, 0],
[0, -1]
];
break;
case 1:
results = [
[0, -1],
[0, 0],
[0, 1],
[1, 0]
];
break;
case 2:
results = [
[-1, 0],
[0, 0],
[1, 0],
[0, 1]
];
break;
case 3:
results = [
[0, -1],
[0, 0],
[0, 1],
[-1, 0]
];
break;
}
break;
case 6:
switch (rotation) {
case 0:
results = [
[-2, -1],
[-1, -1],
[-1, 0],
[0, 0]
];
break;
case 1:
results = [
[-1, 0],
[-1, 1],
[0, 0],
[0, -1]
];
break;
case 2:
results = [
[-2, 0],
[-1, 0],
[-1, 1],
[0, 1]
];
break;
case 3:
results = [
[-2, 0],
[-2, 1],
[-1, 0],
[-1, -1]
];
break;
}
break;
}
return results;
}
Loading

0 comments on commit 0c07353

Please sign in to comment.