A library or so we can call an "engine" for Python's Pygame, our beloved game-making library for python users. Main purpose is to add must-have features for a game engine to ease the use.
This engine is still on developments and being updated often. Please do not hesitate to contribute and add your own flavour.
This project is MIT licensed.
The directory engine/core is the main library. After you clone or download the repository, you can add the it to your project. A more thorough setup will be added soon.
Beware that used Python version of this project is 3.8.3 and the used Pygame version is 2.0.1.
Pygame itself does not provide any sorts of UI Elements more than a label that does not have any function. In the ui_elements.py you can find the essential UI elements; texts, buttons with just texts or images and input boxes with core functionalities for adjusting and aligning.
There will be a multi-line supporting input box after fixing some certain bugs.
"will be added soon"
An animation library, to change a value asyncronously. It's currently being refactored and the new version will be presented soon.
A render manager for updating and rendering all objects in one function in every scene. Once you register an object, it will rendered every time render method is called, until it is removed from the render manager. While registering, the user could specify the z-index to decide the depth of the element while rendering.
This section represents the practices used by the developers.
The file that is used to create the root of the game and to run it. You can mainly create your Game class instance here and run the game by initializing the first scene.
Mainly used to hold all the constants and static values in one place that will be used across the project. It's important not to import modules that could cause circular import error.
A sincere suggestion is to create a script for all classes that will derive from Scene. A basic Scene looks like this:
from scene import Scene
from renderer import RenderManager
from ui_elements import Button, ProcessElements
import pygame, defaults
class MenuScene(Scene):
def __init__(self, main_surface):
Scene.__init__(main_surface)
self.render_manager = RenderManager(main_surface, background_color=(80, 80, 80))
self.BUTTONS = [Button(main_surface, x=10, y=10), Button(main_surface, x=100, y=100)]
self.render_manager.register_all(self.BUTTONS)
def process_input(self, events: list, pressed_keys, mouse_pos: tuple) -> None:
ProcessElements(events, pressed_keys, mouse_pos, self.BUTTONS)
def update(self, delta_time: int) -> None:
pass
def render(self) -> None:
self.render_manager.render()