Hi
Could someone help me with this code?
I am trying to make the camera stop moving when it comes into contact with the ground. Don't bother running it, though, because it your computer won't have the hieghtmap images, etc.
;-----------------------------------------------------------
Graphics3D 640,480 ;set the graphics
AntiAlias=True
SetBuffer BackBuffer() ;set the buffer
;;;;;;;;;;;;;;;;;;;;;;;
;; make stuff ;;
;;;;;;;;;;;;;;;;;;;;;;;
piv=CreatePivot
cam1=CreateCamera()
EntityParent cam1,piv
light=CreateLight()
brush1=CreateBrush(tex1)
brush2=CreateBrush(tex2)
tex1=LoadTexture( "C:/SEANS FILES/texture1.bmp" )
tex2=LoadTexture( "C:/SEANS FILES/texture2.bmp" )
BrushTexture brush1,tex1
BrushTexture brush2,tex2
AmbientLight 255,255,255
grass_tex=LoadTexture( "C:/SEANS FILES/grasstex.bmp" )
ship=LoadMesh( "media/geometricks_models/fighter/fighter.3ds" )
water_tex=LoadTexture( "C:/water.bmp" )
grass_tex=LoadTexture( "C:/SEANS FILES/grasstex.bmp" )
sky_tex=LoadTexture( "C:/sky.bmp" )
; Load terrains
terrain=LoadTerrain( "C:/hieghtmap.bmp" )
water=LoadTerrain( "C:/watermap.bmp" )
; Scale terrain
ScaleEntity terrain,1,60,1
ScaleEntity water,1,90,1
; Texture terrain
EntityTexture terrain,grass_tex,0,1
EntityTexture water,water_tex,0,1
; Set terrain detail, enable vertex morphing
TerrainDetail terrain,4000,True
TerrainDetail water,4000,True
;;;;;;;;;;;;;;;;;;;;;;;
;; do stuff ;;
;;;;;;;;;;;;;;;;;;;;;;;
Const cam_col=1
Const ground_col=2
EntityType cam1,cam
EntityType terrain,ground
Collisions cam1,ground,2,1
;;;;;;;;;;;;;;;;;;;;;;;
;; move stuff ;;
;;;;;;;;;;;;;;;;;;;;;;;
RotateEntity light,100,0,0
RotateEntity cam1,45,0,0
CameraViewport cam1,0,0,GraphicsWidth(),GraphicsHeight()
PositionEntity terrain,0,0,0
PositionEntity water,0,0,0
PositionEntity cam1,100,13,100
RotateEntity cam1,0,0,0
;;;;;;;;;;;;;;;;;;;;;;;
;; controls ;;
;;;;;;;;;;;;;;;;;;;;;;;
While Not KeyHit(1)
Print"Sean's first go at a 3D game. Use the cursor keys to move about :)"
roll#=0 MoveEntity cam1,0,0,0.5 ;move forwards
If KeyDown (203)=True Then roll#=0 TurnEntity cam1,0,1,0 ;turn left
If KeyDown (205)=True Then roll#=0 TurnEntity cam1,0,-1,0;turn right
If EntityCollided(cam1,terrain) Then Print "Collided!"
RenderWorld
UpdateWorld
Flip
Wend
End
;-----------------------------------------------------------
Thanks
Could someone help me with this code?
I am trying to make the camera stop moving when it comes into contact with the ground. Don't bother running it, though, because it your computer won't have the hieghtmap images, etc.
;-----------------------------------------------------------
Graphics3D 640,480 ;set the graphics
AntiAlias=True
SetBuffer BackBuffer() ;set the buffer
;;;;;;;;;;;;;;;;;;;;;;;
;; make stuff ;;
;;;;;;;;;;;;;;;;;;;;;;;
piv=CreatePivot
cam1=CreateCamera()
EntityParent cam1,piv
light=CreateLight()
brush1=CreateBrush(tex1)
brush2=CreateBrush(tex2)
tex1=LoadTexture( "C:/SEANS FILES/texture1.bmp" )
tex2=LoadTexture( "C:/SEANS FILES/texture2.bmp" )
BrushTexture brush1,tex1
BrushTexture brush2,tex2
AmbientLight 255,255,255
grass_tex=LoadTexture( "C:/SEANS FILES/grasstex.bmp" )
ship=LoadMesh( "media/geometricks_models/fighter/fighter.3ds" )
water_tex=LoadTexture( "C:/water.bmp" )
grass_tex=LoadTexture( "C:/SEANS FILES/grasstex.bmp" )
sky_tex=LoadTexture( "C:/sky.bmp" )
; Load terrains
terrain=LoadTerrain( "C:/hieghtmap.bmp" )
water=LoadTerrain( "C:/watermap.bmp" )
; Scale terrain
ScaleEntity terrain,1,60,1
ScaleEntity water,1,90,1
; Texture terrain
EntityTexture terrain,grass_tex,0,1
EntityTexture water,water_tex,0,1
; Set terrain detail, enable vertex morphing
TerrainDetail terrain,4000,True
TerrainDetail water,4000,True
;;;;;;;;;;;;;;;;;;;;;;;
;; do stuff ;;
;;;;;;;;;;;;;;;;;;;;;;;
Const cam_col=1
Const ground_col=2
EntityType cam1,cam
EntityType terrain,ground
Collisions cam1,ground,2,1
;;;;;;;;;;;;;;;;;;;;;;;
;; move stuff ;;
;;;;;;;;;;;;;;;;;;;;;;;
RotateEntity light,100,0,0
RotateEntity cam1,45,0,0
CameraViewport cam1,0,0,GraphicsWidth(),GraphicsHeight()
PositionEntity terrain,0,0,0
PositionEntity water,0,0,0
PositionEntity cam1,100,13,100
RotateEntity cam1,0,0,0
;;;;;;;;;;;;;;;;;;;;;;;
;; controls ;;
;;;;;;;;;;;;;;;;;;;;;;;
While Not KeyHit(1)
Print"Sean's first go at a 3D game. Use the cursor keys to move about :)"
roll#=0 MoveEntity cam1,0,0,0.5 ;move forwards
If KeyDown (203)=True Then roll#=0 TurnEntity cam1,0,1,0 ;turn left
If KeyDown (205)=True Then roll#=0 TurnEntity cam1,0,-1,0;turn right
If EntityCollided(cam1,terrain) Then Print "Collided!"
RenderWorld
UpdateWorld
Flip
Wend
End
;-----------------------------------------------------------
Thanks