The end result will be a battle-like environment. This means we need to be able to combine scripts of all the students into one coherent whole.

"Just put a try/catch block around it"
    -- Tom

Conventions

Code tries to map as close as possible to functional programming, meaning functions should have no side effects.

Ideally, functions should be seen as generators or modifiers, and only do one of the two.

We should be able to see what a modifier has modified or a generator has generated. This means that we would love to get delta-values out of the functions instead of real objects. We could use real objects and compare.

The delta-values are important because we might be able to animate or damp them.

path_from_points

from DrawingPrimitives import *
def path_from_points(pts):
    assert len(pts) > 1
    path = BezierPath(_ctx)
    path.moveto(pts[0].x, pts[0].y)
    for pt in pts[1:]:
        if isinstance(pt, PathElement) and pt.cmd == CURVETO:
            path.curveto(pt.ctrl1.x, pt.ctrl1.y, pt.ctrl2.x, pt.ctrl2.y, pt.x, pt.y)
        else:
            path.lineto(pt.x, pt.y)    
    path.inheritFromContext()
    return path

typing keys

speed(30)

def setup():
    global textline, lastframe
    textline = ""
    lastframe = -100
    
    
def draw():
    global textline, lastframe
    
    if keydown and FRAME - lastframe > 5:
        if keycode == 51: # backspace
            textline = textline[:-1]
        else:
            textline += key
        lastframe = FRAME
        
    text(textline, 10, 100)
   

typing keys (oo)

speed(30)

class Typer:
    def __init__(self):
        self.textline = ""
        self.lastframe = -100
        
    def update(self):
        if keydown and FRAME - self.lastframe > 5:
            if keycode == 51: # backspace
                self.textline = self.textline[:-1]
            else:
                self.textline += key
            self.lastframe = FRAME

def setup():
    global typer
    typer = Typer()
    
def draw():
    global typer
    
    typer.update()

        
    text(typer.textline, 10, 100)
Last update — 02 November 2026 14:20