61 lines
2.2 KiB
Markdown
61 lines
2.2 KiB
Markdown
Pygame Framework
|
|
================
|
|
|
|
PGFW is a game framework that facilitates the creation and development of [Pygame][] projects. It contains a class `Game` which can be inherited and used as a project skeleton. There are classes for features such as sprites, animations, audio, b-splines, geometry, and screen capture. It is a collection of code used in previous projects with a focus on creating 2D games. Some examples of games using it are [Picture Processing][], [Scrapeboard][], and [Cakefoot][].
|
|
|
|
Requirements
|
|
------------
|
|
|
|
* Python 3+
|
|
* [Pygame][] 1.9+
|
|
|
|
Start a project
|
|
---------------
|
|
|
|
Clone the repository (or [download](https://open.shampoo.ooo/shampoo/pgfw/archive/main.zip) and unzip it)
|
|
|
|
git clone https://open.shampoo.ooo/shampoo/pgfw
|
|
|
|
Save the following script at the root of the repository to create a project that redraws a square at a random location every second. The project can be run with `python3 [SCRIPT]`. Maybe some cats may even like this game. This script is also available in [sample.py][].
|
|
|
|
from time import sleep
|
|
from random import randint
|
|
|
|
from pgfw.Game import Game
|
|
|
|
class SampleGame(Game):
|
|
|
|
square_width = 30
|
|
|
|
# instructions in the update method automatically run once every frame
|
|
def update(self):
|
|
sleep(1)
|
|
screen = self.get_screen()
|
|
bounds = screen.get_size()
|
|
screen.fill((0, 0, 0))
|
|
screen.fill((255, 255, 255),
|
|
(randint(0, bounds[0]), randint(0, bounds[1]),
|
|
self.square_width, self.square_width))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
SampleGame().run()
|
|
|
|
To further build this example, the [Pygame API][] and classes in [pgfw/][] could be imported and used directly in the update function.
|
|
|
|
License
|
|
-------
|
|
|
|
Unrestricted use, under the zlib license, see [LICENSE.txt][]
|
|
|
|
![Pygame powered](https://www.pygame.org/docs/_static/pygame_powered.png)
|
|
|
|
[Pygame]: https://pygame.org
|
|
[Pygame API]: https://www.pygame.org/docs
|
|
[Picture Processing]: https://ohsqueezy.itch.io/ppu
|
|
[Scrapeboard]: https://scrape.nugget.fun
|
|
[Cakefoot]: https://ohsqueezy.itch.io/cakefoot
|
|
[sample.py]: sample.py
|
|
[pgfw/]: pgfw/
|
|
[LICENSE.txt]: LICENSE.txt
|