look on my code, i dont use point, i draw direct on the screen-memory. This is much faster.
Code: Select all
;#realx=1024:#realy=768
;#realx=800:#realy=600
;#realx=640:#realy=480
;#realx=512:#realy=384
;#realx=400:#realy=300
;#realx=320:#realy=240
#realx=320:#realy=200
;#realx=320:#realy=470-150
;#aufx=320:#aufy=200
;#aufx=640:#aufy=480
;#aufx=512:#aufy=384
;#aufx=400:#aufy=300
;#aufx=#realx:#aufy=#realy
;#aufx=479-100:#aufy=470-150
;#aufx=128:#aufy=128
#aufx=#realx : #aufy=#realy
#updown=1 ; 0 or 1 Calculate from up to down (1) or down to up (0)
#mouselen=100 ; waittime, before the old mousepoints are deleted
#hotspotadd=0 ; Change the brightness of the hotspots
#dodownmax=0 ; high of the flames (0=small 2=very big)
#downsub=3 ; dito+flicker (0=high flames, no flicker ,10=small high flicker)
text$="Set on Fire by GPI" ; the text ;""=nowtext
#line=1
Structure long
l.l
EndStructure
If #realx<#aufx Or #realy<#aufy
MessageRequester("Fire","auflösung",0)
End
EndIf
Dim col(#aufx,#aufy)
Dim hotspot(#aufx,#aufy)
If InitSprite()=0
MessageRequester("Fire","sprite",0)
Debug "sprite"
End
EndIf
If InitKeyboard()=0
MessageRequester("Fire","keyboard",0)
Debug "keyboard"
End
EndIf
If InitMouse()=0
MessageRequester("Fire","maus",0)
Debug "maus"
End
EndIf
OpenWindow(0,0,0,#realx,#realy,0,"hallo")
If OpenScreen(#realx,#realy,32,"PureFire")=0
MessageRequester("Fire","open",0)
Debug "open"
End
EndIf
omx=#aufx/2:omy=#aufy/2
MouseLocate(omx,omy-1)
Structure xy
x.l
y.l
c.l
EndStructure
NewList M.xy()
Dim color(255)
Procedure setcolor(i,r,g,b)
result=0
If DrawingBufferPixelFormat()=#PB_PixelFormat_32Bits_RGB
result=b<<16+g<<8+r
ElseIf DrawingBufferPixelFormat()=#PB_PixelFormat_32Bits_BGR
result=r<<16+g<<8+b
Else
result=RGB(r,g,b)
EndIf
color(i)=result
EndProcedure
StartDrawing(ScreenOutput())
For i=0 To 84
setColor(i,Int(250/84*i),0,0)
setcolor(i+85,250,Int(250/84*i),0)
setColor(i+85+85,250,250,Int(250/84*i))
Next
setColor(255,255,255,255)
StopDrawing()
;draw the flame-points
;ClearScreen(0,0,0)
StartDrawing(ScreenOutput())
DrawingMode(1)
If text$<>""
LoadFont(0,"Van Dijk",30)
DrawingFont(FontID())
DrawingMode(1)
FrontColor(255,255,255)
Locate((#aufx-TextLength(text$))>>1,#aufy-1-Int(60/200*#aufy) )
DrawText(text$)
CloseFont(0)
EndIf
CompilerIf #line
LineXY(0,#aufy-1,#aufx-1,#aufy-1)
CompilerEndIf
For y=0 To #aufy-1
For x=0 To #aufx-1
If Point(x,y)>0
hotspot(x,y)=1
EndIf
Next
Next
StopDrawing()
;FlipBuffers()
dodown=0:count=0
Repeat
CompilerIf #dodownmax>0
dodown+1:If dodown>#dodownmax:dodown=0:EndIf
CompilerEndIf
count+1:If count>#mouselen:count=0:EndIf
;mouse
quit=0
While FirstElement(m())>0 And quit=0
If m()\c=count
hotspot(m()\x,m()\y)=0
DeleteElement(m())
Else
quit=1
EndIf
Wend
mx=MouseX():my=MouseY()
If mx>#aufx-1:mx=#aufx-1:EndIf
If my>#aufy-1:my=#aufy-1:EndIf
If omx<>mx Or omy<>my
ax=omx-mx:If ax<0 :ax=-ax:EndIf
ay=omy-my:If ay<0 :ay=-ay:EndIf
If ax>ay:ab=ax:Else:ab=ay:EndIf
ax=omx-mx:ay=omy-my
For i=1 To ab
xx=mx+Int(ax*i/ab)
yy=my+Int(ay*i/ab)
If hotspot(xX,yY)=0
LastElement(m())
AddElement(m())
m()\x=xx
m()\y=yy
m()\c=count
hotspot(xX,yY)=col(xX,yY)+1
EndIf
Next
omx=mx:omy=my
EndIf
StartDrawing(ScreenOutput())
ClearScreen(0,0,0)
CompilerIf #updown
add=DrawingBufferPitch()
adr=DrawingBuffer()
If adr=0 Or add=0
Debug "adr=0"
MessageRequester("Fire","adr=0",0)
End
EndIf
For NY=0 To #aufy-1
CompilerElse
sub=DrawingBufferPitch()
adr=DrawingBuffer()+sub*(#aufy-1)
If adr=0 Or sub=0
Debug "adr=0"
MessageRequester("Fire","adr=0",0)
End
EndIf
For NY=#aufy-1 To 0 Step -1
CompilerEndIf
ny1 =ny+1:If ny1 >#aufy-1:ny1=#aufy-1:EndIf
ny2 =ny+2:If ny2 >#aufy-1:ny2=#aufy-1:EndIf
ny3 =ny+3:If ny3 >#aufy-1:ny3=#aufy-1:EndIf
*adr2.long=adr
For NX=0 To #aufx-1
nx1=nx-1:If nx1<0:nx1=0:EndIf
nx3=nx+1:If nx3>#aufx-1:nx3=#aufx-1:EndIf
i=Int( (col(nx1,ny1)+col(NX,ny1)+col(nx3,ny1)+col(nx1,ny2)+col(NX,ny2)+col(nx3,ny2))/6 )
;i= (col(NX,ny1)+col(NX,ny3)+col(nx1,ny2)+col(nx3,ny2))>>2
If dodown=0
CompilerIf #downsub=<0
i-1
CompilerElse
i-Random(#downsub)
CompilerEndIf
EndIf
If i<0:i=0:EndIf
;If i>254:i=254:EndIf
If hotspot(nx,ny)
a=col(nx,ny)
b=hotspot(nx,ny)
If a=b : b=Random(330)+20:hotspot(nx,ny)=b:EndIf
If a+10<b:b=a+10:EndIf
If a-10>b:b=a-10:EndIf
col(nx,ny)=b
i+#hotspotadd
If i<0:i=0:EndIf
If i>255:i=255:EndIf
Else
col(nx,ny)=i
If i>254:i=254:EndIf
EndIf
If i<0
c=color(0)
ElseIf i>255
c=color(255)
Else
c=color(i)
EndIf
*adr2\l=c
*adr2+4
Next
CompilerIf #updown
adr+add
CompilerElse
adr-sub
CompilerEndIf
Next
StopDrawing()
ExamineMouse()
ExamineKeyboard()
FlipBuffers()
Until KeyboardPushed(#PB_Key_All)
Debug "normal end"
End
p.s.: Mark you code with {code} and {/code} (note:instead of {} use [], but when i write it in the exampe, you can see it here