thrid person game

Blitz3D Forums/Blitz3D Beginners Area/thrid person game

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

ok here is my code:

;SET UP GRAPHICS
Graphics3D 640,480
SetBuffer BackBuffer()

;create camera
Global camera=CreateCamera()
EntityType camera,1
CameraRange camera,0.1,10000

;LOAD EQUIPTMENT
level=LoadMesh("floor.b3d")
PositionEntity level,0,-1,0
;ScaleEntity level,.01,.01,.01
EntityType level,2
EntityPickMode level,2

wall=LoadMesh("walls.b3d")
PositionEntity wall,0,-1,0
EntityType level,3
EntityPickMode level,3

;collisions
Collisions 1,2,2,3
Collisions 1,3,2,3

campivot=CreatePivot()

Global player=CreateCone()
EntityParent campivot,player
PositionEntity campivot,0,0,-7
EntityType player,1

Global jump_force#
Global jump_flag=0; set jump flag to 'no jump'
Global gravity#=0.8; set gravity value

While Not KeyHit(1)
;MoveEntity player,0,-.1,0

If KeyDown(17) Then MoveEntity player,0,0,0.2
If KeyDown(31) Then MoveEntity player,0,0,-0.2
If KeyDown(30) Then TurnEntity player,0,2,0
If KeyDown(32) Then TurnEntity player,0,-2,0

If KeyHit(57) And jump_flag=0 Then; if user presses spacebar
jump_flag=1; set jump flag to 'jump'
jump_force=1.3; set jumping force. make larger for higher jump
End If

If jump_flag=1 Then; if jump flag set then 'jump'
update_jump()
End If


Gosub updatecamera
UpdateWorld
RenderWorld
Flip
Wend
End

.updatecamera
PointEntity camera,campivot
MoveEntity camera,0,0,EntityDistance(camera,campivot)/10
PointEntity camera,player

RotateEntity camera,EntityPitch(player),EntityYaw(player),EntityRoll(player); make the camera equal to the rotations of the camera
PositionEntity camera,EntityX(player),EntityY(camera),EntityZ(player); position the camera at the x and z pos of the player
MoveEntity camera,0,0,-7; move the camera back from the player by 7 units



Return

Function update_jump()

jump_force=jump_force*gravity; apply gravity to the jumping force

MoveEntity player,0,jump_force,0; move the player
If jump_force>0 And jump_force<0.05 Then; when players upward speed reaches alomost zero, reverse it
; make smaller to keep player in the air for longer
jump_force=jump_force*-1; reverse the jumping force
gravity=gravity+(2*(1-gravity)); turn gravity around
End If
If jump_force<-0.5 Then jump_force=-0.5; stop the player from falling to quick
If EntityCollided(player,2) Then; if the player has collided with the ground
jump_force=0; reset the jumping force
jump_flag=0; reset jump flag back to zero (not jumping)
gravity=gravity-(2*(gravity-1)); reset gravity
End If
End Function

please reply soon.