# Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

### DarkBASIC Discussion / Bullets slow the game...

Message
Posted: 7th Oct 2002 23:27
I have a blaster type weapon where it fires up to 10 slow moving bullets across the screen (ala tribes 2 blaster weapon), but in order to tell if they hit the enemy I have to do a collision check for each one. This slows down the game horribly.I cant do it in a straigt line because if you fire one, turn, then fire the other, that's 2 different paths to check. And I cant check if the enemy is being hit because the level uses the same collision (make collision box, if object collision). Any ideas how to keep the bullet count up, but the speed up also?
Posted: 8th Oct 2002 00:22
Are you checking for collision on every loop? Or are you doing distance-checks?

400 Mhz, 120 Meg, TNT2 - and then some...
Posted: 8th Oct 2002 01:08
Checking distance won't work for projectile weapons. Especially slow moving ones. What if: Something moved into the path of the projectile, this would be the new collision distance.

Posted: 25th Oct 2002 19:02
i have a little math code that could solve your problem. it is cos and sin which worked for me. if i know what you are talking about, what it does,is determine if something is going to be in the way of a fast moving object like a bullet. instead of having something go 1000 units fast and actually pass through the object object with out touching it to see if it colliodes(faces overlaping) you could use this. if this is what you need then i could tell you how to use it, otherwise i dont know what your thinking about.

Posted: 30th Oct 2002 17:00
Don't do a collision check for each one. Instead of something like this (imagine enemy is object 1, bullets are objects 2,3,4,5:

Do something like this:

Posted: 31st Oct 2002 00:55
that might work too, but there is a time where if you have a fast moving bullet that just goes through the object without touching it. if thats the case, you should use what i used. but since you have slow moving bullets, i agree with Shadow Spirit

Posted: 31st Oct 2002 07:11
"Checking distance won't work for projectile weapons. Especially slow moving ones. What if: Something moved into the path of the projectile, this would be the new collision distance."

Erm DT is a complete distance check no DB collision code and guess how im detecting bullets?.

You would isolate what the bullets can or cant hit with a loop in your distance check.

anything that doesnt need to be hit with the bullet like game sprites that add visuals are not in the code loop.

Calculating the angle of the bullet in code also allows u to spin it around as it flys out of the player.

the essence of a good bullet script

make the bullets
hide the bullets
store the bullets off the game world like Y -10000
when the player fires the button
move a bullet to the player location
rotate the bullet to the same angle direction as the player
make the bullet move forward in move units or math based moving positions

after a certain time is reached move the bullet off the game world
hide it

repeat process

indi is part of Team Lunarpixel
multimedia logisitics and interactive media