J'ai trouvé sur un forum Russe consacré à Purebasic ce code de Artem (ou Aptem) :
Code : Tout sélectionner
InitSprite()
InitSprite3D()
InitKeyboard()
OpenWindow(0,100,100,800,600,"Light")
OpenWindowedScreen(WindowID(0),0,0,800,600,0,0,0)
Structure foton
x.f
y.f
size.l
life.l
a.f
EndStructure
Structure Light
id.l
x.l
y.l
life.l
size.l
List foton.foton()
EndStructure
Structure stena
id.l
x.l
y.l
s.l
EndStructure
Global NewList s.stena()
For i=0 To 200
AddElement(s())
ix=Random(800)/32
iy=Random(600)/32
s()\x=Random(800)
s()\y=Random(600)
s()\s=32
s()\id=CreateSprite(#PB_Any,32,32)
Next
CatchSprite(0,?b1)
Global NewList light.light(),LightB
Procedure InitLight()
LightB=CreateSprite(#PB_Any,800,600,#PB_Sprite_Texture)
CreateSprite3D(0,LightB)
LightC=2
EndProcedure
Procedure ExamineLight()
Start3D()
Sprite3DBlendingMode(9,8)
DisplaySprite3D(LightC,0,0)
Stop3D()
StartDrawing(SpriteOutput(LightB))
Box(0,0,800,600,RGB(0,0,0))
StopDrawing()
ForEach Light()
With light()
c.f=(359/50)
If ListSize(light()\foton())<50
For i=1 To 51
AddElement(light()\foton())
\foton()\life=\life
\foton()\size=\size
\foton()\x=\x
\foton()\y=\y
\foton()\a=c*i
Next
EndIf
EndWith
Next
EndProcedure
Procedure AddLight(id, x, y, life, size)
AddElement(light())
With light()
\x=x
\y=y
\id=id
\life=life
\size=size
EndWith
EndProcedure
Procedure DrawLight(id,x,y)
StartDrawing(SpriteOutput(LightB))
ForEach Light()
If light()\id=id
light()\x=x
light()\y=y
With light()
While ListSize(\foton())>0
ForEach \foton()
\foton()\x=\foton()\x+Cos(\foton()\a*#PI/180)*(\foton()\size)
\foton()\y=\foton()\y+Sin(\foton()\a*#PI/180)*(\foton()\size)
\foton()\life-(\foton()\size/2)
ForEach s()
If \foton()\x<s()\x+s()\s And \foton()\x>s()\x
If \foton()\y<s()\y+s()\s And \foton()\y>s()\y
\foton()\life=0
EndIf
EndIf
Next
If \foton()\life>0
cof=(255/light()\life)*\foton()\life
Circle(\foton()\x,\foton()\y,\foton()\size,RGB(cof,cof,cof))
EndIf
If \foton()\life<=0
DeleteElement(\foton())
EndIf
Next
Wend
EndWith
EndIf
Next
StopDrawing()
EndProcedure
Procedure FPS()
Shared s, fps
ss=Second(Date())
fps+1
If s<>ss
s=ss
SetWindowTitle(0,"Свет FPS: "+Str(FPS))
fps=0
EndIf
EndProcedure
InitLight()
AddLight(1, 400, 300, 50, 10)
AddLight(2, 400, 300, 50, 10)
ForEach s()
StartDrawing(SpriteOutput(s()\id))
Box(0,0,64,64,RGB(255,Random(255),0))
StopDrawing()
Next
Repeat
FPS()
event=WaitWindowEvent(1)
FlipBuffers()
ClearScreen(RGB(0,0,0))
ExamineKeyboard()
For x=0 To 800 Step 146
For y=0 To 600 Step 146
DisplaySprite(0,x,y)
Next
Next
ForEach s()
DisplaySprite(s()\id,s()\x, s()\y)
Next
ExamineLight()
DrawLight(2,400, 300)
x=WindowMouseX(0)
y=WindowMouseY(0)
DrawLight(1,x,y)
If event=#WM_CLOSE Or KeyboardPushed(#PB_Key_Escape)
q=1
EndIf
Until q=1
End
DataSection
b1:
IncludeBinary "1.bmp"
EndDataSection

PS : le lien original : http://purebasic.info/phpBB2/viewtopic.php?t=1889
EDIT : Bon, en bidouillant un peu le code et en passant par des sprites3D plutôt que par des circle(), on arrive à des résultats fabulous breakdown


En plus, je suis passé à 60fps au lieu de 32, grâce aux sprites3D

Je croyais que ce n'était pas possible en purebasic, mais visiblement c'est tout à fait possible, il est puissant ce Purebasic
