Skip to content

mozartilize/tetris

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tetris

screenshot

Installation

This game is made of python3 and pygame.

Install via pip:

$ pip install git+git://github.com/mozartilize/tetris.git

Then run it in terminal to play:

$ tetris

Usage

- Rotate shape

- Move shape to right

- Move shape to left

- Go down faster

F9 - Pause

Credits

This repo is built upon this pygame tutorial.

The original_tetris.py source code is credit to the tutorial.

Notes

  • This game is an improvement from the tutorial which reduces CPU usage from 22% to 8% (tested on my computer) by:

    • Change logic for check_lost which only check for positions of the latest shape.
    • Reduce for loop in grid by tracking grid's available positions used in valid_space and grid#update.
    • Draw only changed parts on pygame's surface.
    • Take advantage of python's generator.
    • And some other minor optimizations.
  • Game pause was added.