Post by Scott B on Jan 24, 2006 16:48:35 GMT -5
const ScreenWidth = 640
const ScreenHeight = 480
const nops = 200 ' Number of points in an explosion
const dis = 10 ' Distance of motion blur
const noexps = 10 ' Number of explosions
dim xbuffer#(dis)(nops)(noexps)
dim ybuffer#(dis)(nops)(noexps)
dim intensity#(dis)(nops)(noexps)
dim lite#(noexps)(nops)
dim xpts#(noexps)(nops)
dim ypts#(noexps)(nops)
dim angs(noexps)(nops)
dim explode(noexps)
dim counter(noexps)
dim times(noexps)(nops)
dim st(noexps)(nops)
dim et(noexps)(nops)
dim t1(noexps)(nops)
dim accel#(noexps)(nops)
dim vel#(noexps)(nops)
const speed = 1
dim xcntr(noexps),ycntr(noexps)
dim choice
dim x,y
dim h,i,j
dim n
dim e
dim red(noexps),green(noexps),blue(noexps)
dim r,g,b
glMatrixMode (GL_PROJECTION)
glLoadIdentity ()
glOrtho (0, ScreenWidth, 0, ScreenHeight, 0, .1)
glMatrixMode (GL_MODELVIEW)
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
glEnable (GL_BLEND)
glEnable (GL_POINT_SMOOTH)
glPointsize(3)
glClearColor(0,0,0,1)
' Initialization
for h = 1 to noexps
gosub refresh
next
while true
glClear (GL_COLOR_BUFFER_BIT)
glBegin (GL_POINTS)
for j = 1 to noexps
if counter(j) > explode(j) then
for h = 1 to dis
for i = 1 to nops
if xbuffer#(h)(i)(j) = 0 and ybuffer#(h)(i)(j) = 0 then goto skip1: endif
glColor4f (red(j),green(j),blue(j),intensity#(h)(i)(j))
glVertex2f (xbuffer#(h)(i)(j),ybuffer#(h)(i)(j))
skip1:
next
next
endif
next
glEnd ()
SwapBuffers ()
for j = 1 to noexps
if counter(j) > explode(j) then
for h = 1 to dis - 1
for i = 1 to nops
xbuffer#(h)(i)(j) = xbuffer#(h+1)(i)(j)
ybuffer#(h)(i)(j) = ybuffer#(h+1)(i)(j)
intensity#(h)(i)(j) = intensity#(h+1)(i)(j) - .1
next
next
endif
next
for i = 1 to noexps
if counter(i) > explode(i) then
for j = 1 to nops
xpts#(i)(j) = xcntr(i) + cosd(angs(i)(j)) * (times(i)(j) * speed)
ypts#(i)(j) = ycntr(i) + sind(angs(i)(j)) * (times(i)(j) * speed)
if t1(i)(j) > st(i)(j) then gosub move endif
if times(i)(j) > et(i)(j) then goto skip2 endif
xbuffer#(dis)(j)(i) = xpts#(i)(j)
ybuffer#(dis)(j)(i) = ypts#(i)(j)
intensity#(dis)(j)(i) = lite#(i)(j)
goto skip3
skip2:
xbuffer#(dis)(j)(i) = 0
ybuffer#(dis)(j)(i) = 0
skip3:
next
endif
next
for h = 1 to noexps
if counter(h) > explode(h) then
n = 1
for i = 1 to nops
t1(h)(i) = t1(h)(i) + 1
if times(h)(i) > et(h)(i) then n = n + 1 endif
if n = nops then gosub refresh endif
next
endif
next
for h = 1 to noexps
counter(h) = counter(h) + 1
next
wend
move:
accel#(i)(j) = accel#(i)(j) + .01
vel#(i)(j) = vel#(i)(j) + accel#(i)(j)
ypts#(i)(j) = ypts#(i)(j) - vel#(i)(j)
times(i)(j) = times(i)(j) + 1
return
refresh:
explode(h) = int(rnd() % 100)
counter(h) = 0
x = int(rnd() % ScreenWidth)
y = int(rnd() % ScreenHeight)
choice = int(rnd() % 7) + 1
if choice = 1 then r = 1: g = 0: b = 0: endif
if choice = 2 then r = 0: g = 1: b = 0: endif
if choice = 3 then r = 0: g = 0: b = 1: endif
if choice = 4 then r = 1: g = 1: b = 0: endif
if choice = 5 then r = 0: g = 1: b = 1: endif
if choice = 6 then r = 1: g = 0: b = 1: endif
if choice = 7 then r = 1: g = 1: b = 1: endif
xcntr(h) = x
ycntr(h) = y
red(h) = r
green(h) = g
blue(h) = b
for i = 1 to nops
lite#(h)(i) = 1
angs(h)(i) = int(rnd() % 360)
st(h)(i) = int(rnd() % 100)
et(h)(i) = int(rnd() % 100)
accel#(h)(i) = 0
vel#(h)(i) = 0
times(h)(i) = 0
t1(h)(i) = 0
next
return
const ScreenHeight = 480
const nops = 200 ' Number of points in an explosion
const dis = 10 ' Distance of motion blur
const noexps = 10 ' Number of explosions
dim xbuffer#(dis)(nops)(noexps)
dim ybuffer#(dis)(nops)(noexps)
dim intensity#(dis)(nops)(noexps)
dim lite#(noexps)(nops)
dim xpts#(noexps)(nops)
dim ypts#(noexps)(nops)
dim angs(noexps)(nops)
dim explode(noexps)
dim counter(noexps)
dim times(noexps)(nops)
dim st(noexps)(nops)
dim et(noexps)(nops)
dim t1(noexps)(nops)
dim accel#(noexps)(nops)
dim vel#(noexps)(nops)
const speed = 1
dim xcntr(noexps),ycntr(noexps)
dim choice
dim x,y
dim h,i,j
dim n
dim e
dim red(noexps),green(noexps),blue(noexps)
dim r,g,b
glMatrixMode (GL_PROJECTION)
glLoadIdentity ()
glOrtho (0, ScreenWidth, 0, ScreenHeight, 0, .1)
glMatrixMode (GL_MODELVIEW)
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
glEnable (GL_BLEND)
glEnable (GL_POINT_SMOOTH)
glPointsize(3)
glClearColor(0,0,0,1)
' Initialization
for h = 1 to noexps
gosub refresh
next
while true
glClear (GL_COLOR_BUFFER_BIT)
glBegin (GL_POINTS)
for j = 1 to noexps
if counter(j) > explode(j) then
for h = 1 to dis
for i = 1 to nops
if xbuffer#(h)(i)(j) = 0 and ybuffer#(h)(i)(j) = 0 then goto skip1: endif
glColor4f (red(j),green(j),blue(j),intensity#(h)(i)(j))
glVertex2f (xbuffer#(h)(i)(j),ybuffer#(h)(i)(j))
skip1:
next
next
endif
next
glEnd ()
SwapBuffers ()
for j = 1 to noexps
if counter(j) > explode(j) then
for h = 1 to dis - 1
for i = 1 to nops
xbuffer#(h)(i)(j) = xbuffer#(h+1)(i)(j)
ybuffer#(h)(i)(j) = ybuffer#(h+1)(i)(j)
intensity#(h)(i)(j) = intensity#(h+1)(i)(j) - .1
next
next
endif
next
for i = 1 to noexps
if counter(i) > explode(i) then
for j = 1 to nops
xpts#(i)(j) = xcntr(i) + cosd(angs(i)(j)) * (times(i)(j) * speed)
ypts#(i)(j) = ycntr(i) + sind(angs(i)(j)) * (times(i)(j) * speed)
if t1(i)(j) > st(i)(j) then gosub move endif
if times(i)(j) > et(i)(j) then goto skip2 endif
xbuffer#(dis)(j)(i) = xpts#(i)(j)
ybuffer#(dis)(j)(i) = ypts#(i)(j)
intensity#(dis)(j)(i) = lite#(i)(j)
goto skip3
skip2:
xbuffer#(dis)(j)(i) = 0
ybuffer#(dis)(j)(i) = 0
skip3:
next
endif
next
for h = 1 to noexps
if counter(h) > explode(h) then
n = 1
for i = 1 to nops
t1(h)(i) = t1(h)(i) + 1
if times(h)(i) > et(h)(i) then n = n + 1 endif
if n = nops then gosub refresh endif
next
endif
next
for h = 1 to noexps
counter(h) = counter(h) + 1
next
wend
move:
accel#(i)(j) = accel#(i)(j) + .01
vel#(i)(j) = vel#(i)(j) + accel#(i)(j)
ypts#(i)(j) = ypts#(i)(j) - vel#(i)(j)
times(i)(j) = times(i)(j) + 1
return
refresh:
explode(h) = int(rnd() % 100)
counter(h) = 0
x = int(rnd() % ScreenWidth)
y = int(rnd() % ScreenHeight)
choice = int(rnd() % 7) + 1
if choice = 1 then r = 1: g = 0: b = 0: endif
if choice = 2 then r = 0: g = 1: b = 0: endif
if choice = 3 then r = 0: g = 0: b = 1: endif
if choice = 4 then r = 1: g = 1: b = 0: endif
if choice = 5 then r = 0: g = 1: b = 1: endif
if choice = 6 then r = 1: g = 0: b = 1: endif
if choice = 7 then r = 1: g = 1: b = 1: endif
xcntr(h) = x
ycntr(h) = y
red(h) = r
green(h) = g
blue(h) = b
for i = 1 to nops
lite#(h)(i) = 1
angs(h)(i) = int(rnd() % 360)
st(h)(i) = int(rnd() % 100)
et(h)(i) = int(rnd() % 100)
accel#(h)(i) = 0
vel#(h)(i) = 0
times(h)(i) = 0
t1(h)(i) = 0
next
return