rem Fire
rem copyright Marc Gale (Xalthorn) 2001
rem
rem a simple fire effect

gosub initialise
gosub main_loop
exit

label main_loop
 repeat
  gosub flip_screen
  clear window

  gosub draw_motes

  buttons=peek("port1")

 until (and(buttons,16384)>0)
return

label draw_motes
 for a=1 to nummotes
  xpos=motes(a,1)
  ypos=motes(a,2)
  strength=motes(a,3)

  setrgb 1,strength+55,strength,0
  dot xpos,ypos

  strength=strength-2
  if strength<=0 then
   motes(a,1)=sw/2+int(ran(10))
   motes(a,2)=sh/2
   motes(a,3)=int(ran(100))+100
  else
   motes(a,1)=xpos+int(ran(3))-1
   motes(a,2)=ypos-1
   motes(a,3)=strength
  fi
 next a
return

label flip_screen
 setdispbuf curbuf 
 curbuf=1-curbuf
 setdrawbuf curbuf
return

label initialise
 sw=640
 sh=512
 curbuf=0
 nummotes=180

 dim motes(nummotes,3)
 rem 1=x
 rem 2=y
 rem 3=strength

 for a=1 to nummotes
  motes(a,1)=sw/2+int(ran(10))
  motes(a,2)=(sh/2)
  motes(a,3)=int(ran(100))
 next a

 open window sw,sh
 clear window
return





