2007. 6. 18. 01:32
Code/NodeBox
size(300,300)
speed(100)
def setup():
global x
global y
global vx
global vy
x=150 #initial position
y=150
vx=10 #initial velocity
vy=15
def draw():
global x
global y
global vx
global vy
c=0.01 #viscosity
r=1.1 #repulsive force
ax=-vx*c
ay=-vy*c
vx+=ax
vy+=ay
x+=vx
y+=vy
if (x>WIDTH):
vx*=-r
x=WIDTH
if (x<0):
vx*=-r
x=0
if (y>HEIGHT):
vy*=-r
y=HEIGHT
if (y<0):
vy*=-r
y=0
oval(x,y,20,20)
speed(100)
def setup():
global x
global y
global vx
global vy
x=150 #initial position
y=150
vx=10 #initial velocity
vy=15
def draw():
global x
global y
global vx
global vy
c=0.01 #viscosity
r=1.1 #repulsive force
ax=-vx*c
ay=-vy*c
vx+=ax
vy+=ay
x+=vx
y+=vy
if (x>WIDTH):
vx*=-r
x=WIDTH
if (x<0):
vx*=-r
x=0
if (y>HEIGHT):
vy*=-r
y=HEIGHT
if (y<0):
vy*=-r
y=0
oval(x,y,20,20)
'Code > NodeBox' 카테고리의 다른 글
ping_class (0) | 2007.06.20 |
---|---|
ping_multi (0) | 2007.06.18 |
splash (0) | 2007.06.17 |
progress (0) | 2007.06.14 |
range() (0) | 2007.06.14 |