Guest User

Untitled

a guest
Dec 12th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. class People(object):
  2. def __init__(self,c,xpos,ypos,speed,xgoal,ygoal):
  3. self.c=c
  4. self.xpos=xpos
  5. self.ypos=ypos
  6. self.speed=speed
  7. self.xgoal=xgoal
  8. self.ygoal=ygoal
  9.  
  10.  
  11. def show(self):
  12. #stroke(0)
  13. fill(self.c)
  14. rectMode(CENTER)
  15. rect(self.xpos,self.ypos,20,10)
  16.  
  17. def drive(self):
  18. self.xpos=self.xpos + (self.xgoal - self.xpos)*0.05 * self.speed
  19. self.ypos=self.ypos + (self.ygoal - self.ypos)*0.05 * self.speed
  20.  
  21. person1=People(color(255,0,0),35,280,1,120,10)
  22. person2=People(color(0,255,0),60,280,1,300,15)
  23.  
  24. def setup():
  25. size(450,320)
  26.  
  27.  
  28. def draw():
  29. person1.show()
  30. person1.drive()
  31. person2.show()
  32. person2.drive()
Add Comment
Please, Sign In to add comment