Publié : sam. 24/déc./2005 13:46
Joyeux Nowel ^_^"
Forums PureBasic - Français
https://www.purebasic.fr/french/
; Code par Dobro !!
; system solaire
; avec raytracing pour l'affichage des parties éclairés
Declare.f RotationX(X, angle.f, dist)
Declare.f RotationY(Y, angle.f, dist)
Declare calcul()
#PI =3.1415926
Enumeration
#dobro
#Police
#soleil
#terre
#lune
#ecran
EndEnumeration
Structure soleil
X.l
Y.l
EndStructure
Dim soleil.soleil(1)
Structure lune
X.l
Y.l
EndStructure
Dim lune.lune(1)
Structure terre
X.l
Y.l
EndStructure
Dim terre.terre(1)
; ***********************************
Resultat = InitSprite ()
FontID = LoadFont ( #Police , "arial" , 18, #PB_Font_Bold )
EcranX = GetSystemMetrics_ ( #SM_CXSCREEN ): ;=largeur de l'ecran
EcranY = GetSystemMetrics_ ( #SM_CYSCREEN ): ;=hauteur de l'ecran
WindowID = OpenWindow (1, 0, 0,EcranX, EcranY, #PB_Window_SystemMenu|#PB_Window_BorderLess |#PB_Window_ScreenCentered , "system solaire maintenir un appuis sur ESC pour quitter" )
Result = OpenWindowedScreen ( WindowID (1) ,0,0,EcranX, EcranY, 1, 0,0)
Resultat = InitMouse ()
Resultat = InitKeyboard ()
; creation de notre ecran
CreateSprite ( #ecran , EcranX, EcranY)
StartDrawing ( SpriteOutput ( #ecran ) )
For etoiles=1 To 1000
x_etoile= Random (EcranX-10)+5
y_etoile= Random (EcranY-10)+5
Plot ( x_etoile, y_etoile, RGB ($B1,$CD,$FC))
Next etoiles
StopDrawing ()
; creation du soleil
CreateSprite ( #soleil , 64,64)
StartDrawing ( SpriteOutput ( #soleil ) ) ; on dessine dedans
Circle (32, 32, 32 , RGB ($FF,$FF,$97))
StopDrawing ()
; creation de la terre
CreateSprite ( #terre , 32, 32)
StartDrawing ( SpriteOutput ( #terre ) ) ; on dessine dedans
Circle (16, 16, 16 , RGB ($71,$88,$F9))
StopDrawing ()
; creation de la lune
CreateSprite ( #lune , 16, 16)
StartDrawing ( SpriteOutput ( #lune ) ) ; on dessine dedans
Circle (8, 8, 8 , RGB ($A6,$A6,$A6))
StopDrawing ()
taille_du_cercle_terre=180
taille_du_cercle_lune=50
nombre_de_jour_terre=360 ; ceci determine la resolution (nombre de points)
nombre_de_jour_lune=21 ; ceci determine la resolution (nombre de points)
soleil(1)\X=EcranX/2-64
soleil(1)\Y=EcranY/2-64
Repeat
ExamineMouse ()
ExamineKeyboard ()
WindowEvent ()
Delay (2)
If MouseButton (2)
End
EndIf
compt_terre+1
compt_lune+1
If compt_terre=nombre_de_jour_terre :compt_terre=0: EndIf ; on a fait le tour ??
If compt_lune=nombre_de_jour_lune :compt_lune=0: EndIf ; on a fait le tour ??
terre(1)\X=taille_du_cercle_terre* Cos ( compt_terre*(2*3.1415926/nombre_de_jour_terre)) + (soleil(1)\X+8 ) ; la formule du cercle /360 = 360 points
terre(1)\Y=taille_du_cercle_terre * Sin ( compt_terre*(2*3.1415926/nombre_de_jour_terre)) + (soleil(1)\Y+8 ) ; la formule du cercle
lune(1)\X=taille_du_cercle_lune* Cos ( compt_lune*(2*3.1415926/nombre_de_jour_lune)) + (terre(1)\X) ; la formule du cercle /360 = 360 points
lune(1)\Y=taille_du_cercle_lune * Sin ( compt_lune*(2*3.1415926/nombre_de_jour_lune)) + (terre(1)\Y) ; la formule du cercle
calcul() ; saut vers le raytracing maison
FlipBuffers (): ; affiche l'ecran
ClearScreen (0, 0, 0) : ;efface l'ecran
Until Event= #PB_Event_CloseWindow
Procedure.f RotationX(X, angle.f, dist)
ProcedureReturn X + Cos (angle.f* #PI /180)*dist
EndProcedure
Procedure.f RotationY(Y, angle.f, dist)
ProcedureReturn Y + Sin (angle.f* #PI /180)*dist
EndProcedure
Procedure calcul()
DisplaySprite ( #ecran , 0, 0)
DisplayTransparentSprite ( #soleil , soleil(1)\X, soleil(1)\Y)
DisplayTransparentSprite ( #terre , terre(1)\X, terre(1)\Y)
DisplayTransparentSprite ( #lune , lune(1)\X, lune(1)\Y)
lumiere= RGB ($FF,$FF,$97) ; lumiere du soleil
StartDrawing ( ScreenOutput ())
For i=1 To 360
For distance=100 To 250 Step 2
coul= Point (RotationX(soleil(1)\X+32, i, distance) ,RotationY(soleil(1)\Y+32, i, distance))
If coul= RGB ($71,$88,$F9) ;la lumiere rencontre la terre
lumiere= RGB ($FF,$FF,$97) ; lumiere du soleil
Box (RotationX(soleil(1)\X+32, i, distance) , RotationY(soleil(1)\Y+32, i, distance),2,2,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+2) , RotationY(soleil(1)\Y+32, i, distance+2),2,2,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+4) , RotationY(soleil(1)\Y+32, i, distance+4),2,2,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+6) , RotationY(soleil(1)\Y+32, i, distance+6),2,2,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+8 ) , RotationY(soleil(1)\Y+32, i, distance+8 ),2,2,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+10) , RotationY(soleil(1)\Y+32, i, distance+10),2,2,lumiere)
Break 1
ElseIf coul= RGB ($A6,$A6,$A6) ;la lumiere rencontre la lune
lumiere= RGB ($FF,$FF,$97) ; lumiere du soleil
Box (RotationX(soleil(1)\X+32, i, distance) , RotationY(soleil(1)\Y+32, i, distance),1,1,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+1) , RotationY(soleil(1)\Y+32, i, distance+1),1,1,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+2) , RotationY(soleil(1)\Y+32, i, distance+2),1,1,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+3) , RotationY(soleil(1)\Y+32, i, distance+3),1,1,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+4) , RotationY(soleil(1)\Y+32, i, distance+4),1,1,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+5) , RotationY(soleil(1)\Y+32, i, distance+5),1,1,lumiere)
Break 1
Else
lumiere= RGB ($FF,$FF,$97) ; lumiere du soleil
Plot (RotationX(soleil(1)\X+32, i, distance) , RotationY(soleil(1)\Y+32, i, distance),lumiere)
EndIf
If KeyboardPushed ( #PB_Key_All )
End
EndIf
While WindowEvent () : Wend
Next distance
flag=0
Next i
StopDrawing ()
EndProcedure
Code : Tout sélectionner
; creation de notre ecran
CreateSprite ( #ecran , EcranX, EcranY)
If StartDrawing ( SpriteOutput ( #ecran ) )
For etoiles=1 To 1000
x_etoile= Random (EcranX)
y_etoile= Random (EcranY)
Plot ( x_etoile, y_etoile, RGB ($B1,$CD,$FC))
Next etoiles
StopDrawing ()
EndIf
ben tu sais ce que sait , c'est des résidus de test qui reste dans le codelionel_om a écrit :Tu peux m'expliquer pourquoi t'as deux "KillThread()", alors qu'il n'y a pas de CreateThread() ???
; Code par Dobro !!
; system solaire
; avec raytracing pour l'affichage des parties éclairés
Declare.f RotationX(X, angle.f, dist)
Declare.f RotationY(Y, angle.f, dist)
Declare calcul()
#PI =3.1415926
Enumeration
#dobro
#Police
#soleil
#terre
#lune
#ecran
EndEnumeration
Structure soleil
X.l
Y.l
EndStructure
Dim soleil.soleil(1)
Structure lune
X.l
Y.l
EndStructure
Dim lune.lune(1)
Structure terre
X.l
Y.l
EndStructure
Dim terre.terre(1)
; ***********************************
Resultat = InitSprite ()
FontID = LoadFont ( #Police , "arial" , 18, #PB_Font_Bold )
EcranX = GetSystemMetrics_ ( #SM_CXSCREEN ): ;=largeur de l'ecran
EcranY = GetSystemMetrics_ ( #SM_CYSCREEN ): ;=hauteur de l'ecran
WindowID = OpenWindow (1, 0, 0,EcranX, EcranY, #PB_Window_SystemMenu|#PB_Window_BorderLess |#PB_Window_ScreenCentered , "system solaire maintenir un appuis sur ESC pour quitter" )
Result = OpenWindowedScreen ( WindowID (1) ,0,0,EcranX, EcranY, 1, 0,0)
Resultat = InitMouse ()
Resultat = InitKeyboard ()
; creation de notre ecran
CreateSprite ( #ecran , EcranX, EcranY)
StartDrawing ( SpriteOutput ( #ecran ) )
For etoiles=1 To 1000
x_etoile= Random (EcranX-10)+5
y_etoile= Random (EcranY-10)+5
Plot ( x_etoile, y_etoile, RGB ($B1,$CD,$FC))
Next etoiles
StopDrawing ()
; creation du soleil
CreateSprite ( #soleil , 64,64)
StartDrawing ( SpriteOutput ( #soleil ) ) ; on dessine dedans
Circle (32, 32, 32 , RGB ($FF,$FF,$97))
StopDrawing ()
; creation de la terre
CreateSprite ( #terre , 32, 32)
StartDrawing ( SpriteOutput ( #terre ) ) ; on dessine dedans
Circle (16, 16, 16 , RGB ($71,$88,$F9))
StopDrawing ()
; creation de la lune
CreateSprite ( #lune , 16, 16)
StartDrawing ( SpriteOutput ( #lune ) ) ; on dessine dedans
Circle (8, 8, 8 , RGB ($A6,$A6,$A6))
StopDrawing ()
taille_du_cercle_terre=180
taille_du_cercle_lune=50
nombre_de_jour_terre=360 ; ceci determine la resolution (nombre de points)
nombre_de_jour_lune=21 ; ceci determine la resolution (nombre de points)
soleil(1)\X=EcranX/2-64
soleil(1)\Y=EcranY/2-64
Repeat
ExamineMouse ()
ExamineKeyboard ()
WindowEvent ()
Delay (2)
If MouseButton (2)
End
EndIf
compt_terre+1
compt_lune+1
If compt_terre=nombre_de_jour_terre :compt_terre=0: EndIf ; on a fait le tour ??
If compt_lune=nombre_de_jour_lune :compt_lune=0: EndIf ; on a fait le tour ??
terre(1)\X=taille_du_cercle_terre* Cos ( compt_terre*(2*3.1415926/nombre_de_jour_terre)) + (soleil(1)\X+8 ) ; la formule du cercle /360 = 360 points
terre(1)\Y=taille_du_cercle_terre * Sin ( compt_terre*(2*3.1415926/nombre_de_jour_terre)) + (soleil(1)\Y+8 ) ; la formule du cercle
lune(1)\X=taille_du_cercle_lune* Cos ( compt_lune*(2*3.1415926/nombre_de_jour_lune)) + (terre(1)\X) ; la formule du cercle /360 = 360 points
lune(1)\Y=taille_du_cercle_lune * Sin ( compt_lune*(2*3.1415926/nombre_de_jour_lune)) + (terre(1)\Y) ; la formule du cercle
calcul() ; saut vers le raytracing maison
FlipBuffers (): ; affiche l'ecran
ClearScreen (0, 0, 0) : ;efface l'ecran
Until Event= #PB_Event_CloseWindow
Procedure.f RotationX(X, angle.f, dist)
ProcedureReturn X + Cos (angle.f* #PI /180)*dist
EndProcedure
Procedure.f RotationY(Y, angle.f, dist)
ProcedureReturn Y + Sin (angle.f* #PI /180)*dist
EndProcedure
Procedure calcul()
DisplaySprite ( #ecran , 0, 0)
DisplayTransparentSprite ( #soleil , soleil(1)\X, soleil(1)\Y)
DisplayTransparentSprite ( #terre , terre(1)\X, terre(1)\Y)
DisplayTransparentSprite ( #lune , lune(1)\X, lune(1)\Y)
lumiere= RGB ($FF,$FF,$97) ; lumiere du soleil
StartDrawing ( ScreenOutput ())
For i=1 To 360
For distance=100 To 250
coul= Point (RotationX(soleil(1)\X+32, i, distance) ,RotationY(soleil(1)\Y+32, i, distance))
If coul= RGB ($71,$88,$F9) ;la lumiere rencontre la terre
lumiere= RGB ($FF,$FF,$97) ; lumiere du soleil
Box (RotationX(soleil(1)\X+32, i, distance) , RotationY(soleil(1)\Y+32, i, distance),2,2,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+2) , RotationY(soleil(1)\Y+32, i, distance+2),2,2,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+4) , RotationY(soleil(1)\Y+32, i, distance+4),2,2,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+6) , RotationY(soleil(1)\Y+32, i, distance+6),2,2,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+8 ) , RotationY(soleil(1)\Y+32, i, distance+8 ),2,2,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+10) , RotationY(soleil(1)\Y+32, i, distance+10),2,2,lumiere)
Break 1
ElseIf coul= RGB ($A6,$A6,$A6) ;la lumiere rencontre la lune
lumiere= RGB ($FF,$FF,$97) ; lumiere du soleil
Box (RotationX(soleil(1)\X+32, i, distance) , RotationY(soleil(1)\Y+32, i, distance),1,1,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+1) , RotationY(soleil(1)\Y+32, i, distance+1),1,1,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+2) , RotationY(soleil(1)\Y+32, i, distance+2),1,1,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+3) , RotationY(soleil(1)\Y+32, i, distance+3),1,1,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+4) , RotationY(soleil(1)\Y+32, i, distance+4),1,1,lumiere)
Box (RotationX(soleil(1)\X+32, i, distance+5) , RotationY(soleil(1)\Y+32, i, distance+5),1,1,lumiere)
Break 1
Else
lumiere= RGB ($FF,$FF,$97) ; lumiere du soleil
; Plot(RotationX(soleil(1)\X+32, i, distance) , RotationY(soleil(1)\Y+32, i, distance),lumiere)
EndIf
If KeyboardPushed ( #PB_Key_All )
End
EndIf
While WindowEvent () : Wend
Next distance
flag=0
Next i
StopDrawing ()
EndProcedure
ya une regle implicite sur le Forum ...Donc même si 1% doit râler, je vais peut être piocher dans ce prog si tu (Dobro) n'y vois pas d'inconvénients!!!
Code : Tout sélectionner
X=taille_du_cercle* Cos( compt*(2*3.1415926/nombre_de_point)) + (EcranX / 2)
Y=taille_du_cercle * Sin( compt*(2*3.1415926/nombre_de_point)) + (EcranY / 2)
; code by Dobro http://michel.dobro.free.fr/
#dobro =1
#Police =1
#Sprite =1
; ***********************************
Resultat = InitSprite ()
FontID = LoadFont ( #Police , "arial" , 50, #PB_Font_Bold )
EcranX = GetSystemMetrics_ ( #SM_CXSCREEN ): ;=largeur de l'ecran
EcranY = GetSystemMetrics_ ( #SM_CYSCREEN ): ;=hauteur de l'ecran
WindowID = OpenWindow (1, 0, 0, EcranX, EcranY, #PB_Window_SystemMenu|#PB_Window_BorderLess |#PB_Window_ScreenCentered , "hello" )
WindowID = WindowID (1)
Result = OpenWindowedScreen ( WindowID ,0,0, EcranX, EcranY, 1, 0,0)
Resultat = InitMouse ()
taille_du_cercle=200
nombre_de_point=360 ; ceci determine la resolution (nombre de points)
Repeat
ExamineMouse ()
Event= WaitWindowEvent ()
StartDrawing ( ScreenOutput ())
compt+1
If compt=nombre_de_point :compt=0: EndIf ; on a fait le tour ??
X=taille_du_cercle* Cos ( compt*(2*3.1415926/nombre_de_point)) + (EcranX / 2) ; la formule du cercle /360 = 360 points
Y=taille_du_cercle * Sin ( compt*(2*3.1415926/nombre_de_point)) + (EcranY / 2) ; la formule du cercle
Box (X, Y,2, 2 , RGB (255,255,255))
StopDrawing ()
FlipBuffers (): ; affiche l'ecran
Event= WindowEvent ()
If MouseButton (2)
End
EndIf
Until Event= #PB_Event_CloseWindow
Procedure.f RotationX(X, angle.f, dist)
ProcedureReturn X + Cos (angle.f* #PI /180)*dist
EndProcedure
Procedure.f RotationY(Y, angle.f, dist)
ProcedureReturn Y + Sin (angle.f* #PI /180)*dist
EndProcedure
Declare.f RotationX(X, angle.f, dist)
Declare.f RotationY(Y, angle.f, dist)
#PI =3.1415926
X=50
Y=50
angle.f=45
dist=100
Debug RotationX(X, angle.f, dist)
Debug RotationY(Y, angle.f, dist)
End
Procedure.f RotationX(X, angle.f, dist)
ProcedureReturn X + Cos (angle.f* #PI /180)*dist
EndProcedure
Procedure.f RotationY(Y, angle.f, dist)
ProcedureReturn Y + Sin (angle.f* #PI /180)*dist
EndProcedure
Code : Tout sélectionner
CT
let taille=100
let demitaille={taille}/2
let seuil=0
pour [branche]
AV taille
TD 60
AV demitaille
RE demitaille
TG 120
let taille={taille}-4
let seuil={seuil}+1
? 10,10 seuil
si seuil>25
saute fin
sinon
[branche]
fin_si
fin_pour
[branche],taille,demitaille
fin:
; code by Dobro http://michel.dobro.free.fr/
Declare.f RotationX(X, angle.f, dist)
Declare.f RotationY(Y, angle.f, dist)
#dobro =1
#Police =1
#Sprite =1
#PI =3.1415926
; ***********************************
Resultat = InitSprite ()
FontID = LoadFont ( #Police , "arial" , 50, #PB_Font_Bold )
EcranX = GetSystemMetrics_ ( #SM_CXSCREEN ): ;=largeur de l'ecran
EcranY = GetSystemMetrics_ ( #SM_CYSCREEN ): ;=hauteur de l'ecran
WindowID = OpenWindow (1, 0, 0, EcranX, EcranY, #PB_Window_SystemMenu|#PB_Window_BorderLess |#PB_Window_ScreenCentered , "hello" )
WindowID = WindowID (1)
Result = OpenWindowedScreen ( WindowID ,0,0, EcranX, EcranY, 1, 0,0)
Resultat = InitMouse ()
taille_du_cercle=200
nombre_de_point=360 ; ceci determine la resolution (nombre de points)
Repeat
ExamineMouse ()
Event= WaitWindowEvent ()
StartDrawing ( ScreenOutput ())
; ******************* faire un cercle ********************************
compt+1
If compt=nombre_de_point :compt=0: EndIf ; on a fait le tour ??
X=taille_du_cercle* Cos ( compt*(2*3.1415926/nombre_de_point)) + (EcranX / 2) ; la formule du cercle /360 = 360 points
Y=taille_du_cercle * Sin ( compt*(2*3.1415926/nombre_de_point)) + (EcranY / 2) ; la formule du cercle
; ***********************************************
; ************ faire un triangle *****************
angle.f=120 ; angle (triangle equilateral)
dist=200 ; longueur d'un coté du triangle
; point 1
x1=EcranX/2
y1=EcranY/2
; point 2
x2=RotationX(x1, angle.f+120, dist) ; les coordoné sont calculé en absolu pas en relatif !!
y2=RotationY(y1, angle.f+120, dist) ; on est donc obligé de rejouter l'angla a la derniere position obtenu
; point 3
x3=RotationX(x2, angle.f+120+120, dist)
y3=RotationY(y2, angle.f+120+120, dist)
; dessin !
LineXY (x1, y1, x2, y2 , RGB ($B1,$FC,$BD))
LineXY (x2, y2, x3, y3 , RGB ($B1,$FC,$0))
LineXY (x3, y3, x1, y1 , RGB ($0,$FC,$BD))
; ********************************************
Box (X, Y,2, 2 , RGB (255,255,255))
StopDrawing ()
FlipBuffers (): ; affiche l'ecran
Event= WindowEvent ()
If MouseButton (2)
End
EndIf
Until Event= #PB_Event_CloseWindow
Procedure.f RotationX(X, angle.f, dist)
ProcedureReturn X + Cos (angle.f* #PI /180)*dist
EndProcedure
Procedure.f RotationY(Y, angle.f, dist)
ProcedureReturn Y + Sin (angle.f* #PI /180)*dist
EndProcedure
Code : Tout sélectionner
Soleil.Point
Soleil\x = 400
Soleil\y = 300
Terre.Point
TerreAngle.f
Lune.Point
LuneAngle.f
AnglePas.f = 0.06
AlphaTerre.f = (2 * #Pi) / 365
AlphaLune.f = (2 * #Pi) / 21
RayTerreStart.Point
RayTerreEnd.Point
RayLuneStart.Point
RayLuneEnd.Point
RaySoleilStart.Point
RaySoleilEnd.Point
InitSprite()
OpenWindow(0, 0, 0, 800, 600, #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget, "Système solaire")
OpenWindowedScreen(WindowID(), 0, 0, 800, 600, 1, 0, 0)
Repeat
Repeat
wEvent = WindowEvent()
Select wEvent
Case #WM_CLOSE
Quit = #True
EndSelect
Until wEvent = #Null
TerreAngle + AlphaTerre * AnglePas
If TerreAngle > 2 * #Pi
TerreAngle - 2 * #Pi
EndIf
LuneAngle + AlphaLune * AnglePas
If LuneAngle > 2 * #Pi
LuneAngle - 2 * #Pi
EndIf
Terre\x = 128 * Cos(-TerreAngle) + Soleil\x
Terre\y = 128 * Sin(-TerreAngle) + Soleil\y
Lune\x = 48 * Cos(-LuneAngle) + Terre\x
Lune\y = 48 * Sin(-LuneAngle) + Terre\y
RaySoleilStart\x = 32 * Cos(-TerreAngle - #Pi / 2) + Soleil\x
RaySoleilStart\y = 32 * Sin(-TerreAngle - #Pi / 2) + Soleil\y
RaySoleilEnd\x = 32 * Cos(-TerreAngle + #Pi / 2) + Soleil\x
RaySoleilEnd\y = 32 * Sin(-TerreAngle + #Pi / 2) + Soleil\y
RayTerreStart\x = 16 * Cos(-TerreAngle - #Pi / 2) + Terre\x
RayTerreStart\y = 16 * Sin(-TerreAngle - #Pi / 2) + Terre\y
RayTerreEnd\x = 16 * Cos(-TerreAngle + #Pi / 2) + Terre\x
RayTerreEnd\y = 16 * Sin(-TerreAngle + #Pi / 2) + Terre\y
RayLuneStart\x = 8 * Cos(-TerreAngle - #Pi / 2) + Lune\x
RayLuneStart\y = 8 * Sin(-TerreAngle - #Pi / 2) + Lune\y
RayLuneEnd\x = 8 * Cos(-TerreAngle + #Pi / 2) + Lune\x
RayLuneEnd\y = 8 * Sin(-TerreAngle + #Pi / 2) + Lune\y
ClearScreen(0, 0, 0)
StartDrawing(ScreenOutput())
DrawingMode(0)
Circle(Soleil\x, Soleil\y, 32, RGB(200, 200, 20)) ; le soleil
Circle(Terre\x , Terre\y , 16, RGB(20, 20, 200)) ; la terre
Circle(Lune\x , Lune\y , 8 , RGB(128, 128, 128)) ; la lune
DrawingMode(4)
Circle(Soleil\x, Soleil\y, 128, RGB(200, 20, 20))
Circle(Terre\x, Terre\y, 48, RGB(200, 20, 20))
LineXY(RaySoleilStart\x, RaySoleilStart\y, RayTerreStart\x, RayTerreStart\y, RGB(20, 200, 20))
LineXY(RaySoleilEnd\x, RaySoleilEnd\y, RayTerreEnd\x, RayTerreEnd\y, RGB(20, 200, 20))
LineXY(RayTerreStart\x, RayTerreStart\y, RayTerreEnd\x, RayTerreEnd\y, RGB(20, 200, 20))
LineXY(RaySoleilStart\x, RaySoleilStart\y, RayLuneStart\x, RayLuneStart\y, RGB(20, 200, 20))
LineXY(RaySoleilEnd\x, RaySoleilEnd\y, RayLuneEnd\x, RayLuneEnd\y, RGB(20, 200, 20))
LineXY(RayLuneStart\x, RayLuneStart\y, RayLuneEnd\x, RayLuneEnd\y, RGB(20, 200, 20))
LineXY(400, 0, 400, 600, RGB(255, 255, 255))
LineXY(0, 300, 800, 300, RGB(255, 255, 255))
LineXY(0, Terre\y, 800, Terre\y, RGB(20, 20, 200))
LineXY(Terre\x, 0, Terre\x, 600, RGB(20, 20, 200))
LineXY(0, Lune\y, 800, Lune\y, RGB(128, 128, 128))
LineXY(Lune\x, 0, Lune\x, 600, RGB(128, 128, 128))
StopDrawing()
FlipBuffers()
Until Quit = #True
Dobro> dans ton code y a un "getsystemmetrics", je trouve pas ce mot dans l'aide, apparemment ça permet d'avoir des infos sur l'affichage, d'où ça vient?
Code : Tout sélectionner
EcranX = GetSystemMetrics_(#SM_CXSCREEN):;=largeur de l'ecran
tu clique sur le bouton [pm] situé en bas de ce message ..Psst j'ai pas envoyé un MP car je sais pas!!(j'ai honte!!!)
Dobro a écrit : quant au
Procedure.f RotationX(X, angle.f, dist)
ProcedureReturn X + Cos (angle.f* #PI /180)*dist
EndProcedure
Procedure.f RotationY(Y, angle.f, dist)
ProcedureReturn Y + Sin (angle.f* #PI /180)*dist
EndProcedure
ces procedures ne sont pas de moi (j'ai oublié qui me les a filé désolé ..)
elle te retourne les coordonées X et Y d'un point situé a "distance" et "angle" du point de depart
ex
point de depart x =50
point de depart y =50
angle= 45 degres
distance du point de depart = 100 pixel
la coordonée X d'arrivé est : 120.710678 (120) <-- ces fonction renvoi un Flottant
la coordonée Y d'arrivé est : 120.710678 (120)
ex :
Declare.f RotationX(X, angle.f, dist)
Declare.f RotationY(Y, angle.f, dist)
#PI =3.1415926
X=50
Y=50
angle.f=45
dist=100
Debug RotationX(X, angle.f, dist)
Debug RotationY(Y, angle.f, dist)
End
Procedure.f RotationX(X, angle.f, dist)
ProcedureReturn X + Cos (angle.f* #PI /180)*dist
EndProcedure
Procedure.f RotationY(Y, angle.f, dist)
ProcedureReturn Y + Sin (angle.f* #PI /180)*dist
EndProcedure
ces procedures ne sont pas de moi (j'ai oublié qui me les a filé désolé ..)
Oops, j'ai dis qqchose qu'il fallait pas dire ???Dobro a écrit :ben tu sais ce que sait , c'est des résidus de test qui reste dans le codelionel_om a écrit :Tu peux m'expliquer pourquoi t'as deux "KillThread()", alors qu'il n'y a pas de CreateThread() ???
bon c'est corrigé !!
je te previens si tu post un code , il a interet a etre nickel , car je vais pas te louper toi
De rien !!!Dobro a écrit :ces procedures ne sont pas de moi (j'ai oublié qui me les a filé désolé ..)
ben j'ai retrouvé qui me les avaient filés ces procedures
c'est :
Lionel_om
donc merci a lui ! ...............