djes a écrit :Désolé d'être direct, mais je ne vois pas en quoi vos procédures sont "rapides".
ben c'est simple , je vais te le montrer
dans ce prg le but est de dessiner des barrières avec le bouton gauche , et avec le bouton droite tu te met en haut de l'écran et tu balance de "l'eau" et regarde bien le résultat , balance beaucoup d'eau hein
observe la vitesse des particules d'eau lorsque tu utilise l'instruction Point()
tu aura meme du mal a dessiner des barrieres sans trous pendant la chutes des particules !!
ensuite remplace "
point" actuel par "
rapide_point" avec l'editeur
relance le programe et test !!
la fluidité, est evidente, et on peu dessiner des barriere rouges, sans probleme !!
ceci prouve que Point() est tres lent !!
j'en avait deja fait la demonstration lors du prog Terre lune avec Huitbit !!

(c'etait mem encore plus flagrant !!)
Code : Tout sélectionner
;-------------
;-By Dobro sur une idée de Mytic ---
;-------------
InitSprite()
InitMouse()
InitKeyboard()
Declare rapide_Point(x,Y)
Declare nouvel_goute(x.l,Y.l)
Declare gravite_collision()
Global taille=5 ; testez un autre chiffre<------------ zoom sur le phenomene
Structure goute
x.l
Y.l
pasy.l
pasx.l
EndStructure
Global NewList goute.goute()
Global largeur,hauteur
Enumeration
#crayon
#goute
#fond
#Window
EndEnumeration
OpenWindow(#Window,1,1,1024,768,"ecran",#PB_Window_BorderLess )
OpenWindowedScreen(WindowID(#Window),1,1,1024,768,1,0,0)
;OpenScreen(1024,768,32,"Eau")
largeur = GetSystemMetrics_ ( #SM_CXSCREEN ): ;=largeur de l'ecran
hauteur = GetSystemMetrics_ ( #SM_CYSCREEN ): ;=hauteur de l'ecran
; ********** Fond ****************
CreateSprite( #fond,1024,768)
; ********************************
; ********** crayon ****************
CreateSprite( #crayon,taille*2,taille*2)
StartDrawing(SpriteOutput(#crayon))
Box(0,0,taille,taille,RGB(0,255,0))
StopDrawing()
; ********************************
; ********** goute d'eau ****************
CreateSprite( #goute,taille,taille)
StartDrawing(SpriteOutput(#goute))
Box(0,0,taille/2,taille/2,RGB(0,0,255))
Box(taille/2,taille/2,taille,taille,RGB(0,0,255))
Box(taille/2,0,taille,taille/2,RGB($24,$95,$E8))
Box(0,taille/2,taille/2,taille,RGB($24,$95,$E8))
StopDrawing()
; ********************************
Repeat
Event = WindowEvent()
ExamineKeyboard()
ExamineMouse()
ClearScreen(0)
If KeyboardPushed(#PB_Key_Escape)
End
EndIf
DisplaySprite(#fond,0,0)
x = MouseX()
Y = MouseY()
DisplaySprite(#crayon,x,Y)
If MouseButton(#PB_MouseButton_Left)
StartDrawing(SpriteOutput(#fond))
Circle(x,Y,taille,RGB(255,0,0))
StopDrawing()
EndIf
If KeyboardPushed(#PB_Key_Space)
StartDrawing(SpriteOutput(#fond))
Circle(x,Y,taille,RGB(0,0,0))
StopDrawing()
EndIf
If MouseButton(#PB_MouseButton_Right)
;Y=0
; x=Random(largeur)
G=G+1
Debug CountList(goute())
nouvel_goute(x,Y)
If G>1000 ; < ------------- seuil maximum
ClearList(goute())
G=0
EndIf
EndIf
gravite_collision()
Delay(1)
FlipBuffers()
ForEver
End
Procedure nouvel_goute(x.l,Y.l)
AddElement(goute())
goute()\x=x
goute()\Y=Y
DisplaySprite(#goute,x,Y)
EndProcedure
Procedure gravite_collision()
ResetList(goute() )
While NextElement(goute())
StartDrawing(ScreenOutput())
If Point (goute()\x,goute()\Y+taille) = 0
goute()\Y+taille
Else
p = Random(1)
If p = 1
If Point (goute()\x+taille,goute()\Y)= 0
goute()\x+taille
Else
If Point (goute()\x-1,goute()\Y)= 0 :goute()\x-taille:EndIf
EndIf
Else
If Point (goute()\x-1,goute()\Y)=0
goute()\x-taille
Else
If Point (goute()\x+taille,goute()\Y)= 0 :goute()\x+taille:EndIf
EndIf
EndIf
EndIf
StopDrawing()
; ******** test sorti en bas on remet en haut ! ************
If goute()\Y>= (hauteur)
goute()\Y=0
EndIf
; *******************************
; ******** test sorti a droite et gauche************
If (goute()\x>= (largeur-taille) Or goute()\x<=0)
goute()\pasx=0
goute()\pasy=0
EndIf
; *******************************
DisplaySprite(#goute,goute()\x,goute()\Y)
Wend
EndProcedure
Procedure rapide_Point(x,Y)
; de cpl Bator
If (x > 0) And (x < largeur) And (Y > 0) And (Y < hauteur)
Select DrawingBufferPixelFormat()
Case #PB_PixelFormat_8Bits : PF=1:t=0
Case #PB_PixelFormat_15Bits : PF=2:t=0
Case #PB_PixelFormat_16Bits : PF=2:t=0
Case #PB_PixelFormat_24Bits_RGB : PF=3:t=0
Case #PB_PixelFormat_24Bits_BGR : PF=3:t=1
Case #PB_PixelFormat_32Bits_RGB : PF=4:t=0
Case #PB_PixelFormat_32Bits_BGR : PF=4:t=1
EndSelect
color= PeekL(DrawingBuffer() + (x * PF) +DrawingBufferPitch()* ( Y ) )
If t=1
Rouge=Red(color)
Vert=Green(color)
Bleu=Blue(color)
color=RGB(Bleu,Vert,Rouge)
EndIf
ProcedureReturn color
Else
color=RGB(0,0,0)
ProcedureReturn color
EndIf
EndProcedure