Code : Tout sélectionner
; ------------------------------------------------------------
; rotation à base de cosinus et sinus
; ------------------------------------------------------------
UsePNGImageDecoder () ;
If InitMouse ()=0 Or InitSprite ()=0 Or InitKeyboard ()=0 Or InitSprite3D ()=0
MessageRequester ( "Error" , "Can't open DirectX 7 or later" , 0)
End
EndIf
Enumeration ; ici, on donne un petit nom à nos sprites:
#disque
#disque3D
#pic
#pic3D
EndEnumeration
If OpenScreen (1024, 768, 32, "SpecialFX -> no problemo" )=0 ; basse résolution, mais en 32bit.
MessageRequester ( "Error" , "Can't open a 640*480 - 32 bit screen !" , 0)
End
EndIf
CreateSprite ( #disque ,64,64, #PB_Sprite_Texture ) ; disque intéractif
StartDrawing ( SpriteOutput ( #disque ))
BackColor ( RGB (0,0,0))
Circle (32,32,32, RGB (255,0,0))
StopDrawing ()
CreateSprite3D ( #disque3D , #disque )
CreateSprite ( #pic ,32,32, #PB_Sprite_Texture ) ; objet tournant autour du disque
StartDrawing ( SpriteOutput ( #pic ))
BackColor ( RGB (0,0,0))
Box (0,0, 32, 32, RGB (158,5,5))
StopDrawing ()
CreateSprite3D ( #pic3D , #pic )
;****************************
;création des tables de sinus et de cosinus.
;****************************
Dim x_sin.l(360)
Dim y_cos.l(360)
For i=1 To 360
x_sin(i)=Sin(i)*128;16
y_cos(i)=Cos(i)*128;16
Next
; ******************************************************************************************************
Repeat ; Boucle principale
; ******************************************************************************************************
FlipBuffers (): ClearScreen ( RGB (0,0,0))
ExamineMouse():ExamineKeyboard ()
StartDrawing ( ScreenOutput ())
AdresseMemoire = DrawingBuffer ()
For i=1 To 360
Plot(512+x_sin(i),384+y_cos(i),RGB ($F2,$FF,$EA))
Next i
StopDrawing ()
; **************************************************************************************************
Start3D ()
Ttourne+1
If Ttourne>10
Ttourne=0:tourne+1
If tourne=361:tourne=1:EndIf
EndIf
DisplaySprite3D ( #pic3D , MouseX ()+16+x_sin(tourne), MouseY ()+40+y_cos(tourne),255)
DisplaySprite3D ( #disque3D , MouseX (), MouseY ()+40,125)
Stop3D ()
; **************************************************************************************************
Gosub fps ; nombre d'image par seconde
Until KeyboardPushed ( #PB_Key_Escape ): End ; fin de la boucle principale (appuyez sur la touche Esc)
fps:
If Val ( FormatDate ( "%ss" , Date ()))=sek
fps+1
Else
FPS$= Str (fps)
fps=0
EndIf
sek= Val ( FormatDate ( "%ss" , Date ()))
StartDrawing ( ScreenOutput ())
DrawingMode (1)
FrontColor ( RGB (255,255,255))
DrawText (1,1, "FPS: " +FPS$)
StopDrawing ()
Return
