Sign in to follow this  

collisions not adding up right!

This topic is 3679 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

whenever i destroy something my score# goes up 1 right? but whenever i kill all 100 enemies the score is almost never 100 sometimes its 97 sometimes 105 its weird! ;creating the enemies code Dim alien(100) for b=1 to 100 alien(b)=loadmesh("alien.b3d") ;my collisions code If CountCollisions(bullet(q)) crash=CollisionEntity(bullet(q),1) HideEntity crash score#=score#+1 PlaySound explosion EndIf [Edited by - zabo on November 21, 2007 9:08:45 PM]

Share this post


Link to post
Share on other sites
The answer I can conclude from the information given is :

34

You might need to give a little more information on the program before any help can be given.

Share this post


Link to post
Share on other sites
Quote:
Original post by zabo
whenever i destroy something my score# goes up 1 right? but whenever i kill all 100 enemies the score is almost never 100 sometimes its 97 sometimes 105 its weird!

;creating the enemies code
Dim alien(100)
for b=1 to 100
alien(b)=loadmesh("alien.b3d")

;my collisions code
If CountCollisions(bullet(q))
crash=CollisionEntity(bullet(q),1)
HideEntity crash
score#=score#+1
PlaySound explosion
EndIf

The only problem I see in this particular piece of code is that you're loading the same mesh 100 times. That's a waste of memory and disk access. Load it once, and draw it a 100 times, using the enemy locations.

Actually, what does HideEntity do? Something tells me that it isn't removing the 'crash' object, so it might be that you're still hitting invisible enemies, which would cause higher scores. It might also be that 'crash' isn't a single entity, but a list of entities (after all, a bullet could hit multiple enemies at once), which could cause the lower scores. In other words, more information is required for us to spot the problem.

Quote:
Original post by zabo
nothing seems wrong...... darn it wats the problem with it?

That's because you assume that every line does what you want it to do. Drop those assumptions and make sure every line is doing what it should do. A debugger can greatly help here, so if you have one, learn to use it. Otherwise, print some info to the console or a log file and see where things go different than expected. With some practice, you can become better at pinpointing problems such as these.

Share this post


Link to post
Share on other sites
I'm assuming that whatever language you are using allows the evaluation of numerals to a Boolean value.

In your case, it seems that your line If CountCollisions(bullet(q)) is returning the number of collisions with enemies (based on the name). In this case, a nonzero returned value will evaluate to "true" and the block will run.

However, if CountCollisions returns 2 or more (more than one enemy hit in the frame?) the block will only be evaluated once, since both '1' and '2' evalute to "true" when used in a Boolean context.

Of course, this is all on the assumption that CountCollisions returns a number and not a boolean value. If it only returns a boolean value you should rename the function to something like HasCollided.


Mord, I've waited for months to pull this one out.

Share this post


Link to post
Share on other sites
captain p you are probably right about my highscores. thanks for the tip on saving memory space! Ravuya you are probably right about my low scores . THANKS GUYS!

Share this post


Link to post
Share on other sites

This topic is 3679 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this