y am i walking on walls?

Blitz3D Forums/Blitz3D Beginners Area/y am i walking on walls?

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.

i have 2 questions:
1. y am i walking on the walls
2. y can't i jump every time i press space

if anybody could answer those that would be great
thanks, Rubiks14

; set up the graphics
Graphics3D 800,600
;set up the back buffer
SetBuffer BackBuffer()

; some globals
Global PlayerGrav# = 0.0
Global Grav# = 0.2
Global jumped = 0
; collision groups
Global PLAYER = 1
Global SCENERY = 2

; create a light
AmbientLight 255,255,255

; create a camera
Global camera = CreateCamera()
; give the camera a distance
CameraRange camera,1,600
; give the camera the same type as the pivot
EntityType camera,PLAYER

; create a pivot for the camera
Global camera_pivot = CreatePivot()
; give a radius to the pivot
EntityRadius camera_pivot,7.5
; make a type for the piivot
EntityType camera_pivot,PLAYER
; move the player to the middle of the map
PositionEntity camera_pivot,10,0,10

; load the level
Global level = LoadMesh("my little map.x")
ScaleEntity level,20,20,20
EntityType level,SCENERY

; load the gun mesh
Global gun = LoadMesh("gloc.3ds",camera)
; load the gun texture
weapon_tex2 = LoadTexture("glocmap.jpg")
; texture the gun
EntityTexture gun,weapon_tex2
; rotate the gun
RotateEntity gun,12,170,14
; scale the gun
ScaleEntity gun,0.01,0.01,0.01
; position the gun a little behind the camera
PositionEntity gun,1,-1,1.5
; draw the gun last
EntityOrder gun, -1

; collisions
Collisions PLAYER,SCENERY,2,3
Collisions SCENERY,PLAYER,2,3

; main loop
While Not KeyHit(1)


MovePlayer()
TurnPlayer()

; the player is moving down
PlayerGrav# = PlayerGrav# - Grav#
	
; give gravity to the level
If EntityCollided(camera_pivot,SCENERY)
	; player gravity is 0
	PlayerGrav# = 0.0
	; player not jumping
	jumped = 0
EndIf
	
; position the camera with the pivot
PositionEntity camera,EntityX#(camera_pivot),EntityY#(camera_pivot),EntityZ#(camera_pivot)

; move the camera to current gravity force
TranslateEntity camera_pivot,0,PlayerGrav#,0

; update the world	
UpdateWorld
; draw the world
RenderWorld
; flip the buffers
Flip
; end of main loop
Wend
; end of program
End

Function MovePlayer()

; move the player foward when player presses w
If KeyDown(17) Then MoveEntity camera_pivot,0,0,2
; move the player back when player presses s
If KeyDown(31) Then MoveEntity camera_pivot,0,0,-1
; move the player left when player presses a
If KeyDown(30) Then MoveEntity camera_pivot,-2,0,0
; move the player right when player presses d
If KeyDown(32) Then MoveEntity camera_pivot,2,0,0
; make the player jump if player presses space
If KeyHit(57) And jumped = 0
	; make the player jump
	PlayerGrav# = 3
	; the player has jumped
	jumped = 1
EndIf

End Function

Function TurnPlayer()

; turn the player with the mouse
TurnEntity camera_pivot,0,-MouseXSpeed(),0
; make the player look up and down
TurnEntity camera,MouseYSpeed(),0,0
; z roll correction
RotateEntity camera_pivot,EntityPitch#(camera_pivot),EntityYaw#(camera_pivot),0
; z roll correction
RotateEntity camera,EntityPitch#(camera),EntityYaw#(camera_pivot),0
; move the mouse to the center of the screen
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2

End Function