Skip to content
Arnaud Dupuis edited this page Oct 9, 2022 · 14 revisions

Welcome to the pygamelib wiki!

🚧 This is a work in progress! 🚧

Quick links:

Migration notes

In every versions, some breaking changes might be introduced and some changes may need a bit more explanation than the release notes are giving. Here you can find a list of the migration notes from a version to the next.

Tutorials

Beginners / new programmers

These tutorials aims at honing freshly acquired coding skills through the pygamelib. They also serves as introduction the the library itself.

Getting started:

  1. Installation and getting ready to code
  2. The board
  3. The Game object
  4. Actionable items

Intermediate

Here we are taking it up a notch: game logic and more advanced mechanisms.

  1. Howto: Create a Font

Advanced

In this section we have the more advanced tutorials. Taking on problems like implementing gravity or more complex game mechanics.

Other links

Discord

We have a Discord server were you can ask your questions or discuss the library: https://discord.gg/ZtVaMqr.

API documentation

The API documentation is published on ReadTheDocs:
https://pygamelib.readthedocs.io/

Video tutorials

TODO

What is the pygamelib

Background

The pygamelib was initially developed as a support for coding lessons given to kids. Python was an obvious choice for the simplicity of its syntax and graphics programming being too hard for kids, terminal display was all we had at hand.

To keep kids motivated, the lure of video game development was a strong drive. And so the hac-game-lib was born (hac stands for Hyrule Astronomy Club, the name of our little science club). At first it was a simplistic library to make things like display a map or moving a character easy.

Later, with kids getting better and better the library was improved with more features. It was then released on pypi so the kids can easily install it and share their creations.

Finally, with more and more people using it (outside of ourselves) and contributors starting to... well contribute patches, it was decided to give it a better name. And so the pygamelib was born.

It was only after all the changes were published along with version 1.2.0 that I realized the possible confusion with the pygame framework...

Current project

The pygamelib is now a reasonably featured framework to write console/terminal games. The 1.2.0 version broke some stuff (see the migration notes) but it was a requirement to pave the way for the next cycle of development.

The library retains its simple roots with the ability to do fun stuff with very little code. But it also allow for more advanced things and particularly with graphics and game logic.

The next release cycle (1.3.x) will bring tons of new features and improvements. From an easier to manage screen to many improvements in the graphics stack it will be an important milestone for the project.

Main features

The pygamelib is a python module that follows object oriented programing (OOP) principles. If you don't know what OOP is, it is a way of programing that allows for high re-use of the same code. For example, a wheel has core characteristics (it's round, has a tire, etc.) that can be tweaked to make a different wheel (the width, the type of tire, etc.). In OOP you will only code what a wheel is at its core, and let the properties (radius, depth, etc.) be tuned by the user to make new wheels.

The library is divided in big modules that can be used and imported (almost) independently (sort of...):

  • engine: holds the core objects like Board, Game or Screen.
  • board_items: holds all the objects that can be placed on a board (Player, NPC, Walls, etc.)
  • actuators: holds all the movement and behavior actuators to give life to the NPCs. This is were you will find the ability to give path finding powers to your NPCs for example.
  • constants: as its name suggests, it holds all the constants of the library.
  • base: holds all the base objects like Vector2D, Text (rich text class), Math (game related math functions), etc.
  • assets: the module where to look for pre-made assets (like models for your objects).
  • gfx: last but not least, the graphics module that contains all the objects related to graphics and their manipulation.

On top of that, the library offers a board editor (pgl-editor) as well as a tool to test your boards without the needs to write any code (pgl-board-tester).

The pygamelib is also designed with scale in mind. It scales with the student's abilities to code. It tries to achieve that by having sensible default values for most objects so they can be used without much configuration or coding. But with more programing skills it offers a wide variety of possibilities.

It is mainly a library that handles the computation and checks required to create any virtual worlds. But it has some nice helpers for the beginners:

  • Complete map creation and management. Based on the Board object it handles everything from characters movements to graphics and collisions.
  • Inventory system. The Inventory object provides a full featured inventory out of the box.
  • Game management. The Game object provide all sort of features that helps run the game. It does a lot of things for the developer (actuate objects like NPC or Projectiles, animations, inputs, etc.) so the developer can focus on actual game mechanics.
  • Lots of "graphical assets" are packaged with the library. Being terminal based, we are talking about UTF8 characters here (box drawing, geometric characters and emojis).
  • The ability to create "advanced console graphics" through the Sprite and Sprixel classes.
  • Boards (i.e maps) and sprites can be stored and loaded from files. The file format is JSON. Performances are sacrificed here to favor readability and interoperability. This is a conscious decision so developers apprentices can look at the file format and tinker with it. Maybe even come up with awesome tools for the community.
  • And much more!