Et j'ai un petit souci.
je voudrais pouvoir calculer sa position non pas depuis l'écart de temps (lancement du projectile et maintenant) mais depuis l'écart de temps (dernier calcule de position et maintenant)
Je sais pas si je suis claire.
est ce quelqu'un a une idée ? Merci d'avance
Code : Tout sélectionner
Structure Projectile
X.f
Y.f
Force.f
Angle.f
Time.l
EndStructure
Global NewList Projectile.Projectile()
Procedure AddProjectile(X.l,Y.l,Force.l,Angle.l)
AddElement(Projectile())
Projectile()\X=X
Projectile()\Y=Y
Projectile()\Force=Force
Projectile()\Angle=Angle
Projectile()\Time=ElapsedMilliseconds()
EndProcedure
AddProjectile(0,300,20,-45)
DeltaTime.f=0
If InitSprite() = 0 Or InitKeyboard() = 0
MessageRequester("Error", "Can't open DirectX 7 or later", 0)
End
EndIf
If OpenWindow(0,0,0,800,600,"A screen in a window... using gadget and sprites!",#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,800,600,0,0,0)
EndIf
Repeat
Event.l = WindowEvent()
FlipBuffers() ; Inverse the buffers (the back become the front (visible)... and we can do the rendering on the back
ExamineKeyboard()
DeltaTime=(ElapsedMilliseconds()-Projectile()\Time)/100
Projectile()\X = Projectile()\Force * (Cos(Projectile()\Angle * 0.0174533) * DeltaTime) + Projectile()\X
Projectile()\Y = (9.81 / 2 * DeltaTime * DeltaTime) + (Projectile()\Force * Sin(Projectile()\Angle * 0.0174533) * DeltaTime) + Projectile()\Y
StartDrawing(ScreenOutput())
Circle(Projectile()\X,Projectile()\Y,10,#Red)
StopDrawing()
Delay(1)
Until Event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
End