Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class People(object):
- def __init__(self,c,xpos,ypos,speed,xgoal,ygoal):
- self.c=c
- self.xpos=xpos
- self.ypos=ypos
- self.speed=speed
- self.xgoal=xgoal
- self.ygoal=ygoal
- def show(self):
- #stroke(0)
- fill(self.c)
- rectMode(CENTER)
- rect(self.xpos,self.ypos,20,10)
- def drive(self):
- self.xpos=self.xpos + (self.xgoal - self.xpos)*0.05 * self.speed
- self.ypos=self.ypos + (self.ygoal - self.ypos)*0.05 * self.speed
- person1=People(color(255,0,0),35,280,1,120,10)
- person2=People(color(0,255,0),60,280,1,300,15)
- def setup():
- size(450,320)
- def draw():
- person1.show()
- person1.drive()
- person2.show()
- person2.drive()
Add Comment
Please, Sign In to add comment