2007. 7. 6. 16:50
Code/NodeBox
mission: 마우스가 정지해 있을 때 popping 효과 제거하기
size(400,400)
speed(15)
def setup():
global mx
global my
global t
global x0
global y0
global x1
global y1
global x2
global y2
global x3
global y3
global x4
global y4
global x5
global y5
global x6
global y6
global x7
global y7
global d
global s
global r
global u
global p
t=20 #term
mx=range(t)
my=range(t)
for n in range(t+1):
mx[n]=-WIDTH
my[n]=-HEIGHT
x0=range(t)
y0=range(t)
x1=range(t)
y1=range(t)
x2=range(t)
y2=range(t)
x3=range(t)
y3=range(t)
x4=range(t)
y4=range(t)
x5=range(t)
y5=range(t)
x6=range(t)
y6=range(t)
x7=range(t)
y7=range(t)
u=range(t)
p=range(t)
d=20 #distance
s=3 #initial size
r=0.99 #ratio of size decreasing
def draw():
global mx
global my
global t
global x0
global y0
global x1
global y1
global x2
global y2
global x3
global y3
global x4
global y4
global x5
global y5
global x6
global y6
global x7
global y7
global d
global s
global r
global u
global p
background(0,0,1)
fill(1)
for i in range(t-1):
mx[i]=mx[i+1]
my[i]=my[i+1]
mx[t-1]=MOUSEX
my[t-1]=MOUSEY
rectc(mx[i],my[i],s,s)
for i in range(t):
u[i]=(t-i)*2 ##to controll the stages of popping
p[i]=-i ##to controll the sizes of popping
if (i>=1) & ((mx[i]-mx[i-1])==0):
u[i]=0
x0[i]=mx[i]+u[i]
y0[i]=my[i]
x1[i]=mx[i]+u[i]
y1[i]=my[i]+u[i]
x2[i]=mx[i]
y2[i]=my[i]+u[i]
x3[i]=mx[i]-u[i]
y3[i]=my[i]+u[i]
x4[i]=mx[i]-u[i]
y4[i]=my[i]
x5[i]=mx[i]-u[i]
y5[i]=my[i]-u[i]
x6[i]=mx[i]
y6[i]=my[i]-u[i]
x7[i]=mx[i]+u[i]
y7[i]=my[i]-u[i]
rectc(x0[i], y0[i], s*(r**p[i]),s*(r**p[i]))
rectc(x1[i], y1[i], s*(r**p[i]),s*(r**p[i]))
rectc(x2[i], y2[i], s*(r**p[i]),s*(r**p[i]))
rectc(x3[i], y3[i], s*(r**p[i]),s*(r**p[i]))
rectc(x4[i], y4[i], s*(r**p[i]),s*(r**p[i]))
rectc(x5[i], y5[i], s*(r**p[i]),s*(r**p[i]))
rectc(x6[i], y6[i], s*(r**p[i]),s*(r**p[i]))
rectc(x7[i], y7[i], s*(r**p[i]),s*(r**p[i]))
def rectc(xc,yc,w,h):
x=xc-w/2
y=yc-h/2
rect(x,y,w,h)
range의 범위를 초과하지 않기 위한 삽입 조건 "i>=1"에 의해 i=1일 때의 상이 남는다.
현재, mx와 my등의 range를 t에서 t+1로 변경하여 적용하는 방법을 시도 중이다.
중략하고 아래와 같이...
그러자, 아예 전체적으로 popping 효과가 사라져 버린다. orz
speed(15)
def setup():
global mx
global my
global t
global x0
global y0
global x1
global y1
global x2
global y2
global x3
global y3
global x4
global y4
global x5
global y5
global x6
global y6
global x7
global y7
global d
global s
global r
global u
global p
t=20 #term
mx=range(t)
my=range(t)
for n in range(t+1):
mx[n]=-WIDTH
my[n]=-HEIGHT
x0=range(t)
y0=range(t)
x1=range(t)
y1=range(t)
x2=range(t)
y2=range(t)
x3=range(t)
y3=range(t)
x4=range(t)
y4=range(t)
x5=range(t)
y5=range(t)
x6=range(t)
y6=range(t)
x7=range(t)
y7=range(t)
u=range(t)
p=range(t)
d=20 #distance
s=3 #initial size
r=0.99 #ratio of size decreasing
def draw():
global mx
global my
global t
global x0
global y0
global x1
global y1
global x2
global y2
global x3
global y3
global x4
global y4
global x5
global y5
global x6
global y6
global x7
global y7
global d
global s
global r
global u
global p
background(0,0,1)
fill(1)
for i in range(t-1):
mx[i]=mx[i+1]
my[i]=my[i+1]
mx[t-1]=MOUSEX
my[t-1]=MOUSEY
rectc(mx[i],my[i],s,s)
for i in range(t):
u[i]=(t-i)*2 ##to controll the stages of popping
p[i]=-i ##to controll the sizes of popping
if (i>=1) & ((mx[i]-mx[i-1])==0):
u[i]=0
x0[i]=mx[i]+u[i]
y0[i]=my[i]
x1[i]=mx[i]+u[i]
y1[i]=my[i]+u[i]
x2[i]=mx[i]
y2[i]=my[i]+u[i]
x3[i]=mx[i]-u[i]
y3[i]=my[i]+u[i]
x4[i]=mx[i]-u[i]
y4[i]=my[i]
x5[i]=mx[i]-u[i]
y5[i]=my[i]-u[i]
x6[i]=mx[i]
y6[i]=my[i]-u[i]
x7[i]=mx[i]+u[i]
y7[i]=my[i]-u[i]
rectc(x0[i], y0[i], s*(r**p[i]),s*(r**p[i]))
rectc(x1[i], y1[i], s*(r**p[i]),s*(r**p[i]))
rectc(x2[i], y2[i], s*(r**p[i]),s*(r**p[i]))
rectc(x3[i], y3[i], s*(r**p[i]),s*(r**p[i]))
rectc(x4[i], y4[i], s*(r**p[i]),s*(r**p[i]))
rectc(x5[i], y5[i], s*(r**p[i]),s*(r**p[i]))
rectc(x6[i], y6[i], s*(r**p[i]),s*(r**p[i]))
rectc(x7[i], y7[i], s*(r**p[i]),s*(r**p[i]))
def rectc(xc,yc,w,h):
x=xc-w/2
y=yc-h/2
rect(x,y,w,h)
range의 범위를 초과하지 않기 위한 삽입 조건 "i>=1"에 의해 i=1일 때의 상이 남는다.
현재, mx와 my등의 range를 t에서 t+1로 변경하여 적용하는 방법을 시도 중이다.
mx=range(t+1)
my=range(t+1)
for i in range(t):
mx[i-1]=mx[i]
my[i-1]=my[i]
mx[t]=MOUSEX
my[t]=MOUSEY
rectc(mx[i+1],my[i+1],s,s)
my=range(t+1)
for i in range(t):
mx[i-1]=mx[i]
my[i-1]=my[i]
mx[t]=MOUSEX
my[t]=MOUSEY
rectc(mx[i+1],my[i+1],s,s)
중략하고 아래와 같이...
if (mx[i+1]-mx[i])==0:
u[i]=0
u[i]=0
그러자, 아예 전체적으로 popping 효과가 사라져 버린다. orz
'Code > NodeBox' 카테고리의 다른 글
progress_class (0) | 2007.07.12 |
---|---|
popping_1.1 (0) | 2007.07.09 |
popping_0.0 (0) | 2007.07.06 |
storing_test (0) | 2007.07.05 |
pop_test (0) | 2007.07.05 |