rem #####################################################
rem #     Program : hotpot
rem # 
rem #      Author : Marc Gale (xalthorn)
rem #
rem # Description : Just a small, flaming pot
rem #
rem #####################################################

gosub initialise
gosub draw_bowl
gosub main_loop
exit

label main_loop
 repeat
  gosub move_flame
  gosub new_line
  buttons=peek("port1")
 until (and(buttons,16384)>0)
return

label draw_bowl
 for a=20 to 1 step -1
  setrgb 1,255-a*10,0,0
  fill circle sw/2+3,sh/2+6,a
 next a
return

label new_line
 for a=1 to 10
  b=int(ran(fw/2))+11
  s=255
  flamebuf(b*fh)=s
  setrgb 1,s,s*0.5,0
  dot fx+b,fy
 next a
return

label move_flame
 for y=0 to fh-1
  for x=0 to fw-1
   col=flamebuf(x*fh+y)
   col=col-10
   setrgb 1,col,col*0.5,0
   xo=int(ran(4))-1
   xx=x+xo
   if xx>=fw then xx=xx-2 fi
   if xx<0 then xx=x fi
   dot fx+xx,fy-y
   flamebuf(xx*fh+y+1)=col
   dot fx+xx,fy-y-1
  next x
 next y
return

label initialise
 sw=640
 sh=512

 fw=30
 fh=25
 fx=sw/2-fw/2
 fy=sh/2-fh/2

 dim flamebuf(fw*fh)
 for a=1 to fw*fh
  flamebuf(a)=0
 next a

 open window sw,sh
 clear window
return






