A drawing and physics engine for Pygame
Project description
Phoenyx - Pygame Engine v0.2.1
Some simple classes in python that could make your life much simplier. Relies on pygame and numpy, based on the idea of the Processing language.
Get the latest stable version using pip with
pip install phoenyx
.
What it does
This library allows you to create graphical components in pygame in a very few lines of code. It handles all color management, stroke weights and filling for you. It also provides a Vector and a SanBox class suitable for physics engines and more mathematical drawings.
Please go and check pygame for their amazing work ! Additionnal kudos to Daniel Shiffman.
How to ?
Please refer to the examples folder on GitHub for very simple but effective test files. You can now also read the helpme file for all available methods and objects.
from phoenyx import *
renderer: Renderer = Renderer(600, 600, "collision")
sandbox: SandBox = SandBox(renderer, 290, 290)
b1: Body
b2: Body
b3: Body
def reset() -> None:
global b1, b2, b3
b1.reset()
b2.reset()
b3.reset()
def setup() -> None:
global b1, b2, b3
renderer.create_menu("options", background=False, color=255, text_color=255, reset=reset)
b1 = sandbox.new_body(300, 100, 1, 10)
b2 = sandbox.new_body(290, 80, 1, 10)
b3 = sandbox.new_body(310, 60, 1, 10)
sandbox.set_gravity(y=.5)
renderer.set_background(51)
renderer.text_size = 15
renderer.text_color = 255
def draw() -> None:
global b1, b2, b3
sandbox.update()
sandbox.show()
renderer.text(10, 10, f"fps : {round(renderer.fps)}")
if __name__ == "__main__":
renderer.run(draw, setup=setup)
Requirements
Obviously some distribution of python : python 3.9
or above is required.
You will also need pygame
in order to use the Renderer and numpy
to use Vectors. To upgrade to a more recent version of any lib, run pip install --upgrade ...
. Requirements will automatically be met with pip when installing phoenyx.
Licenses
Phoenyx is licensed under the GPLv3. See LICENSE for more details. Phoenyx also includes the following components from other open source projects (see LICENSES folder for more) :
- numpy licensed under the BSD 3-Clause "New" or "Revised" License
- pygame licended under the GNU LGPL version 2.1
Changelog
Please refer to the changelog file for the full history.
The 0.2.0 update featured the new SandBox class, allowing you to create a physics world for Bodies to interract and move around in very few lines of code. This update targets the Renderer class and fixes some drawing methods as well as introduces new ones.
v0.2.1 : some other more drawings
- some bug fixes for the Renderer and Vector (point stroke color not used, rect and square position unpacking, reset_matrix not reseting rotation, use of the Callable class for clarity, equality tests and representation for vectors)
- new scaling method for the renderer, old method still available, scaling happens (as always for these new methods) relatively to the axes origin ; note that the stroke weight is not affected by scale
- new drawing method to draw arcs ; note that the rect for arcs (as well as for ellipses) does not rotate
- alternate method to apply background every time through draw
- alternate wrap method (there is no real wrap method irl is there ?)
- changed the gravity setting method of the SandBox
TODOs
option to hide buttons and sliders or to draw them only when neededoption of alts drawing methods for buttonskeyboard integration- scrollbars
and side menus interractive drawingphysics Sandbox- more physics happening for bodies
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.