diff --git a/Games/Tetris_Game/Readme.md b/Games/Tetris_Game/Readme.md
new file mode 100644
index 0000000000..25bb008234
--- /dev/null
+++ b/Games/Tetris_Game/Readme.md
@@ -0,0 +1,23 @@
+## Tetris Game
+
+This is a simple Tetris game built with HTML, CSS, and JavaScript.
+
+**How to Play:**
+
+1. Open `index.html` in a web browser.
+2. Use the arrow keys to move the tetrimino (left, right, down) and the up key to rotate it.
+3. Clear lines by filling them entirely with blocks.
+4. Avoid stacking blocks too high; the game ends if a new tetrimino can't spawn.
+
+**Features:**
+
+* Classic tetrimino shapes.
+* Basic movement and rotation controls.
+* Line clearing with score updates.
+
+**Getting Started:**
+
+1. Download or clone this repository.
+2. Open `index.html` in your web browser.
+
+![Screenshot 2024-06-07 123816](https://github.com/kunjgit/GameZone/assets/141642724/14c48201-d47b-40ac-99ed-45f90bef8b96)
\ No newline at end of file
diff --git a/Games/Tetris_Game/assets/Board/Board.png b/Games/Tetris_Game/assets/Board/Board.png
new file mode 100644
index 0000000000..41721e4e75
Binary files /dev/null and b/Games/Tetris_Game/assets/Board/Board.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/I.png b/Games/Tetris_Game/assets/Shape Blocks/I.png
new file mode 100644
index 0000000000..8a38a5cb7c
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/I.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/I1.png b/Games/Tetris_Game/assets/Shape Blocks/I1.png
new file mode 100644
index 0000000000..7dae5ab446
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/I1.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/J.png b/Games/Tetris_Game/assets/Shape Blocks/J.png
new file mode 100644
index 0000000000..ce04b3f660
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/J.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/J1.png b/Games/Tetris_Game/assets/Shape Blocks/J1.png
new file mode 100644
index 0000000000..04c24d7ebf
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/J1.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/J2.png b/Games/Tetris_Game/assets/Shape Blocks/J2.png
new file mode 100644
index 0000000000..a792c29dff
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/J2.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/J3.png b/Games/Tetris_Game/assets/Shape Blocks/J3.png
new file mode 100644
index 0000000000..b766b3bca2
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/J3.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/L.png b/Games/Tetris_Game/assets/Shape Blocks/L.png
new file mode 100644
index 0000000000..ffcd6b78a2
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/L.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/L1.png b/Games/Tetris_Game/assets/Shape Blocks/L1.png
new file mode 100644
index 0000000000..be1a30b70e
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/L1.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/L2.png b/Games/Tetris_Game/assets/Shape Blocks/L2.png
new file mode 100644
index 0000000000..a9327826f7
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/L2.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/L3.png b/Games/Tetris_Game/assets/Shape Blocks/L3.png
new file mode 100644
index 0000000000..e6accee39a
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/L3.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/O.png b/Games/Tetris_Game/assets/Shape Blocks/O.png
new file mode 100644
index 0000000000..414b055595
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/O.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/S.png b/Games/Tetris_Game/assets/Shape Blocks/S.png
new file mode 100644
index 0000000000..467789550d
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/S.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/S1.png b/Games/Tetris_Game/assets/Shape Blocks/S1.png
new file mode 100644
index 0000000000..deed977c9b
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/S1.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/T.png b/Games/Tetris_Game/assets/Shape Blocks/T.png
new file mode 100644
index 0000000000..b056b981c2
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/T.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/T1.png b/Games/Tetris_Game/assets/Shape Blocks/T1.png
new file mode 100644
index 0000000000..00e85b0f60
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/T1.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/T2.png b/Games/Tetris_Game/assets/Shape Blocks/T2.png
new file mode 100644
index 0000000000..e81ab07421
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/T2.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/T3.png b/Games/Tetris_Game/assets/Shape Blocks/T3.png
new file mode 100644
index 0000000000..5a60c0947a
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/T3.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/Z.png b/Games/Tetris_Game/assets/Shape Blocks/Z.png
new file mode 100644
index 0000000000..f74c7bc1c5
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/Z.png differ
diff --git a/Games/Tetris_Game/assets/Shape Blocks/Z1.png b/Games/Tetris_Game/assets/Shape Blocks/Z1.png
new file mode 100644
index 0000000000..96f05c9db0
Binary files /dev/null and b/Games/Tetris_Game/assets/Shape Blocks/Z1.png differ
diff --git a/Games/Tetris_Game/assets/Single Blocks/Blue.png b/Games/Tetris_Game/assets/Single Blocks/Blue.png
new file mode 100644
index 0000000000..614481efc0
Binary files /dev/null and b/Games/Tetris_Game/assets/Single Blocks/Blue.png differ
diff --git a/Games/Tetris_Game/assets/Single Blocks/Green.png b/Games/Tetris_Game/assets/Single Blocks/Green.png
new file mode 100644
index 0000000000..4a9f3d0bc7
Binary files /dev/null and b/Games/Tetris_Game/assets/Single Blocks/Green.png differ
diff --git a/Games/Tetris_Game/assets/Single Blocks/LightBlue.png b/Games/Tetris_Game/assets/Single Blocks/LightBlue.png
new file mode 100644
index 0000000000..d3d49f231f
Binary files /dev/null and b/Games/Tetris_Game/assets/Single Blocks/LightBlue.png differ
diff --git a/Games/Tetris_Game/assets/Single Blocks/Orange.png b/Games/Tetris_Game/assets/Single Blocks/Orange.png
new file mode 100644
index 0000000000..dc6c2e904f
Binary files /dev/null and b/Games/Tetris_Game/assets/Single Blocks/Orange.png differ
diff --git a/Games/Tetris_Game/assets/Single Blocks/Purple.png b/Games/Tetris_Game/assets/Single Blocks/Purple.png
new file mode 100644
index 0000000000..c08126a8bf
Binary files /dev/null and b/Games/Tetris_Game/assets/Single Blocks/Purple.png differ
diff --git a/Games/Tetris_Game/assets/Single Blocks/Red.png b/Games/Tetris_Game/assets/Single Blocks/Red.png
new file mode 100644
index 0000000000..8f36d38409
Binary files /dev/null and b/Games/Tetris_Game/assets/Single Blocks/Red.png differ
diff --git a/Games/Tetris_Game/assets/Single Blocks/Yellow.png b/Games/Tetris_Game/assets/Single Blocks/Yellow.png
new file mode 100644
index 0000000000..acfd7b678e
Binary files /dev/null and b/Games/Tetris_Game/assets/Single Blocks/Yellow.png differ
diff --git a/Games/Tetris_Game/assets/Sound Effects/clear-lines.mp3 b/Games/Tetris_Game/assets/Sound Effects/clear-lines.mp3
new file mode 100644
index 0000000000..9e433e83d8
Binary files /dev/null and b/Games/Tetris_Game/assets/Sound Effects/clear-lines.mp3 differ
diff --git a/Games/Tetris_Game/assets/Title/Title.png b/Games/Tetris_Game/assets/Title/Title.png
new file mode 100644
index 0000000000..f13871ca95
Binary files /dev/null and b/Games/Tetris_Game/assets/Title/Title.png differ
diff --git a/Games/Tetris_Game/assets/Title/retry.png b/Games/Tetris_Game/assets/Title/retry.png
new file mode 100644
index 0000000000..3e401c1d74
Binary files /dev/null and b/Games/Tetris_Game/assets/Title/retry.png differ
diff --git a/Games/Tetris_Game/index.html b/Games/Tetris_Game/index.html
new file mode 100644
index 0000000000..6dd8ff0746
--- /dev/null
+++ b/Games/Tetris_Game/index.html
@@ -0,0 +1,40 @@
+
+
+
+
+
+ Document
+
+
+
+
+
+
+
+
+
+
Score0
+
Lines0
+
Level1
+
+
+
+
+
+
+
+
diff --git a/Games/Tetris_Game/main.js b/Games/Tetris_Game/main.js
new file mode 100644
index 0000000000..4687687431
--- /dev/null
+++ b/Games/Tetris_Game/main.js
@@ -0,0 +1,558 @@
+const tetriminos = {
+ i:[
+ [
+ [1,1,1,1],
+ [0,0,0,0],
+ [0,0,0,0],
+ [0,0,0,0],
+ ],
+ [
+ [1,0,0,0],
+ [1,0,0,0],
+ [1,0,0,0],
+ [1,0,0,0],
+ ],
+],
+ j:[
+ [
+ [1,0,0],
+ [1,1,1],
+ [0,0,0],
+ ],
+ [
+ [1,1,0],
+ [1,0,0],
+ [1,0,0],
+ ],
+ [
+ [1,1,1],
+ [0,0,1],
+ [0,0,0],
+ ],
+ [
+ [0,1,0],
+ [0,1,0],
+ [1,1,0],
+ ],
+ ],
+ l: [
+ [
+ [0,0,1],
+ [1,1,1],
+ [0,0,0],
+ ],
+ [
+ [1,0,0],
+ [1,0,0],
+ [1,1,0],
+ ],
+ [
+ [1,1,1],
+ [1,0,0],
+ [0,0,0],
+ ],
+ [
+ [1,1,0],
+ [0,1,0],
+ [0,1,0],
+ ],
+],
+ o: [
+ [
+ [1,1],
+ [1,1]
+ ],
+ [
+ [1,1],
+ [1,1]
+ ],
+],
+ s: [
+ [
+ [0,1,1],
+ [1,1,0],
+ [0,0,0],
+ ],
+ [
+ [1,0,0],
+ [1,1,0],
+ [0,1,0],
+ ],
+],
+
+ t: [
+ [
+ [0,1,0],
+ [1,1,1],
+ [0,0,0],
+ ],
+ [
+ [1,0,0],
+ [1,1,0],
+ [1,0,0],
+ ],
+ [
+ [1,1,1],
+ [0,1,0],
+ [0,0,0],
+ ],
+ [
+ [0,1,0],
+ [1,1,0],
+ [0,1,0],
+ ],
+],
+ z: [
+ [
+ [1,1,0],
+ [0,1,1],
+ [0,0,0],
+ ],
+ [
+ [0,1,0],
+ [1,1,0],
+ [1,0,0],
+ ],
+]
+};
+const rotationStates = {
+ l: {
+ 0:[0,1],
+ 1:[1,-1],
+ 2:[-1,1],
+ 3:[0,-1],
+ },
+ j: {
+ 0:[0,1],
+ 1:[1,-1],
+ 2:[-1,1],
+ 3:[0,-1],
+ },
+ t: {
+ 0:[0,0],
+ 1:[1,-1],
+ 2:[-1,1],
+ 3:[0,0],
+ },
+ s: {
+ 0:[-1,1],
+ 1:[1,-1],
+ },
+ z: {
+ 0:[-1,1],
+ 1:[1,-1],
+ },
+ i: {
+ 0:[-1,1],
+ 1:[1,-1],
+ },
+ o: {
+ 0:[0,0],
+ },
+};
+let gameOver = false;
+let lines=0;
+let score=0;
+let level=1;
+document.getElementById("startGame").addEventListener("click",function(){
+ window.game.scene.keys["TetrisScene"].resetGame();
+});
+class TetrisScene extends Phaser.Scene {
+ constructor() {
+ super({key: "TetrisScene"});
+ this.gameBoard = [];
+ this.currentTetrimino = null;
+ this.blockSprites = [];
+ for (let i=0;i<20;i++) {
+ this.blockSprites[i] = new Array(10).fill(null);
+ }
+ }
+ preload() {
+ this.load.image("j","assets/Shape Blocks/J.png");
+ this.load.image("i","assets/Shape Blocks/I.png");
+ this.load.image("l","assets/Shape Blocks/L.png");
+ this.load.image("z","assets/Shape Blocks/Z.png");
+ this.load.image("s","assets/Shape Blocks/S.png");
+ this.load.image("t","assets/Shape Blocks/T.png");
+ this.load.image("o","assets/Shape Blocks/O.png");
+ this.load.image("j1","assets/Shape Blocks/J1.png");
+ this.load.image("i1","assets/Shape Blocks/I1.png");
+ this.load.image("l1","assets/Shape Blocks/L1.png");
+ this.load.image("z1","assets/Shape Blocks/Z1.png");
+ this.load.image("s1","assets/Shape Blocks/S1.png");
+ this.load.image("t1","assets/Shape Blocks/T1.png");
+ this.load.image("j2","assets/Shape Blocks/J2.png");
+ this.load.image("l2","assets/Shape Blocks/L2.png");
+ this.load.image("t2","assets/Shape Blocks/T2.png");
+ this.load.image("j3","assets/Shape Blocks/J3.png");
+ this.load.image("l3","assets/Shape Blocks/L3.png");
+ this.load.image("t3","assets/Shape Blocks/T3.png");
+ this.load.image("block-j","assets/Single Blocks/Blue.png");
+ this.load.image("block-i","assets/Single Blocks/LightBlue.png");
+ this.load.image("block-l","assets/Single Blocks/Orange.png");
+ this.load.image("block-s","assets/Single Blocks/Green.png");
+ this.load.image("block-t","assets/Single Blocks/Purple.png");
+ this.load.image("block-z","assets/Single Blocks/Red.png");
+ this.load.image("block-o","assets/Single Blocks/Yellow.png");
+ this.load.image("board","assets/Board/Board.png");
+ this.load.audio("lineClear","assets/Sound Effects/clear-lines.mp3");
+ this.load.on("complete",()=>{
+ const oTetrimino = this.textures.get("o").getSourceImage();
+ this.blockSize = oTetrimino.width/4;
+ });
+ }
+ create() {
+ let bg = this.add.image(0,0,"board");
+ this.lineClear = this.sound.add("lineClear");
+ bg.setOrigin(0,0);
+ bg.displayWidth = this.sys.game.config.width;
+ bg.displayHeight = this.sys.game.config.height;
+ for(let i=0; i<20;i++) {
+ this.gameBoard[i] = [];
+ for(let j=0;j<10;j++) {
+ this.gameBoard[i][j] = 0;
+ }
+ }
+ this.moveCounter = 0;
+ this.moveInterval = 60;
+ this.spawnTetrimino();
+ this.cursors = this.input.keyboard.createCursorKeys();
+ }
+ spawnTetrimino() {
+ const tetriminos = ["j","i","l","z","s","t","o"];
+
+ if(!this.nextTetriminoType) {
+ const randomIndex = Math.floor(Math.random()* tetriminos.length);
+ this.nextTetriminoType = tetriminos[randomIndex];
+ }
+ this.currentTetriminoType = this.nextTetriminoType;
+ const randomIndex = Math.floor(Math.random()* tetriminos.length);
+ this.nextTetriminoType = tetriminos[randomIndex];
+ nextTetriminoImage.src = "assets/Shape Blocks/"+this.nextTetriminoType.toUpperCase()+".png";
+ this.currentTetrimino = this.physics.add.image(0,this.blockSize,this.currentTetriminoType);
+ const tetriminoWidth = 0.5*this.currentTetrimino.displayWidth/this.blockSize;
+ const xOffset = tetriminoWidth%2 === 0 ? (this.blockSize*(10-tetriminoWidth))/2: 3*this.blockSize;
+ this.currentTetrimino.x = xOffset;
+ this.currentTetrimino.y = 0;
+ this.currentTetrimino.rotationState = 0;
+ this.currentTetrimino.setOrigin(0,0);
+ this.currentTetrimino.setScale(0.5);
+ this.physics.world.enable(this.currentTetrimino);
+ this.currentTetrimino.body.collideWorldBounds = true;
+ this.currentTetrimino.blocks = this.calculateBlockPositions(this.currentTetriminoType,0);
+ gameOver = this.isGameOver();
+ if(gameOver) {
+ this.displayEndGameMessage();
+ }
+ }
+ spawnTetriminoAt(type,x,y,rotationState) {
+ this.currentTetrimino = this.physics.add.image(0,this.blockSize,type);
+ this.currentTetrimino.setOrigin(0,0);
+ this.currentTetrimino.setScale(0.5);
+ this.physics.world.enable(this.currentTetrimino);
+ this.currentTetrimino.body.collideWorldBounds =true;
+ this.currentTetrimino.x = x+rotationStates[this.currentTetriminoType][rotationState][0]*this.blockSize;
+ this.currentTetrimino.y = y+rotationStates[this.currentTetriminoType][rotationState][1]*this.blockSize;
+ this.currentTetrimino.rotationState = rotationState;
+ this.currentTetrimino.blocks = this.calculateBlockPositions(this.currentTetriminoType,rotationState);
+ }
+ isGameOver() {
+ let spawnLocations = {
+ i: [0,3],
+ o: [0,4],
+ default: [0,3]
+ };
+ let spawnLocation = spawnLocations[this.currentTetriminoType] || spawnLocations["default"];
+ let blockPositions = this.calculateBlockPositions(this.currentTetriminoType,this.currentTetrimino.rotationState);
+ for(let block of blockPositions) {
+ let x = spawnLocation[1]+block.x;
+ let y = spawnLocation[0]+block.y;
+ if(this.gameBoard[y] && this.gameBoard[y][x] === 1) {
+ return true;
+ }
+ }
+ return false;
+ }
+ displayEndGameMessage() {
+ endGameContainer.style.display = "flex";
+ finalScore.innerText = score;
+ }
+
+ resetGame() {
+ endGameContainer.style.display = "none";
+ gameOver = false;
+ score=0;
+ lines=0;
+ level=1;
+ scoreNumber.innerText =0;
+ linesNumber.innerText = 0;
+ levelNumber.innerText = 1;
+ this.create();
+ }
+ calculateBlockPositions(type,rotationState) {
+ const positions = [];
+ const matrix = tetriminos[type][rotationState];
+ for (let i = 0;i{
+ let currentTetriminox = this.currentTetrimino.x+rotationStates[this.currentTetriminoType][rotationState][0]*this.blockSize;
+ let currentTetriminoy = this.currentTetrimino.y+rotationStates[this.currentTetriminoType][rotationState][1]*this.blockSize;
+ const x = Math.floor((currentTetriminox+block.x*this.blockSize)/this.blockSize);
+ const y = Math.floor((currentTetriminoy+block.y*this.blockSize)/this.blockSize);
+ if(x>9 || x<0 || y<0 || y>19) {
+ rotationValid = false;
+ } else if (this.gameBoard[y][x] == 1)
+ rotationValid = false;
+ });
+ return rotationValid;
+ }
+ update() {
+ if(gameOver) return;
+ this.moveCounter++;
+ if(this.currentTetrimino && this.moveCounter>= this.moveInterval) {
+ this.setTetriminoOnBoard(0);
+ this.currentTetrimino.y += this.blockSize;
+ this.moveCounter =0;
+ this.setTetriminoOnBoard(2);
+ this.time.delayedCall(500,()=>{
+ this.checkAndHandleLandedTetrimino();
+ });
+ }
+ if(!this.currentTetrimino) return;
+ if(Phaser.Input.Keyboard.JustDown(this.cursors.left)) {
+ if(!this.isMoveValid(-1)) return;
+ this.setTetriminoOnBoard(0);
+ this.currentTetrimino.x -=this.blockSize;
+ this.setTetriminoOnBoard(2);
+ this.checkAndHandleLandedTetrimino();
+ }
+ if(Phaser.Input.Keyboard.JustDown(this.cursors.right)) {
+ if(!this.isMoveValid(1)) return;
+ this.setTetriminoOnBoard(0);
+ this.currentTetrimino.x +=this.blockSize;
+ this.setTetriminoOnBoard(2);
+ this.checkAndHandleLandedTetrimino();
+ }
+ if(this.cursors.down.isDown && this.moveCounter % 5 == 0) {
+ this.setTetriminoOnBoard(0);
+ if(!this.hasLanded())
+ this.currentTetrimino.y+=this.blockSize;
+ this.setTetriminoOnBoard(2);
+ if(this.hasLanded()) {
+ this.landTetrimino();
+ }
+ }
+ if(Phaser.Input.Keyboard.JustDown(this.cursors.up) && !this.hasLanded()) {
+ this.setTetriminoOnBoard(0);
+ this.rotate();
+ this.setTetriminoOnBoard(2);
+ }
+ if(Phaser.Input.Keyboard.JustDown(this.cursors.space)) {
+ while(!this.hasLanded()) {
+ this.currentTetrimino.y +=this.blockSize;
+ }
+ this.landTetrimino();
+ }
+ }
+
+checkAndHandleLandedTetrimino() {
+ if(this.hasLanded()) {
+ this.setTetriminoOnBoard(0);
+ this.landTetrimino();
+ }
+}
+
+isMoveValid(direction) {
+ let moveValid = true;
+ this.currentTetrimino.blocks.forEach((block)=>{
+ const x = Math.floor((this.currentTetrimino.x+block.x*this.blockSize)/this.blockSize);
+ const y = Math.floor((this.currentTetrimino.y+block.y*this.blockSize)/this.blockSize);
+ if(this.gameBoard[y][x+direction]===1 || (x+direction)<0 || (x+direction)>9) moveValid = false;
+ });
+ return moveValid;
+}
+setTetriminoOnBoard(value) {
+ this.currentTetrimino.blocks.forEach((block)=>{
+ const x = Math.floor((this.currentTetrimino.x+block.x*this.blockSize)/this.blockSize);
+ const y = Math.floor((this.currentTetrimino.y+block.y*this.blockSize)/this.blockSize);
+ if(x>=0 && x<10 && y>=0 && y<20) {
+ this.gameBoard[y][x] = value;
+ }
+ });
+}
+
+hasLanded() {
+ for(let block of this.currentTetrimino.blocks) {
+ const x = Math.floor((this.currentTetrimino.x+block.x*this.blockSize)/this.blockSize);
+ const y = Math.floor((this.currentTetrimino.y+block.y*this.blockSize)/this.blockSize);
+ if(y>=19) {
+ return true;
+ }
+ if(y<20 && x<10 && this.gameBoard[y+1][x]===1) {
+ return true;
+ }
+ }
+ return false;
+}
+landTetrimino() {
+ this.setTetriminoOnBoard(1);
+ this.replaceTetriminoWithBlocks();
+ this.checkLines();
+ this.spawnTetrimino();
+}
+ replaceTetriminoWithBlocks() {
+ for(let block of this.currentTetrimino.blocks) {
+ let x = this.currentTetrimino.x+block.x*this.blockSize;
+ let y = this.currentTetrimino.y+block.y*this.blockSize;
+ let blockSprite = this.physics.add.image(x,y,"block-"+this.currentTetriminoType);
+ blockSprite.setOrigin(0,0);
+ blockSprite.setScale(0.5);
+ this.physics.world.enable(blockSprite);
+ let i = Math.floor(y/this.blockSize);
+ let j = Math.floor(x/this.blockSize);
+ this.blockSprites[i][j] = blockSprite;
+ }
+ this.currentTetrimino.destroy();
+ this.currentTetrimino = null
+ }
+ checkLines() {
+ let linesToRemove = [];
+ let completedTweenCount = 0;
+ for (let i=19;i>=0;i--){
+ if(this.gameBoard[i].every((cell)=>cell === 1)) {
+ for (let j=0;j<10;j++) {
+ let blockSprite = this.blockSprites[i][j];
+ if(blockSprite!==null) {
+ this.lineClear.play();
+ this.tweens.add({
+ targets:blockSprite,
+ alpha:0,
+ ease:"Power1",
+ duration:50,
+ yoyo:true,
+ repeat:3,
+ onComplete:() => {
+ blockSprite.destroy();
+ completedTweenCount++;
+ if(completedTweenCount === linesToRemove.length*10) {
+ this.updateScoreAndLevel(linesToRemove);
+ this.shiftBlocks(linesToRemove);
+ }
+ },
+ });
+ this.blockSprites[i][j] = null;
+ }
+ }
+ this.gameBoard[i] = new Array(10).fill(0);
+ linesToRemove.push(i);
+ }
+ }
+ }
+ shiftBlocks(linesToRemove) {
+ for(let line of linesToRemove.reverse()){
+ for(let k=line;k>=1;k--) {
+ for(let j=0;j<10;j++) {
+ this.blockSprites[k][j] = this.blockSprites[k-1][j];
+ if(this.blockSprites[k][j]!==null) {
+ this.blockSprites[k][j].y+= this.blockSize;
+ }
+ }
+ this.gameBoard[k] = [...this.gameBoard[k-1]];
+ }
+ this.gameBoard[0] = new Array(10).fill(0);
+ this.blockSprites[0] = new Array(10).fill(null);
+ }
+ }
+
+ updateScoreAndLevel(linesToRemove) {
+ let linesCleared = linesToRemove.length;
+ if(linesCleared>0) {
+ let scores = [0,40,100,300,1200];
+ score+=scores[linesCleared]*level;
+ scoreNumber.innerText = score;
+ lines+=linesCleared;
+ linesNumber.innerText = lines;
+ level = Math.floor(lines/10+1);
+ this.moveInterval = Math.max(3,60/Math.pow(2,Math.floor((level-1)/3)));
+ levelNumber.innerText = level;
+ }
+ }
+}
+
+const config = {
+ type: Phaser.AUTO,
+ width:320,
+ height:640,
+ parent: "boardContainer",
+ physics: {
+ default:"arcade",
+ arcade: {
+ gravity:{y:0},
+ debug:false,
+ },
+ },
+ scene:[TetrisScene],
+};
+
+window.game = new Phaser.Game(config);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Games/Tetris_Game/style.css b/Games/Tetris_Game/style.css
new file mode 100644
index 0000000000..6f31b315d7
--- /dev/null
+++ b/Games/Tetris_Game/style.css
@@ -0,0 +1,103 @@
+body {
+ display: flex;
+ justify-content: center;
+}
+.container {
+ display: flex;
+ justify-content: center;
+ background-color: #000000d9;
+ padding: 20px;
+ width: 800px;
+}
+#boardContainer {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ border:10px solid lightgray;
+ border-radius: 5px;
+ margin-left:140px
+}
+.displayContainer {
+ display: flex;
+ height: 600px;
+ flex-direction: column;
+ margin-left: 10px;
+}
+.score {
+ display: flex;
+ border: 8px solid lightgray;
+ margin: 10px;
+ margin-top:0;
+ margin-bottom: 0;
+ padding: 10px;
+ font-family: fantasy;
+ font-size: 30px;
+ color: #63f319;
+ justify-content: space-between;
+}
+.nextTetrimino {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ width: 210px;
+ height: 120px;
+ border:10px solid lightgray;
+ margin: 10px;
+ margin-top:0px;
+ padding: 10px;
+ border-radius: 5px;
+}
+.nextTetrimino img {
+ scale: 0.5;
+}
+.titleContainer {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ width: 210px;
+ height: 110px;
+ border:10px solid lightgray;
+ margin:10px;
+ padding: 10px;
+ border-radius: 5px;
+}
+.titleContainer img {
+ width: 100%;
+}
+
+#endGameContainer {
+ position: absolute;
+ display: none;
+ width: 300px;
+ height: 260px;
+ justify-content: space-between;
+ align-items: center;
+ flex-direction: column;
+ align-items: center;
+ background-color: #109d76;
+ color: white;
+ border: 5px solid lightgray;
+ border-radius: 5px;
+ font-size: xx-large;
+ font-family: fantasy;
+}
+#scoreContainer {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ width: 250px;
+ height: 80px;
+ border:5px solid lightgrey;
+ border-radius: 5px;
+}
+#gameMessage {
+ margin-top: 20px ;
+}
+#startGame {
+ width: 70px;
+ cursor: pointer;
+}
+#buttonContainer {
+ margin-bottom: 5px;
+}
\ No newline at end of file
diff --git a/README.md b/README.md
index 624620560c..49508fe155 100644
--- a/README.md
+++ b/README.md
@@ -330,10 +330,12 @@ This repository also provides one such platforms where contributers come over an
|[Color The Page](https://github.com/kunjgit/GameZone/tree/main/Games/Color_The_Page)|
|[AquaSort_Game](https://github.com/kunjgit/GameZone/tree/main/Games/AquaSort_Game) |
| [Snake](https://github.com/kunjgit/GameZone/tree/main/Games/snake) |
+| [Tetris Game](https://github.com/kunjgit/GameZone/tree/main/Games/tetris_game)|
|[Chess_Game_computer](https://github.com/kunjgit/GameZone/tree/main/Games/Chess_Game_computer) |
|[Turn_on_the_light](https://github.com/kunjgit/GameZone/tree/main/Games/Turn_on_the_light) |
+
| [Tic-Tac-Toe Game](https://github.com/kunjgit/GameZone/tree/main/Games/Tic-Tac-Toe) |
| [Rapid_click_frenzy](https://github.com/kunjgit/GameZone/tree/main/Games/Rapid_click_frenzy) |
| [Dsa_quiz_game](https://github.com/kunjgit/GameZone/tree/main/Games/Dsa_quiz_game) |
@@ -341,6 +343,9 @@ This repository also provides one such platforms where contributers come over an
| [Anagarm-Word-Game](https://github.com/kunjgit/GameZone/tree/main/Games/Anagarm-Word-Game) |
| [Alphabet-and-Vowels](https://github.com/kunjgit/GameZone/tree/main/Games/Alphabet-and-Vowels) |
| [Taash_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Taash_Game)|
+
+
+
| [Brick Buster Game](https://github.com/kunjgit/GameZone/tree/main/Games/Brick%20Buster) |
| [Rapid_click_frenzy](https://github.com/kunjgit/GameZone/tree/main/Games/Rapid_click_frenzy) |
| [Penguins Can't Fly](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Penguins_Can't_Fly) |
@@ -356,6 +361,7 @@ This repository also provides one such platforms where contributers come over an
|[Harmony_Mixer](https://github.com/kunjgit/GameZone/tree/main/Games/Harmony_Mixer)|
+
diff --git a/assets/images/black.png b/assets/images/black.png
new file mode 100644
index 0000000000..6600bbe424
Binary files /dev/null and b/assets/images/black.png differ