Skip to content

wolfjpy/toy_snake_game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terminal-based Toy Snake Game

I spent a couple of off-work hours to create this toy snake game from scratch. Enjoy!

Python Coding Skills

A list of selected coding skills demonstrated in the source code.

Note:

  • yapf and black are good python formatters too.

OOP Design

A list of selected OOP design demonstrated in the source code.

  • Class / Object
  • Abstraction
  • Abstracted class / Interface
  • Encapsulation
  • Composition
  • Inheritance
  • Delegation
  • Polymorphism
  • UnitTest
  • Test-driven Development
  • MVC (Model-View-Controller)
  • SOLID guidelines

Note:

  • Extensibility:

    • Easy change game/render engine, e.g. implement Drawable interface.
    • Easy add more game elements, e.g. create more snakes objects, more foods objects, and any shape of the walls in game World object.
    • Easy customized game logic, e.g. create another Logic class in logic module.
  • Robustness:

    • UnitTest
    • Clearly separate Model, View, and Controller.

Installation

Python version: 3.7

Install pipenv (https://docs.pipenv.org/, highly recommended) first if you haven't.

Create Python 3.7 virtualenv, activiate it, install dependencies.

pipenv --python 3.7
pipenv shell
pipenv install

Run Game

Make sure virtualenv is activated by pipenv shell from above.

Go to source code directory, run main entry point. Have fun!

cd toy_snake_game
python game.py