this jumping crap is starting to make me mad

Blitz3D Forums/Blitz3D Beginners Area/this jumping crap is starting to make me mad

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.


can u do that so i can just put it in my code bc i just tried and i must have done it wrong bc my camera screws up now



Here's a "bare bones" effort that should illustrate most of the stuff you need (with simple placeholder objects and textures).

;system
Graphics3D 640,480,0,1
SetBuffer BackBuffer()
HidePointer

;player
player=CreateCube()

;camera
cam=CreateCamera(player)
CameraRange cam,.1,50
CameraFogMode cam,1
CameraFogRange cam,20,30

;level
level=CreatePlane();SHUTIT!
PositionEntity level,0,-2,0
levelTex=CreateTexture(64,64)
SetBuffer TextureBuffer(levelTex) 
Color 0,255,0 : Rect 0,0,64,64
Color 0,0,255 : Rect 0,0,32,32 : Rect 32,32,32,32
ScaleTexture leveltex,2,2
EntityTexture level,levelTex

;sky
sky=CreateSphere(32,player)
FlipMesh sky
EntityOrder sky,1
skyTex=CreateTexture(512,512)
SetBuffer TextureBuffer(skyTex)
For i=0 To 400
Color Rnd(0,255),Rnd(0,255),Rnd(0,255)
Plot Rnd(0,511),Rnd(0,511) 
Next 
EntityTexture sky,skyTex
SetBuffer BackBuffer()

;collisions
EntityType player,1
EntityType level,2
Collisions 1,2,2,2

;vars
yVel#=0


RotateEntity player,0,0,0
RotateEntity cam,0,0,0,True


While Not KeyDown(1)

;mouselook
my#=MouseYSpeed()*.5
If my#>3 Then my#=3
If my#<-3 Then my#=-3

TurnEntity player,0,-MouseXSpeed()*.3,0
TurnEntity cam,-my#,0,0

If EntityPitch(cam)>0 And EntityPitch(cam)>60 Then RotateEntity cam,60,EntityYaw(cam),EntityRoll(cam)
If EntityPitch(cam)<0 And EntityPitch(cam)<-40 Then RotateEntity cam,-40,EntityYaw(cam),EntityRoll(cam)

MoveMouse 320,240

;jumping
For i=0 To CountCollisions(player)
	If i>0
		If CollisionEntity(player,i)=level
			yVel=0
			If KeyDown(57) Then yVel=.1
		EndIf
	EndIf
Next

;movement
If KeyDown(30) Then MoveEntity player,-.05,0,0 
If KeyDown(32) Then MoveEntity player,.05,0,0
If KeyDown(17) Then MoveEntity player,0,0,.05
If KeyDown(31) Then MoveEntity player,0,0,-.05


;simple gravity
TranslateEntity player,0,yVel,0
yVel=yVel-.004


;sky
RotateEntity sky,EntityPitch(sky),-EntityYaw(player),EntityRoll(sky)


UpdateWorld
RenderWorld
Flip

Wend


Hopefully you should be able to apply the jumping stuff to your code without too much trouble. The mouselook is hardly exemplary but gives you an idea about how to constrain the "head" a bit.