Introduction

Ggame is not intended to be a full-featured gaming API, with every bell and whistle. It 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.

Functionality Goals

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

"""
Trivial example of a minimal ggame App with Sprite.
"""
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()

Extensions

Ggame is being extended for geometry exploration in a manner reminiscent of Geogebra, digital logic simulation, and with tools and classes to use with rocket and orbital simulations.

Overview

There are three major pieces in a ggame app: assets, sprites and the app itself.

Assets

Asset objects (i.e. ImageAsset, etc.) typically represent separate files that are provided by the “art department”. These might be background images, user interface images, or images that represent objects in the game. In addition, SoundAsset are used to represent sound files (.wav or .mp3 format) that can be played in the game.

Ggame also extends the asset concept to include graphics that are generated dynamically at run-time, such as geometrical objects, e.g. rectangles, lines, etc.

Sprites

All of the visual aspects of the game are represented by instances of Sprite or subclasses of it.

App

Every ggame application must create a single instance of the App class (or a sub-class of it). Create an instance of the App class to draw a graphics canvas in your browser window. Execute the app’s run() method to start refreshing and redrawing the visual assets on the screen.

Events

No game is complete without a player and players make events. Your code handles user input by registering to receive keyboard and mouse events using listenKeyEvent() and listenMouseEvent() methods of the App class.

Execution Environment

Ggame is designed to execute in a web browser using Brython, Pixi.js and Buzz. The easiest way to do this is by executing from runpython, with your source code stored at github. When you use ggame from within runpython, the Github ggame repository is automatically placed on the import search path.

Geometry

When referring to screen coordinates, note that the x-axis of the computer screen is horizontal with the zero position on the left hand side of the screen. The y-axis is vertical with the zero position at the top of the screen.

Increasing positive y-coordinates correspond to the downward direction on the computer screen. Note that this is different from the way you may have learned about x and y coordinates in math class!