Skip to main content

A small game development framework for teaching programming.

Project description

Linux: Ok Windows: Ok Mac OS: Ok GPLv3 license PRs Welcome Documentation Status CII Best Practices CircleCI codecov

pygamelib

A (not so) small library for terminal based game development.

Preemptive warning

Between version 1.1.1 and 1.2.0 the library was renamed from hac-game-lib to pygamelib and reworked to its core. So even though all the objects remains API compatible across versions, there is a bit of renaming to do in the imports.

Introduction

Historically, this library is used as a base to teach coding to kids from 6 to 15. It aims at giving an environment to new and learning developers (including kids) that let them focus on the algorithm instead of the lousy display or precise management.

It started as a very simple library with very little capabilities, but over time it became something more. To the point that it is now possible to make very decent games with it. So this is obviously still extremely simple compared to other game framework and it still does not aim at being anything serious for real game developers. However, it can now be used by aspiring game developers for an introduction to 2D games development.

There is a Youtube channel that contains tutorials.

suparex.py screenshot

Here is a quick view of what can currently be achieved with that library (base_game haven't been updated for a long time):

base_game.py animation

The base game makes use of:

  • The main "game engine" (pygamelib.engine.Game)
  • Many different types of structures (from pygamelib.board_items): Wall (well the walls...), Treasure (gems and money bag), GenericStructure (trees) and GenericActionnableStructure (hearts and portals)
  • Game()'s menu capabilities.
  • Player and NPC (from pygamelib.board_items)
  • Inventory (from pygamelib.engine.Inventory)
  • Player and Inventory stats
  • RandomActuator (NPCs in level 2) and PathActuator (NPCs in level 1) (from pygamelib.actuators.SimpleActuators)

For more up to date examples, have a look at:

Here is a poorly done gif of Suparex: Suparex animation

Strong points

Hopefully you'll find the pygamelib to have a lot of strong points:

  • It is simple. It requires very limited Python knowledge to start coding games.
  • Yet powerful offering more advanced programmers a lot of possibilities.
  • The possibilities scale up with the students offering basic feature and default values "good enough" for beginners and lots of tunning opportunities for the advanced coders.
  • Lots of stuff are available by default. Any idea how long it would take a beginner to display only a part of a board? 1 second with the pygamelib, probably slightly more if they had to do it by hand ;)
  • It is Terminal based. This means no graphics card dependencies, cross platform, and a framework that stimulate imagination and creativity.

Installation (recommended)

The easiest way to install a stable version is to use pypi:

pip3 install pygamelib

It will pull all dependencies

Installation from sources and requirements

Python

The pygamelib only supports Python 3.6+. It will not run with Python 2. We use pipenv to manage dependencies.

Run Pipenv to install the requirements:

pip3 install pipenv
pipenv install

If you want the development dependencies you need to run:

pip3 install pipenv
pipenv install --dev

Runing tests

To run the unit tests use the following command:

python -m unittest discover -s tests

Terminal color and emojis

It is not really a hard requirement but colored emojis are really bringing the games created to life.
We then recommend to have a color emojis font installed like Noto Color Emojis (on most Linux distributions you can install it from the package manager, search for "noto-color-emoji").

If your terminal application is not displaying color emojis, please have a look at this file and follow the instructions.

Running examples

To run the examples using pipenv:

pipenv shell
(pygamelib) cd examples/suparex
(pygamelib) python3 suparex.py

Limitations

There is tons of limitations but for the most important ones:

  • Only one player is supported.
  • There is little protections against messing up with the internal. This is on purpose, I want the kids to learn to use the API not mess up with the internals of every single class.
  • It's pure Python (it's slow).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygamelib-1.2.3.tar.gz (106.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygamelib-1.2.3-py3-none-any.whl (119.6 kB view details)

Uploaded Python 3

File details

Details for the file pygamelib-1.2.3.tar.gz.

File metadata

  • Download URL: pygamelib-1.2.3.tar.gz
  • Upload date:
  • Size: 106.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.8

File hashes

Hashes for pygamelib-1.2.3.tar.gz
Algorithm Hash digest
SHA256 2a495dd1d273371963e628d9cc00abd28810d44fa9359b5824d254e161482d46
MD5 f04b8a079a624902c0649dee1a52b13a
BLAKE2b-256 5067bfa36d70fd4e3954dd025c18e265ebba28c4a191efd0cca2fb7576bced72

See more details on using hashes here.

File details

Details for the file pygamelib-1.2.3-py3-none-any.whl.

File metadata

  • Download URL: pygamelib-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 119.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.8

File hashes

Hashes for pygamelib-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9407307bfd05cb9b96c0cc6d969add6aaa247b41d7ea3d6c69b69037c8815400
MD5 dc1b58bf29fecacd871cc2852fc145ca
BLAKE2b-256 aff83b4f415481a6be472083eb25775ffaa6f89bcfea453c5d1073f98b6773e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page