블로그 이미지
Leeway is... the freedom that someone has to take the action they want to or to change their plans.
maetel

Notice

Recent Post

Recent Comment

Recent Trackback

Archive

calendar

1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
  • total
  • today
  • yesterday

Category

2007. 6. 20. 12:01 Code/NodeBox
class를 사용하여 ping_multi 코딩하기

class Ping:
    def __init__(self, x, y, vx, vy):
        self.x=x
        self.y=y
        self.vx=vx
        self.vy=vy
       
    def render(self):
        c=0.001
        r=1.1
       
        ax=-self.vx*c
        ay=-self.vy*c
        self.vx+=ax
        self.vy+=ay
        self.x+=self.vx
        self.y+=self.vy
               
        if (self.x>=WIDTH):
            self.vx*=-r
            self.x=WIDTH
           
        if (self.x<=0):
            self.vx*=-r
            self.x=0
           
        if (self.y>=HEIGHT):
            self.vy*=-r
            self.y=HEIGHT
           
        if (self.y<=0):
            self.vy*=-r
            self.y=0
                       
        oval(self.x, self.y, 20, 20)
   
       
size(300,300)
speed(100)   
   
def setup():
    global particle
   
    particle=range(5)
    for i in range(5):
        particle[i]=Ping(i*20+150,i*5+150,i*5+1, i*5+1)
        #print particle[i]
   
       
def draw():
    global particle
           
    for i in particle:
        print i
        i.render()


'Code > NodeBox' 카테고리의 다른 글

orbit  (0) 2007.06.20
particle(rect+oval)_class  (0) 2007.06.20
ping_multi  (0) 2007.06.18
ping  (0) 2007.06.18
splash  (0) 2007.06.17
posted by maetel