Hi all. I just wrote this quickly about 15 minutes ago, while trying to make some form of first person game. This is all I've got so far:
Graphics3D 800,600,32,1
SetBuffer BackBuffer()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Global font=LoadFont( "Lucida Console",18 )
SetFont font
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Global cam=CreateCamera()
PositionEntity cam,0,5,-3
Global campiv=CreatePivot()
EntityParent cam,campiv
;CameraFogMode cam,1
;CameraFogColor cam,200,230,235
;CameraFogRange cam,1,2000
CameraRange cam,1,115000
CameraClsColor cam,0,20,30
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mainlight=CreateLight()
LightColor mainlight,230,240,255
PositionEntity mainlight,10,3,7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Global level=LoadMesh( CurrentDir()+"/building.3ds" )
Global leveltex=LoadTexture( CurrentDir()+"/buildingmap.bmp" )
EntityTexture level,leveltex
EntityAlpha level,1
EntityShininess level,0.5
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Const levelcol=0
Const camcol=1
EntityType level,levelcol
EntityType cam,camcol
Collisions camcol,levelcol,2,1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Global sky=CreateSphere(64)
FlipMesh sky
ScaleEntity sky,2000,2000,2000
skytex=LoadTexture( CurrentDir()+"/sky.bmp" )
ScaleTexture skytex,0.5,0.5
EntityTexture sky,skytex
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
While Not KeyHit(1)
TurnEntity sky,0.1,0.05,-0.2
If KeyDown(17) Then MoveEntity cam,0,0,1.6
If KeyDown(31) Then MoveEntity cam,0,0,-1.6
If KeyDown(30) Then MoveEntity cam,-1.6,0,0
If KeyDown(32) Then MoveEntity cam,1.6,0,0
mxspd#=MouseXSpeed()*0.25
myspd#=MouseYSpeed()*0.25
mxspd=mxspd*0.6
myspd=myspd*0.6
campitch=campitch+myspd
If campitch<-85 Then campitch=-85
If campitch>85 Then campitch=85
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
RotateEntity cam,campitch,EntityYaw(cam)-mxspd,0
RotateEntity cam,campitch,EntityYaw(cam)-mxspd,0
If EntityCollided(cam,levelcol) Then
Text 400,300,"Collision Detected",True,True ;Why doesn't this...
MoveEntity cam,0,0,0 ;...or this work?
EndIf
RenderWorld()
UpdateWorld()
Flip
Wend
End
Everything works, except for the collisions. It's probably just some thing I haven't done or I've mispelled something, can anyone tell me why the collisions aren't working?
|