Cant get object to work in processing.py

Sorry new to Processing and trying to build a wall with different sized bricks, at the basic stage of creating a brick class this doesn’t produce anything when I run it and I can’t work out why…!

class Brick(object):
def init(self, xpos, ypos, width_, height_):
self.xpos = xpos
self.ypos = ypos
self.width_ = width_
self.height_ = height_

def display(self):
    strokeWeight(5)
    stroke(255,0,0)
    fill(255)
    rect(self.xpos, self.ypos, 20,10)

Brick1 = Brick(100,100,20,10)

def setup():
size(300, 300)
noLoop()

def draw():
background(0,204,0)
display.Brick1()

Object goes 1st, and then its method: Brick1.display()

BtW, variables & methods by convention should use lowerCase names:

brick = Brick(100, 100, 20, 10)
brick.display()
5 Likes