Skip to main content

Dependencies

This package depends on the following libraries:

  • numpy (BSD)
  • moderngl (MIT)
  • pygame (LGPL)

Pygame is used for graphics, and is not modified in this package. Please see Pygame's license: LGPL v2.1.

To use gamengine2d, You must first use the Engine class

from gamengine2d import Engine, Color, Rectangle, vector2d # import the Engine Rectangle, vector2d, and Color classes

engine = Engine(width=500, height=500,           # Create the Engine object that opens a window of height 500, width 500,
                name="GamEngine2d Demo", resizable=True,  # name GamEngine2d Demo, and make the window resizable,
                background_color=Color.blue)   # set the background color to blue

# By default, the name is GamEngine2d, resizable is True, and the background color is Color.black

rect = Rectangle(pos=vector2d(0, 0), size=vector2d(100, 400),  # Create a rectangle at 0, 0, with size 100, 400,
                 color=Color.red, rotation=10, visible=True,   # and color red, and rotation 10 degrees, and make it visible,
                 name="MyRect")                                # and name it MyRect

# By default, the position is 0, 0, size is 40, 40, color is Color.white, rotation is 0, visible is True, and name is rectangle

engine.add_object(rect) # add the rectangle object to the engine

engine.run(60, dynamic_view=True) # start the engine, and try to run at 60 fps, and dynamic view is True

# dynamic view allows the user to use the mouse wheel to zoom in or out, or left click and drag to pan around.
# by default, fps is 60, and dynamic view is True

To add a script to an object, use attach.

rect.attach("scripts/rectangle.py", engine.context) # attach the script rectangle.py to the rect object with the engine context

Then, in scripts/rectangle.py

class Rectangle: # The class name should be the same as the filename
    def __init__(self, obj, context): # get the object, and the engine context
        self.obj = obj # assign self.obj to obj
        self.context = context # assign self.context to context
    
    def update(self, dt): # the update method is called every frame, and takes dt which is delta time
        self.obj.rotation += 10 * dt # rotate the object at 10 degrees per second
        self.context.functions.draw_text(text=str(self.obj.rotation), # Draw the current rotation as text
                                         pos=vector2d(400, 300),      # at 400, 300
                                         color=Color.red,           # in red
                                         font_size=18)                # with font size 18

# By default, font_size is 18

the 3D version of this package is out under the name gamengine3d.

Check out the full documentation for this package here: Package Docs

Release files for gamengine2d 2.22.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gamengine2d 2.22.2
File Size Uploaded
gamengine2d-2.22.2.tar.gz 17.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gamengine2d 2.22.2
File Interpreter ABI Platform
gamengine2d-2.22.2-py3-none-any.whl Python 3 none any Details

Total release size: 36.1 kB

Release files / gamengine2d-2.22.2.tar.gz

Download URL gamengine2d-2.22.2.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
81ea653627de7260b0ede4b8333256efb87869fa58e8d901404af9959be0a0b4
BLAKE2b-256 checksum
How to use checksums
cc411f75fb24d83ab6bda608b7edbb156f722c70ed7ede204b34249f31ec967f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release files / gamengine2d-2.22.2-py3-none-any.whl

Download URL gamengine2d-2.22.2-py3-none-any.whl
Size 18.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7fe71e6091d5b3bbbb9294b6694b7b09565d85eed30c608edfa86244863bff6b
BLAKE2b-256 checksum
How to use checksums
b6f89c7bac46c9d855c88c561e1f3aa0da7117d6900cc9fdc0a7137118991f19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

2.22.2 This release

2 release files

2.22.1

2 release files

2.22.0

2 release files

2.21.3

2 release files

2.21.2

2 release files

2.18.0

2 release files

2.16.0

2 release files

2.15.1

2 release files

2.15.0

2 release files

2.14.0

2 release files

2.13.0

2 release files

2.12.7

2 release files

2.12.6

2 release files

2.12.5

2 release files

2.12.0

2 release files

2.11.5

2 release files

2.11.1

2 release files

2.11.0

2 release files

2.10.9

2 release files

2.10.8

2 release files

2.10.7

2 release files

2.10.6

2 release files

2.10.5

2 release files

2.10.0

2 release files

2.9.1

2 release files

2.9.0

2 release files

2.8.2

2 release files

2.8.1

2 release files

2.8.0

2 release files

2.7.0

2 release files

2.6.0

2 release files

2.5.2

2 release files

2.5.1

2 release files

2.5.0

2 release files

2.4.2

2 release files

2.4.1

2 release files

2.4.0

2 release files

2.3.5

2 release files

2.3.4

2 release files

2.3.3

2 release files

2.3.2

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page