Coder Social home page Coder Social logo

pygameengine's Introduction

PyGameEngine

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.

License

This project is MIT licensed.

Setup

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.

It Consists...

User Interface Elements

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.

Scene Management System

"will be added soon"

Animation

An animation library, to change a value asyncronously. It's currently being refactored and the new version will be presented soon.

Renderer

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.

Other Practices Used By The Author

This section represents the practices used by the developers.

main.py

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.

defaults.py

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.

Scene Scripting

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()

pygameengine's People

Contributors

erthium avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.