Skip to main content

build passing

ggame

The simple sprite and game platform for Brython Server (Pygame, Tkinter to follow?).

Ggame stands for a couple of things: "good game" (of course!) and also "git game" or "github game" because it is designed to operate with Brython Server in concert with Github as a backend file store.

Ggame is not intended to be a full-featured gaming API, with every bell and whistle. Ggame is designed primarily as a tool for teaching computer programming, recognizing that the ability to create engaging and interactive games is a powerful motivator for many progamming students. Accordingly, any functional or performance enhancements that can be reasonably implemented by the user are left as an exercise.

Please visit the detailed documentation page for ggame. This is generated automatically from the ggame sources.

Functionality Goals

The ggame library is intended to be trivially easy to use. For example:

from ggame import App, ImageAsset, Sprite
# Create a displayed object at 100,100 using an image asset
Sprite(ImageAsset("bunny.png"), (100,100))
# Create the app, with a default stage
app = App()
# Run the app
app.run()

Another Example

The following example illustrates the more common use case in which the basic ggame classes, Sprite and App, are subclassed as Bunny and DemoApp and given event handlers and step (i.e. poll) functions.

from ggame import App, ImageAsset, Sprite, MouseEvent
from random import random, randint

class Bunny(Sprite):

    asset = ImageAsset("bunny.png")

    def __init__(self, position):
        super().__init__(Bunny.asset, position)
        # register mouse events
        App.listenMouseEvent(MouseEvent.mousedown, self.mousedown)
        App.listenMouseEvent(MouseEvent.mouseup, self.mouseup)
        App.listenMouseEvent(MouseEvent.mousemove, self.mousemove)
        self.dragging = False


    def step(self):
        """
        Every now and then a bunny hops...
        """
        if random() < 0.01:
            self.x += randint(-20,20)
            self.y += randint(-20,20)


    def mousedown(self, event):
        # capture any mouse down within 50 pixels
        self.deltax = event.x - (self.x + self.width//2)
        self.deltay = event.y - (self.y + self.height//2)
        if abs(self.deltax) < 50 and abs(self.deltay) < 50:
            self.dragging = True
            # only drag one bunny at a time - consume the event
            event.consumed = True

    def mousemove(self, event):
        if self.dragging:
            self.x = event.x - self.deltax - self.width//2
            self.y = event.y - self.deltay - self.height//2
            event.consumed = True

    def mouseup(self, event):
        if self.dragging:
            self.dragging = False
            event.consumed = True


class DemoApp(App):

    def __init__(self):
        super().__init__()
        for i in range(10):
            Bunny((randint(50,self.width),randint(50,self.height)))

    def step(self):
        """
        Override step to perform action on each frame update
        """
        for bunny in self.spritelist:
            bunny.step()


# Create the app
app = DemoApp()
# Run the app
app.run()

Installing ggame

Before using ggame with your Python source repository on Github, you may add the ggame source tree to your repository. If you are executing your code in http://runpython.com, then the current ggame repository is already added to your import search path and no installation is required.

Contributing to ggame

Environment

Set up the development environment with Python 3.11.

Create a virtual environment with venv and activate it:

$ python3.11 -m venv env
$ source env/bin/activate

Install the requirements:

$ python3.11 -m pip install -r requirements-headless.txt

Test your environment by running the tests:

$ scripts/run_tests.sh

Code Quality

Python sources in ggame should be passed through black. For example:

$ black ggame/app.py

Python sources should also be tested with pylint. For example:

$ python3.11 -m pylint -r n ggame/app.py

You can perform all of these checks in concert with a full Sphinx build by executing the script:

$ scripts/run_tests.sh

Metadata

Release files for ggame 1.1.3

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

Source distribution (sdist)

Source distribution for ggame 1.1.3
File Size Uploaded Provenance
ggame-1.1.3.tar.gz 227.8 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 460.0 kB

Release files / ggame-1.1.3.tar.gz

Download URL ggame-1.1.3.tar.gz
Size 227.8 kB
Tags Source
SHA-256 checksum
How to use checksums
91aef9169d85df070ff16481756da3f35a4b7484334a74049da0a86cca634c2b
BLAKE2b-256 checksum
How to use checksums
5a1e3a2f14f5bc907cab77c39a037e85763f54c5c6609dfb25ffe5f9b2f4d548
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / ggame-1.1.3-py3-none-any.whl

Download URL ggame-1.1.3-py3-none-any.whl
Size 232.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
37eb2969f3b43a2fdee20cd8317df795907dbf6b68275ffc200ec4a5b2182843
BLAKE2b-256 checksum
How to use checksums
5d2b2136dd659a5b8b7289e3a0d7dc91f4b67c1b9fb37119630a95a1c4ba9ff8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Security for ggame 1.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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