Advice for 'player' in a FPS

Blitz3D Forums/Blitz3D Programming/Advice for 'player' in a FPS

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.

Please excuse the messy test code - like this Ross?

Graphics3D 800,600,16,2

Const c_jumpspeed# = .3
Const c_gravity# = -.016

Global g_game_gravity# = 0
Global g_game_player_jumpspeed# = 0

ground = CreateCube()
ScaleEntity ground, 2,1,2
EntityColor ground, 0,0,255
EntityType ground, 1
EntityPickMode ground, 2

ground1 = CreateCube()
ScaleEntity ground1, 2,1,2
EntityColor ground, 0,0,255
EntityType ground, 1
EntityPickMode ground1, 2
PositionEntity ground1, -4, -4, 0
EntityColor ground, 0,255,0

player = CreateSphere()
PositionEntity player, 0,2,0
EntityColor player, 255,0,0
EntityType player, 2


light=CreateLight()
PositionEntity light, 0, 3, -7
TurnEntity light,45,45,0

cam =  CreateCamera()
PositionEntity cam, -3, 3, -15
PointEntity cam, player
CameraZoom cam,1.6

While Not KeyHit(1)

	If KeyDown(203) MoveEntity player,-.1,0,0
	If KeyDown(205) MoveEntity player,.1,0,0
	If KeyDown(200) MoveEntity player,0,0,.1
	If KeyDown(208) MoveEntity player,-0,0,-.1
	
	If KeyHit(30)
		g_game_player_jumpspeed# = c_jumpspeed#
		g_game_gravity# = c_gravity#
	EndIf
	
	;DebugLog "jumping = " + g_game_player_jumpspeed#
	g_game_player_jumpspeed# =  g_game_player_jumpspeed# + g_game_gravity#
	TranslateEntity player,0, g_game_player_jumpspeed#,0

	If LinePick(EntityX#(player), EntityY#(player), EntityZ#(player), 0, -1, 0) > 0
		g_game_player_jumpspeed# =0
		g_game_gravity# = 0
	Else
		g_game_gravity# = c_gravity#
	EndIf
	
	UpdateWorld	
	RenderWorld

	Text 10,10, "player position " + EntityX#(player) + " " + EntityY#(player) + " " + EntityZ#(player)
	Text 10,30, "linepick        " + LinePick(EntityX#(player), EntityY#(player), EntityZ#(player), 0, -1, 0)
	Text 10,50, "distance        " + EntityDistance#(player, ground)

	Flip

Wend