This is an even more minimalist version of my minimalist game framework. It uses Python 3 and pygame.
A few decisions have been made to keep things simple:
Getting started with the ultra-minimalist game framework is easy!
import game to the top of your script.game module to create your game.All functions and enums listed below are members of the game module. If you wanted to draw a line, you would call game.draw_line() from your code.
If you don't already have pygame installed, you can install it by running pip install pygame on the command line.

import game
import random
IMG_FACE_NORMAL = 'eJxjiObgZBAFAygFAoxghAcwIkvD9AMA4AgFsQßß'
IMG_FACE_HIT = 'eJxjiObgZBAFAygFAoxghAmYgACThukHAND6BPUß'
game.set_title('Bouncing Faces')
class Face:
def __init__(self):
self.x = random.randint(1, 141)
self.y = random.randint(1, 90)
self.vx = random.uniform(-1, 1)
self.vy = random.uniform(-1, 1)
faces = []
for i in range(0, 20):
faces.append(Face())
while True:
# Move the faces:
for face in faces:
if face.x <= 0 or face.x >= 142:
face.vx *= -1
if face.y <= 0 or face.y >= 91:
face.vy *= -1
face.x += face.vx
face.y += face.vy
# Draw the screen:
game.clear_screen(game.Color.GRAY_DARKER)
for face in faces:
# Draw the face, using an alternate sprite if it's overlapping any other face:
sprite = IMG_FACE_NORMAL
for otherFace in faces:
if face != otherFace and game.test_sprites(IMG_FACE_NORMAL, face.x, face.y, IMG_FACE_NORMAL, otherFace.x, otherFace.y):
sprite = IMG_FACE_HIT
break
game.draw_sprite(sprite, face.x, face.y)
# Draw a box around the face when it's hovered, and beep when it's clicked:
if game.test_sprite(sprite, face.x, face.y, game.get_mouse_x(), game.get_mouse_y()):
game.draw_rect(game.Color.WHITE, face.x - 2, face.y - 2, 12, 13, False)
if game.is_mouse_down(game.Button.LEFT):
game.play_sound(game.Instrument.SQUARE, game.Note.C4, 0.2)
# End of frame:
game.wait_for_frame()
def wait_for_frame()
def wait_for_seconds(duration: float)
def wait_for_close()
def wait_for_input(prompt: str) -> str
def set_title(title: str)
def clear_screen(color: Color)
def draw_pixel(color: Color, x: int, y: int)
def draw_line(color: Color, x1: int, y1: int, x2: int, y2: int)
def draw_rect(color: Color, x: int, y: int, width: int, height: int, fill: bool)
def draw_circle(color: Color, x: int, y: int, radius: int, fill: bool)
def draw_triangle(color: Color, x1: int, y1: int, x2: int, y2: int, x3: int, y3: int, fill: bool)
def draw_text(text: str, color: Color, x: int, y: int, alignment: Alignment) -> tuple[int, int]
def draw_sprite(sprite: str, x: int, y: int)
def test_rect(x: int, y: int, width: int, height: int, test_x: int, test_y: int) -> bool
def test_circle(x: int, y: int, radius: int, test_x: int, test_y: int) -> bool
def test_sprite(sprite: str, x: int, y: int, test_x: int, test_y: int) -> bool
def test_sprites(sprite1: str, x1: int, y1: int, sprite2: str, x2: int, y2: int) -> bool
def play_sound(instrument: Instrument, note: Note, duration: float, delay: float = 0.0, volume: float = 1.0)
duration and delay are measured in seconds.volume is from 0 (silent) to 1 (maximum volume).def is_key_down(key: Key) -> bool
def is_key_held(key: Key) -> bool
def is_key_up(key: Key) -> bool
def get_typed_text() -> str
def get_mouse_x() -> int
def get_mouse_y() -> int
def is_mouse_down(button: Button) -> bool
def is_mouse_held(button: Button) -> bool
def is_mouse_up(button: Button) -> bool
def set_cursor_visible(visible: bool)
class Color (Enum)
Color.TRANSPARENTColor.BLACKColor.GRAY_DARKERColor.GRAY_DARKColor.GRAYColor.GRAY_LIGHTColor.GRAY_LIGHTERColor.WHITEColor.BLUE_DARKColor.PURPLE_DARKColor.PINK_DARKColor.RED_DARKColor.ORANGE_DARKColor.YELLOW_DARKColor.GREEN_DARKColor.MINT_DARKColor.BLUEColor.PURPLEColor.PINKColor.REDColor.ORANGEColor.YELLOWColor.GREENColor.MINTColor.BLUE_LIGHTColor.PURPLE_LIGHTColor.PINK_LIGHTColor.RED_LIGHTColor.ORANGE_LIGHTColor.YELLOW_LIGHTColor.GREEN_LIGHTColor.MINT_LIGHTclass Alignment (Enum)
Alignment.LEFTAlignment.CENTERAlignment.RIGHTclass Instrument (Enum)
Instrument.SQUAREInstrument.PULSEInstrument.TRIANGLEInstrument.SAWTOOTHInstrument.NOISEclass Note (Enum)
Note.C6Note.B5Note.ASHARP5Note.A5Note.GSHARP5Note.G5Note.FSHARP5Note.F5Note.E5Note.DSHARP5Note.D5Note.CSHARP5Note.C5Note.B4Note.ASHARP4Note.A4Note.GSHARP4Note.G4Note.FSHARP4Note.F4Note.E4Note.DSHARP4Note.D4Note.CSHARP4Note.C4Note.B3Note.ASHARP3Note.A3Note.GSHARP3Note.G3Note.FSHARP3Note.F3Note.E3Note.DSHARP3Note.D3Note.CSHARP3Note.C3Note.B2Note.ASHARP2Note.A2Note.GSHARP2Note.G2Note.FSHARP2Note.F2Note.E2Note.DSHARP2Note.D2Note.CSHARP2Note.C2Note.B1Note.ASHARP1Note.A1Note.GSHARP1Note.G1Note.FSHARP1Note.F1Note.E1Note.DSHARP1Note.D1Note.CSHARP1Note.C1class Key (Enum)
Key.BACKSPACEKey.TABKey.CLEARKey.RETURNKey.PAUSEKey.ESCAPEKey.SPACEKey.EXCLAIMKey.QUOTEDBLKey.HASHKey.DOLLARKey.AMPERSANDKey.QUOTEKey.LEFTPARENKey.RIGHTPARENKey.ASTERISKKey.PLUSKey.COMMAKey.MINUSKey.PERIODKey.SLASHKey.NR_0Key.NR_1Key.NR_2Key.NR_3Key.NR_4Key.NR_5Key.NR_6Key.NR_7Key.NR_8Key.NR_9Key.COLONKey.SEMICOLONKey.LESSKey.EQUALSKey.GREATERKey.QUESTIONKey.ATKey.LEFTBRACKETKey.BACKSLASHKey.RIGHTBRACKETKey.CARETKey.UNDERSCOREKey.BACKQUOTEKey.AKey.BKey.CKey.DKey.EKey.FKey.GKey.HKey.IKey.JKey.KKey.LKey.MKey.NKey.OKey.PKey.QKey.RKey.SKey.TKey.UKey.VKey.WKey.XKey.YKey.ZKey.DELETEKey.KP_0Key.KP_1Key.KP_2Key.KP_3Key.KP_4Key.KP_5Key.KP_6Key.KP_7Key.KP_8Key.KP_9Key.KP_PERIODKey.KP_DIVIDEKey.KP_MULTIPLYKey.KP_MINUSKey.KP_PLUSKey.KP_ENTERKey.KP_EQUALSKey.UPKey.DOWNKey.RIGHTKey.LEFTKey.INSERTKey.HOMEKey.ENDKey.PAGEUPKey.PAGEDOWNKey.F1Key.F2Key.F3Key.F4Key.F5Key.F6Key.F7Key.F8Key.F9Key.F10Key.F11Key.F12Key.F13Key.F14Key.F15Key.NUMLOCKKey.CAPSLOCKKey.SCROLLOCKKey.RSHIFTKey.LSHIFTKey.RCTRLKey.LCTRLKey.RALTKey.LALTclass Button (Enum)
Button.LEFTButton.MIDDLEButton.RIGHT