J’ai crée un nouveau post car le premier est saturé !

Code : Tout sélectionner
;-------------
;-By Mytic ---
;-------------
;------------------(Physique des fluides 7)
InitSprite()
;InitScreen() ;----(Inutile pour les nouvelles versions )
InitMouse()
InitKeyboard()
Structure info
x.l
y.l
acc.D
coul.l
activ.l
mov.l
ina.l
EndStructure
;Global FPS()
Global Dim goute.info(9999)
Global Dim Bgoute.info(9999)
Global maxg.l = -1
Global limg.l = 9999 ,mous.l = 0,could.l = RGB(0,255,0)
Global G.D = 0.1,maxacc.d = 4
Global pa.l = 255
Global activ.l = 0
Procedure.l intro()
i = -10
LoadFont(1, "Arial", 50)
StartDrawing(ScreenOutput())
DrawText(225,220,"> Physique des Fluides <")
StopDrawing()
FlipBuffers()
Delay(2000)
imi.d = 630/300
Repeat
ClearScreen(0)
StartDrawing(ScreenOutput())
i =i + 1
For y = 1 To 479
For x = 1 To 639
coul = (Sin(x)*Sin(y)*x)/y
Plot(x,y,coul+i)
Next x
Next y
;DrawText(10,10,Str(i))
If i < 0
DrawText(225,220,"> Physique des Fluides <")
EndIf
If i > 10 And i < 80
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(225,220,"Crée par <<Réda Jarmoune>> , Alias >Mytic<...",RGB(Random(255),Random(255),Random(255)))
EndIf
If i > 80 And i < 255
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(50,120,"Mode d’emploi :",RGB(0,0,255))
DrawText(10,150,"Le programme va simuler la physique d’un Fluide dans un milieu avec obstacles;",RGB(0,255,0))
DrawText(20,170," que vous allez dessiner vous même.",RGB(0,255,0))
DrawText(10,190,"Le moteur de physique gère la gravité, la pression, les collisions, les chocs, et les glissements.",RGB(0,255,0))
DrawText(10,210,"Pour ce qui est de l’interactivité :",RGB(0,0,255))
DrawText(10,230,"Contrôlez le curseur avec la souris,",RGB(0,255,0))
DrawText(10,260,"La touche Espace pour changer le mode de dessin en gomme ou crayon-à-obstacle et vis versa.",RGB(0,255,0))
DrawText(10,290,"Clique Gauche de la souris pour dessiner selon le mode de dessin choisi avec espace.",RGB(0,255,0))
DrawText(10,310,"Clique Droit de la souris pour injecter le fluide.",RGB(0,255,0))
DrawText(10,340,"Touche Entrer pour générer un labyrinthe...",RGB(0,255,0))
EndIf
Box(1,440,639,450,0)
mvv.d = mvv + imi
Box(3,443,mvv,447,RGB(Random(255),Random(255),Random(255)))
StopDrawing()
FlipBuffers()
If i > 300:Goto exintro:EndIf
ExamineKeyboard()
Delay(2)
Until KeyboardPushed(#PB_Key_All)
exintro:
ProcedureReturn 1
EndProcedure
Procedure.s FPS()
Static newtime.d,bactime.d,fp.l,rfp.s
newtime = ElapsedMilliseconds()
If newtime - bactime => 1000
rfp = Str(fp)
fp = 0
bactime = newtime
Else
fp = fp + 1
EndIf
ProcedureReturn rfp
EndProcedure
Procedure mega_Point(x,Y)
UseBuffer(0)
color= PeekW(DrawingBuffer() + (x * 2) +DrawingBufferPitch()* ( Y ) )
UseBuffer(-1)
ProcedureReturn color
EndProcedure
Procedure mega_Plot(x,Y,Couleur)
UseBuffer(0)
PokeW( DrawingBuffer() + (x * 2) +DrawingBufferPitch()* ( Y ) , Couleur )
UseBuffer(-1)
EndProcedure
Procedure mega_BOX(x,Y,w.l,h.l,Couleur)
UseBuffer(-1)
For ny = y To y+h-2
For nx = x To x+w-2
PokeW( DrawingBuffer() + (nx * 2) +DrawingBufferPitch()* ( nY ) , Couleur )
Next nx
Next ny
EndProcedure
Procedure labi(maxlX.l,minlY.l,grosso.l,couleur.l)
#taille = 13
For y = 1 To minlY-1 Step #taille
For x = 1 To maxlX-1 Step #taille
ax = Random(1)
If ax <> 0
For i = 0 To grosso
LineXY(x,y+i,x+#taille,y+i,couleur)
Next i
EndIf
Next x
Next y
For x = 1 To maxlX-1 Step #taille
For y = 1 To minlY-1 Step #taille
ay = Random(1)
If ay <> 0
For i = 0 To grosso
LineXY(x+i,y,x+i,y+#taille,couleur)
Next i
EndIf
Next y
Next x
EndProcedure
Procedure init_goute()
For i = 0 To limg
goute(i)\x = 1
goute(i)\y = 1
goute(i)\activ = 0
vv = Random(150)
goute(i)\coul = RGB(vv,vv,220 + Random(30))
Next i
EndProcedure
Procedure nouvel_goute(x.l,y.l)
For i = 0 To maxg
If goute(i)\activ = 0
goute(i)\acc = 1
goute(i)\x = x
goute(i)\y = y
goute(i)\activ = 1
vv = Random(150)
goute(i)\coul = RGB(vv,vv,220 + Random(30))
ProcedureReturn 1
EndIf
Next i
If maxg <= limg
maxg = maxg + 1
goute(maxg)\acc = 1
goute(maxg)\x = x
goute(maxg)\y = y
goute(maxg)\activ = 1
vv = Random(150)
goute(maxg)\coul = RGB(vv,vv,220 + Random(30))
ProcedureReturn 1
EndIf
ProcedureReturn 0
EndProcedure
Procedure gravite_collision()
activ = 0
StartDrawing(SpriteOutput(0))
For i = 0 To maxg
If goute(i)\activ = 1
activ+1
;=================(effet bulles de savon)
;If mega_Point(goute(i)\x,goute(i)\y)<> 0
;goute(i)\y-1
;EndIf
If mega_Point(goute(i)\x,goute(i)\y+goute(i)\acc) = 0
goute(i)\y+goute(i)\acc
If goute(i)\acc < maxacc
goute(i)\acc+G
EndIf
;goute(i)\ina-1
Else
goute(i)\acc=1
p = Random(1)
If p = 1
If mega_Point(goute(i)\x+1,goute(i)\y)= 0
goute(i)\x+1
Else
If mega_Point(goute(i)\x-1,goute(i)\y)= 0 :goute(i)\x-1:EndIf
EndIf
Else
If mega_Point(goute(i)\x-1,goute(i)\y)= 0
goute(i)\x-1
Else
If mega_Point(goute(i)\x+1,goute(i)\y)= 0 :goute(i)\x+1:EndIf
EndIf
EndIf
If mega_Point(goute(i)\x,goute(i)\y+1)<> 0 And mega_Point(goute(i)\x,goute(i)\y-1)= 0
If mega_Point(goute(i)\x-1,goute(i)\y+1)<> 0 And mega_Point(goute(i)\x+1,goute(i)\y+1)<> 0
goute(i)\y-1
;goute(i)\y-goute(i)\acc
EndIf
EndIf
EndIf
If (goute(i)\x > 10) And (goute(i)\x < 630) And (goute(i)\y > 10) And (goute(i)\y < 470)
vv = Random(150)
goute(i)\coul = RGB(vv,vv,220 + Random(30))
mega_Plot(Bgoute(i)\x,Bgoute(i)\y,0)
mega_Plot(goute(i)\x,goute(i)\y,goute(i)\coul)
Bgoute(i)\x = goute(i)\x
Bgoute(i)\y = goute(i)\y
Else
activ-1
mega_Plot(Bgoute(i)\x,Bgoute(i)\y,0)
goute(i)\activ = 0
EndIf
EndIf
Next i
DrawText(10,10,"Gouttes actives : " + Str(activ)+"#" + FPS() + "#" ,53289)
StopDrawing()
EndProcedure
Procedure type_goute()
StartDrawing(ScreenOutput())
For i = 0 To maxg
If goute(i)\activ = 1
;Box(Bgoute(i)\x,Bgoute(i)\y,2,2,0)
Box(goute(i)\x,goute(i)\y,2,2+goute(i)\acc/maxacc+1,goute(i)\coul)
;mega_BOX(goute(i)\x,goute(i)\y,2,2+goute(i)\acc/maxacc+1,goute(i)\coul)
EndIf
Next i
StopDrawing()
EndProcedure
Procedure create_mouse_Draw()
Static newww.b
If newww = 0
newww = 1
CreateSprite(1,20,20)
EndIf
UseBuffer(1)
ClearScreen(0)
StartDrawing(SpriteOutput(1))
DrawingMode(#PB_2DDrawing_Outlined)
LineXY(0,5,9,5,could)
LineXY(4,0,5,9,could)
Circle(5,5,5,could)
StopDrawing()
FlipBuffers()
UseBuffer(-1)
EndProcedure
Procedure create_mouse_water()
Static newww.b
If newww = 0
newww = 1
CreateSprite(1,20,20)
EndIf
UseBuffer(1)
ClearScreen(0)
StartDrawing(SpriteOutput(1))
DrawingMode(#PB_2DDrawing_Outlined)
LineXY(0,1,9,1,could)
LineXY(0,0,5,9,could)
LineXY(9,0,5,9,could)
StopDrawing()
FlipBuffers()
UseBuffer(-1)
EndProcedure
;OpenWindow(0,0,0,500,500,"test")
;OpenWindowedScreen(WindowID(0),0,0,500,500,0,0,0)
OpenScreen(640,480,16,"Eau")
CreateSprite(0,500,500)
create_mouse_Draw()
intro()
init_goute()
Repeat
ClearScreen(0)
ExamineKeyboard()
ExamineMouse()
If KeyboardReleased(#PB_Key_Return)
UseBuffer(0)
ClearScreen(0)
StartDrawing(SpriteOutput(0))
labi(640,480,3,255)
StopDrawing()
UseBuffer(-1)
EndIf
If KeyboardPushed(#PB_Key_Escape)
End
EndIf
If KeyboardReleased(#PB_Key_Space)
mous = 0
If pa = 0
could = RGB(0,255,0)
pa = 255
Else
could = RGB(0,0,255)
pa = 0
EndIf
create_mouse_draw()
EndIf
x = MouseX()
y = MouseY()
If MouseButton(#PB_MouseButton_Left)
If mous = 0 Or mous = 2
mous = 1
create_mouse_draw()
EndIf
StartDrawing(SpriteOutput(0))
Circle(x,y,3,pa)
;mega_Plot(x,y,255)
StopDrawing()
EndIf
If MouseButton(#PB_MouseButton_Right)
If mous = 0 Or mous = 1
mous = 2
create_mouse_water()
EndIf
nouvel_goute(x,y)
EndIf
DisplaySprite(0,0,0)
DisplayTransparentSprite(1,x-5,y-5)
gravite_collision()
type_goute()
;event = WindowEvent()
Delay(1)
FlipBuffers()
ForEver
End