help me with inertia !!!

BlitzMax Forums/BlitzMax Beginners Area/help me with inertia !!!

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

A very basic implementation could be:

Type TPlayer

	Field X:Float
	Field Y:Float
	
	Field X_Speed:Float
	Field Y_Speed:Float
	
	Const Friction:Float = 0.90
	
	
	Method Draw()
	
		DrawOval X, Y, 10,10

	EndMethod
	
	Method Update()
	
		X_Speed:*Friction
		Y_Speed:*Friction
	
		X:+X_Speed
		Y:+Y_Speed
		
		Self.Draw()
	
	EndMethod
	

EndType


Graphics 800,600

Const Offset:Float = 1.0

Local Player:TPlayer = New TPlayer

Player.X = GraphicsWidth() / 2
Player.Y = GraphicsHeight() / 2

While Not KeyDown(KEY_ESCAPE)

	If KeyDown(KEY_LEFT) Then 
		Player.X_Speed:-Offset
	End If

	If KeyDown(KEY_RIGHT) Then 
		Player.X_Speed:+Offset
	End If

	If KeyDown(KEY_UP) Then 
		Player.Y_Speed:-Offset
	End If
	
	If KeyDown(KEY_DOWN) Then 
		Player.Y_Speed:+Offset

	End If
	
	Cls
    ' my ship ;-)
	Player.Update()
	Flip
	
Wend