利用物理公式:
Vx = Vx
Vy = Vy + a*t
X = X + Vx*t
Y = Y + Vy*t + 1/2*a*t*^2
'宣告
Dim Position As Vector2
Dim V As Vector2
Dim a As Integer
'初始
Position = New Vector2(0, 420)
a = 60
V = New Vector2(150, -150)
'update
V.Y = V.Y + CInt(a * gameTime.ElapsedGameTime.TotalSeconds)
Position.X = Position.X + CInt(V.X * gameTime.ElapsedGameTime.TotalSeconds)
Position.Y = Position.Y + CInt(V.Y * gameTime.ElapsedGameTime.TotalSeconds) + CInt(0.5 * a * (gameTime.ElapsedGameTime.TotalSeconds) ^ 2)
'draw
spriteBatch.DrawString(txtFont, txt, Position, Color.Red)
影片
http://www.youtube.com/watch?v=3_k08C-Rwsw
沒有留言:
張貼留言