A repository for short pygame drafts, examples, tutorials and more!
Currently, this repository contains a draft lighting system, a particle system, a networked game, a hexogonal tile system, a cloth simulation and other cool pygame examples.
To get a copy of this repository, simply open up git bash in an empty folder and use the command:
$ git clone https://github.com/rbaltrusch/pygame_examples
Dependencies can be installed using the requirements.txt as below:
pip install -r requirements.txt
To run some of the examples, navigate to the respective folder in the code folder, then run main.py.
This repository contains the following small pygame examples:
- Particle system: contains a simple, but effective, particle system implementation.
- Evolution simulation: contains a simple simulation of evolving animals hunting for food.
- Cloth simulation: contains a cloth simulation with custom physics.
- Conway's game of life: contains a simulation of Conway's game of life.
- Game console: contains a minimal implementation of an in-game console.
- Animation testing tool: can be used to test out animations. Contains a fully featured in-game console with a decoupled and flexible design.
- Networked game: contains a minimal implementation of a networked game, featuring one external server and two separate clients, communicating with each other through the server.
- Dynamic lighting: contains a small draft implementation for dynamic in-game lighting.
- Hexagonal grid: contains an implementation of a hexagonal grid, including collision handling.
- Tidy event queue: contains an exercise in decoupling complex pygame event handling constructs into separate parts.
- Async events: contains an example implementation for an asynchronous event handler (useful for writing linear-looking code for events with execution spread out over multiple game cycles).
- Squish and stretch: contains an example implementation of squishing and stretching an image.
- Timed events: contains an implementation of callbacks executed after a specified delay. Not pygame-specific.
- Random starry sky: generates a random starry sky.
To contribute to this repository, please read the contribution guidelines.
Written in Python 3.8.3.
This repository is open-source software available under the MIT license.
Please raise an issue for code changes. To reach out, please send an email to richard@baltrusch.net.