-
Notifications
You must be signed in to change notification settings - Fork 839
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5005 from pavitraag/super_tetris
Added Super tetris game
- Loading branch information
Showing
6 changed files
with
804 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Oops, something went wrong.