Coders Packet

Tetris Game Using Python

By Ganesh Dinkarrao Kulkarni

I have created a Tetris game using Python. The Player's goal is to continually stack boxes and clear lines. If the player runs out of space then the game is over.

I have created a Tetris game using Python. For this program, users have to install Python and pygame libraries on their machine. It can run on any IDEs like pycharm, vs code, and command prompt also.  

Instructions to play Tetris game:

This is a simple game.

1.First understand the pattern of boxes coming from upside.

2.You have to move the boxes in specific ways.

3.If you run out of space then the game will over.`


Here we have to import 2 libraries from Python which are as follows:

1.import pygame

2.import random

1.import pygame: For installing this module, open a command prompt and type pip install pygame, and press enter, your module will download.

       It is a cross-platform set of Python modules that are used to create video games

       This module is used in game development, media applications, etc.

       It consists of computer graphics and sound libraries which will used with the Python programming language.

       I have created a 10*20 square grid for playing games. I have created 6 shapes that we can use to fill our square grid.

       These blocks are in different alphabetical shapes namely S, Z, I, O, J, L, T.


2.import random: It is a built-in module of Python so doesn't need installation.

   This module is used to generate random variables.

   This module can be used to get any random output.

   It can shuffle elements randomly, can generate integers, floats, etc.


Download Complete Code


No comments yet