Skip to content

Latest commit

 

History

History
99 lines (62 loc) · 2.83 KB

File metadata and controls

99 lines (62 loc) · 2.83 KB

Tetromino Game

Aim

The main aim of the project is to create a game using pygame module.

Purpose

The purpose of this project is to give fun for the users.

Short description of package/script

  • If standalone script, short description of script explaining what it achieves.

Differently shaped blocks (each made up of four boxes) fall from the top of the screen, and the player must guide them down to form complete rows that have no gaps in them. When a complete row is formed, the row disappears and each row above it moves down one row. The player tries to keep forming complete lines until the screen fills up and a new falling block cannot fit on the screen.

  • List out the libraries imported.

    • Pygame
    • Time
    • Sys
    • Random

Workflow of the Project

  • Importing the required modules.
  • Setting up Timing Constants for Holding Down Keys
  • Setting Up the Piece Templates [Symbols shape]
  • Splitting a “Line of Code” Across Multiple Lines
  • The main() Function for running the game
  • The Start of a New Game function
  • The Game Loop and Event Handling Loop
  • Pausing the Game for blocks falling
  • Using Movement Variables to Handle User Input
  • Checking if a Slide or Rotation is Valid
  • Finding the Bottom function
  • Moving by Holding Down the Key
  • Letting the Piece “Naturally” Fall
  • Drawing Everything on the Screen
  • makeTextObjs(), A Shortcut Function for Making Text
  • The Same Old terminate() Function
  • Waiting for a Key Press Event with the checkForKeyPress() Function
  • showTextScreen(), A Generic Text Screen Function
  • The checkForQuit() Function
  • The calculateLevelAndFallFreq() Function
  • Generating Pieces with the getNewPiece() Function
  • Adding Pieces to the Board Data Structure
  • Creating a New Board Data Structure
  • The isOnBoard() and isValidPosition() Functions
  • Checking for, and Removing, Complete Lines
  • Convert from Board Coordinates to Pixel Coordinates
  • Drawing a Box on the Board or Elsewhere on the Screen
  • Drawing Everything to the Screen
  • Drawing the Score and Level Text
  • Drawing a Piece on the Board or Elsewhere on the Screen
  • Drawing the “Next” Piece

Setup instructions

Install python 2.8 or above version.

Install prerequisite module - pip install pygame

Now your system is ready to use.

Compilation Steps

Download the tetromino_game.py

Download the sounds for background music.

Extract the file

Double click the code and start playing.

Output

Author(s)

Rammya Dharshini K

Disclaimers, if any

None