et le rayon que fera le virage (on parle en degrés)
Le pgm genere le centre de rotation
Tu appuis sur Space pour commencer le virage.
Code : Tout sélectionner
; Fichiers Include
IncludePath "Include\" : IncludeFile "dreamotion3d.pbi"
Global *sp1.CSprite2D
; Initialisation des différents modules
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
End
EndIf
; Initialise la fenêtre graphique
DM_Graphics3D(800, 600, 32, 0, 1)
SetCurrentDirectory("media/")
;----------------
; Charge un petit sprite
;----------------
;position intiale du sprite
pos_sp_x = 200
pos_sp_y = 200
; son angle d'attaque du moment
AngDeg.f=40
; rayon de virage
Rayon = 50
; chargement et positionnement
*sp1 = DM_LoadSprite2D("sp1.png", pos_sp_x,pos_sp_y)
DM_RotateSprite2D(*sp1, AngDeg)
; calcul du point central du futur virage
Centre_X = pos_sp_x + Cos((AngDeg+180)*#PI/180) * Rayon
Centre_Y = pos_sp_y + Sin((AngDeg+180)*#PI/180) * Rayon
flag.c = #False
Repeat
ExamineKeyboard()
If KeyboardReleased(#PB_Key_Escape) Or WindowEvent()=#PB_Event_CloseWindow
Quit=1
EndIf
If KeyboardReleased(#PB_Key_Space)
flag=#True
EndIf
If flag
AngDeg + 0.5
Pos_X = Centre_X + Rayon * Cos(AngDeg*#PI/180)
Pos_Y = Centre_Y + Rayon * Sin(AngDeg*#PI/180)
DM_PositionSprite2D(*sp1, Pos_X, Pos_Y)
DM_RotateSprite2D(*sp1, AngDeg)
EndIf
; ---------------
; Rendu
; ---------------
DM_BeginScene()
DM_ClsScreen(0,0,0)
DM_DrawSprite2D(*sp1)
DM_EndScene()
Until Quit=1
DM_ClearGraphics()
End