Ma Version (atention soyez patient c'est lent !!) <- d'ailleurs je comprend pas pourquoi le point() sois si lent .....
; 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