trouble with coins

Blitz3D Forums/Blitz3D Beginners Area/trouble with coins

AvestheFox(Posted 2005) [#1]
I cant get the coins to disapear when the player collides with them... alsoI'm trying to get them all to rotate... which I cant figure out how to use types properly =P

can someone help me pleaze???

Graphics3D 600,600,32,2
SetBuffer BackBuffer()

Const tbob=1
Const tcoin=2

Type coin
Field colision
End Type

camera=CreateCamera()
CameraClsColor camera,0,100,100
l=CreateLight()
PositionEntity camera,5,5,-15

bob=CreateSphere()
coin=CreateSphere() 

EntityColor coin,100,100,0
ScaleEntity coin,.1,.5,.5
EntityShininess coin,1

PositionEntity bob,-3,0,0
EntityColor bob,0,100,100

EntityType bob,tbob
EntityType coin,tcoin

Collisions tbob,tcoin,1,1

For c.coin=Each coin
If EntityCollided(bob,coin)
	c\colision=CountCollisions(bob)
	If c\colision>0
	HideEntity coin
		Delete c
		collectball=collectball+1
	EndIf
EndIf  
Next

For x=0 To 5
For y=0 To 5
CopyEntity coin 
PositionEntity coin,x*3,y*3,0
Next
Next

While Not KeyHit(1)

If KeyDown(205) MoveEntity bob,.2,0,0
If KeyDown(203) MoveEntity bob,-.2,0,0
If KeyDown(200) MoveEntity bob,0,.2,0
If KeyDown(208) MoveEntity bob,0,-.2,0

TurnEntity coin,1,1,1

colidecount=CountCollisions(bob)

RenderWorld
UpdateWorld
Text 0,0,"Use arrow keys to control Bob"
Text 0,12,"colision count on Bob = "+colidecount
Text 400,0,"Gold Coins Collected = "+collectball
Flip
Wend
End






Luke.H(Posted 2005) [#2]



Matty(Posted 2005) [#3]
EDIT: Did not see earlier post (wasn't there when I typed this)

try this:
graphics3d 600,600,32,2
setbuffer backbuffer()

type coinobj

field enthandle

end type

bob=createsphere(8)
camera=createcamera(bob)
moveentity camera,7,-7
pointentity camera,bob
entitytype bob,1
entityradius bob,1.0


for x=0 to 5
for z=0 to 5
coin.coinobj=new coinobj
coin\enthandle = createsphere()
entitytype coin\enthandle,2
entityradius coin\enthandle,1.0
positionentity coin\enthandle,x*3,0,z*3
next
next

collisions 1,2,1,2

repeat

if keydown(200) then moveentity bob,0,0,0.2
if keydown(208) then moveentity bob,0,0,-0.2
if keydown(203) then turnentity bob,0,1,0
if keydown(205) then turnentity bob,0,-1,0

for colid=1 to countcollisions(bob)
   for coin.coinobj=each coinobj
     if collisionentity(bob,colid)=coin\enthandle then hideentity coin\enthandle
   next
next

for coin.coinobj=each coinobj
turnentity coin\enthandle,0,0.5,0
next

updateworld
renderworld
flip

until keydown(1)
end





AvestheFox(Posted 2005) [#4]
darn that explains allot =P .. so I'd have to make the entity's type from within the "c.coin=new coin" command and declair it a field under the type's field listing

thanks allot!! ^_^ (Matty and Luke)