problem with types, i'm officially confused

Blitz3D Forums/Blitz3D Programming/problem with types, i'm officially confused

mtnhome3d(Posted 2009) [#1]
OK i was going through some posts and saw a solution to a problem the other day, and it made me go check on an old piece of code. in checking the old piece of code, i found that the problems was not the same as in the post but i still tried to fix it. i have "pruned" my code and tried fixing it several ways but i cant get it to work. here it is:


what happens, is that when i run into my power-up, its supposed to activate a timer and do a certain effect. the part i can't get to work is the removal of the one object. what happens right now is that it activates and then it deletes all the other power ups any help would be nice.


Ross C(Posted 2009) [#2]
May i suggest you using a timer based on millisecs()

Timer = millsecs()
Time_duration = 1000 ; one whole second

repeat


until millisecs() > timer + time



That's the basic idea behind a timer. It doesn't rely on frames per second.

I'm looking at your code.


Ross C(Posted 2009) [#3]
This line:

If EntityCollided (p\e,pikup)


Your not checking against each type object, mearly the same mesh over and over again. This may be causing a problem, as it would be testing all pickup objects, against the one health pickup, so if the player hits into this one pickup, they all will get deleted. I can't test it as i'm at work though, but i'm sure that's your problem.

If EntityCollided (p\e,o\e)


Should work?


mtnhome3d(Posted 2009) [#4]
thank you, I knew it would probably be something simple.


Stevie G(Posted 2009) [#5]
Well, actually - that won't work. EntityCollided's second parameter is the entitytype, not the entity itself.

What you need to identify is which pick up a player has collided with.

for c = 1 to countcollisions( p\e )
   if collisionentity( p\e, c ) = o\e
       o\Active = true
   endif
next


There are better and more efficient ways of handling this - specifically using the object and handle commands. It saves you iterating through them all to find the one collided with. e.g.

When you create your pickup instance ..

o.pickup = new pickup
o\e = createcube()
nameentity o\e, handle( o )


To determine which pickup the player has collided with

Entity = entitycollided( p\e, pikup )
if Entity > 0
     o.pickup = object.pickup( entityname( Entity ) )
     o\Active = true
     ;other stuff
endif



mtnhome3d(Posted 2009) [#6]
Thank you Stevie G, I didn't know how to use the object and handle commands. They really need to be documented. I'll try this solution.


_PJ_(Posted 2009) [#7]
object and handle commands. They really need to be documented

Here Here!!!


H. T. U.(Posted 2009) [#8]
Mortis showed me this site a few months ago:

http://www.hpquest.com/techlord/apps/AOBPwB3D/