# BoxMaker.py

from Processing import *
window(500, 500)

# Contains all objects that have been created
boxes = []

rectMode(CENTER)

# A class to create a simple Box
class Box:
    # Constructor that initializes position
    def __init__(self, x, y):
        self.x = x
        self.y = y

    # This method advances the state of the object
    def step(self):
        pass

    # This method draws the object in its current state
    def display(self):
        fill(200)
        rect(self.x, self.y, 20, 20)

# Create a new box and add to the master list
def createBox(o, e):
    x, y = mouseX(), mouseY()
    b = Box( x, y )
    boxes.append( b )

# Draw all boxes
def draw(o, e):
    background(0)
    for b in boxes:
        b.step()
        b.display()

# Create a new box whenever the mouse is clicked
onMousePressed += createBox

# Draw all
frameRate(20)
onLoop += draw
loop()
