Hiding an entity upon colision

Blitz3D Forums/Blitz3D Beginners Area/Hiding an entity upon colision

The code below *should* work, though i haven't had time to test it.

---------------------------------------------------- 
Graphics3D 530,340 
SetBuffer BackBuffer() 

Const bob_type=1 
Const wld_type=2 
Const coin_type=3 

;--Camera------------------------- 
cam=CreateCamera() 
CameraClsColor cam,999,999,999 
CameraFogMode cam,1 
CameraFogRange cam,0,100 
CameraFogColor cam,999,999,999 
CameraViewport cam,0,0,800,600 
MoveEntity cam,0,5,-20 

light=CreateLight() 
;--------------------------------- 

;--Player------------------------- 
bob=CreateSphere() 
PositionEntity bob,0,0,0 
EntityType bob,bob_type 

t2=CreateCube() 
ScaleEntity t2,1,1,1 
PositionEntity t2,0,1,0 
EntityColor t2,800,43,25 
EntityAlpha t2,0 

EntityParent cam,t2 
;---------------------------------- 

;--Coins (for now)----------------- 
coin=CreateSphere() 
ScaleEntity coin,0.5,0.5,0.5 
EntityColor coin,100,50,100 
EntityType coin,coin_type 
PositionEntity coin,5,0,0 

CopyEntity coin 
PositionEntity coin,10,0,0 
CopyEntity coin 
PositionEntity coin,15,0,0 
CopyEntity coin 
PositionEntity coin,20,0,0 
CopyEntity coin 
PositionEntity coin,20,0,-5 
CopyEntity coin 
PositionEntity coin,20,0,-10 
CopyEntity coin 
PositionEntity coin,20,0,-15 
;----------------------------------- 


;--world---------------------------- 
wld=CreatePlane() 
PositionEntity wld,0,-5,0 
grs= LoadTexture("grass.bmp") 
ScaleTexture grs,20,20 
EntityTexture wld,grs 
EntityType wld,wld_type 
;------------------------------------ 

Collisions bob_type,wld_type,2,2 
collisions bob_type,coin_type,2,2

gravity#=.03 
jumpvel#=.9 

While Not KeyHit(1) 


If KeyDown(200) MoveEntity bob,0,0,0.5 MoveEntity t2,0,0,0.5 
If KeyDown(208) MoveEntity bob,0,0,-0.5 MoveEntity t2,0,0,-0.5 
If KeyDown(203) MoveEntity bob,-0.5,0,0 MoveEntity t2,-0.5,0,0 
If KeyDown(205) MoveEntity bob,0.5,0,0 MoveEntity t2,0.5,0,0 
PointEntity cam,t2 

If jumping=0 
If KeyDown(54) Then yvel#=jumpvel# jumping=1 
EndIf 
If jumping=1 
yvel#=yvel#-gravity# 
by#=by#+yvel# 
EndIf 

If by#<1 Then by#=1 yvel#=0 jumping=0 

speed#=speed#*.99 
MoveEntity bob,0,yvel#,speed# 

if countcollisions(bob) > 0 then
    if entitycollided(bob, coin_type) > 0 then
        freeentity entitycollided(bob, coin_type)
        updateworld()
    endif
endif

UpdateWorld 
RenderWorld 

Flip 
Wend 

End