managing bullets
Moderator: Coders of Rage
- WSPSNIPER
- Chaos Rift Regular
- Posts: 145
- Joined: Sun Jan 03, 2010 6:19 pm
- Current Project: top down shooter
- Favorite Gaming Platforms: ps3
- Programming Language of Choice: c++
managing bullets
hi i was thinking about how i was going to handle bullets in a game im writing. i use to just do a for loop checking every bullet against every entity and i was wondering if you had a faster method of doing this. it is going to be a top down shooter so the bullets will be traveling in different directions. thanks for your time
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: managing bullets
look up quadtrees. That is all.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
- hurstshifter
- ES Beta Backer
- Posts: 713
- Joined: Mon Jun 08, 2009 8:33 pm
- Favorite Gaming Platforms: SNES
- Programming Language of Choice: C/++
- Location: Boston, MA
- Contact:
Re: managing bullets
Do a search for things like "handling bullets" or "projectiles". I've seen many topics like this one on this forum in the past year or two. If I can find any I will post the links.
"Time is an illusion. Lunchtime, doubly so."
http://www.thenerdnight.com
http://www.thenerdnight.com
- WSPSNIPER
- Chaos Rift Regular
- Posts: 145
- Joined: Sun Jan 03, 2010 6:19 pm
- Current Project: top down shooter
- Favorite Gaming Platforms: ps3
- Programming Language of Choice: c++
Re: managing bullets
Ginto8 wrote:look up quadtrees. That is all.
Thanks
Re: managing bullets
Make sure you always have a full clip in your weapon, and make sure you have at least 3 other fully loaded clips on you. Hopefully you also have an emergency side arm, I have found this to be the best method of bullet management, and it is highly effective against the zombie menace
- ibly31
- Chaos Rift Junior
- Posts: 312
- Joined: Thu Feb 19, 2009 8:47 pm
- Current Project: Like... seven different ones
- Favorite Gaming Platforms: Xbox 360, Gamecube
- Programming Language of Choice: C++, ObjC
- Location: New Jersey.
Re: managing bullets
Haha eatcomics, thats what I thought he was talking about. When I first saw this I'm like "WTF, uuhmm, aim for heads, dont spray..." isn't that kind of obvious?
Website/Tumblr
My Projects
The best thing about UDP jokes is that I don’t care if you get them or not.
- WSPSNIPER
- Chaos Rift Regular
- Posts: 145
- Joined: Sun Jan 03, 2010 6:19 pm
- Current Project: top down shooter
- Favorite Gaming Platforms: ps3
- Programming Language of Choice: c++
Re: managing bullets
eatcomics wrote:Make sure you always have a full clip in your weapon, and make sure you have at least 3 other fully loaded clips on you. Hopefully you also have an emergency side arm, I have found this to be the best method of bullet management, and it is highly effective against the zombie menace
lol, im sorry i may not have clearly stated the question. i ment managing bullets as in handling collisions and such in the code...
Re: managing bullets
I knew what you meant, but it was late and i thought someone explained it... just look on this forum and on google there are a LOT of tutorials on the subject, once you wrap your head around it it becomes second nature... But I could be more helpful if you would explain what kind of game you are doing? Like a 2D space shooter or 3D FPS and so on
Edit: oh you said top down shooter... really I think your method should be efficient enough, but as ginto said quadtrees would be helpful as well
Edit: oh you said top down shooter... really I think your method should be efficient enough, but as ginto said quadtrees would be helpful as well
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: managing bullets
It could be. But as there are probably going to end up being both a large number of bullets and entities simultaneously active, the chances of a naive bruteforce being efficient is low. A correctly populated and sorted quadtree can significantly reduce the number of collision tests he does, and will also be a good learning experience (quadtrees and their 3D companions octtrees are used a ton in game dev).eatcomics wrote:really I think your method should be efficient enough, but as ginto said quadtrees would be helpful as well
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Re: managing bullets
yep, and I didn't even know about them until recently... But you are certainly right that is why I suggested it along with you. and there are ways you could optimize it to only check things on screen and such if that's what you want, but quad trees are definitely my suggestion
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: managing bullets
Well unless things are only alive when they're on the screen, you want to check more than just the screen, because otherwise you can have all sorts of mess ups with the game logic (for example, you walk away from an NPC and the npc walks into/through a wall, and suddenly your collision has a seizure when it comes back onscreen because it doesn't know how to handle it).eatcomics wrote:yep, and I didn't even know about them until recently... But you are certainly right that is why I suggested it along with you. and there are ways you could optimize it to only check things on screen and such if that's what you want, but quad trees are definitely my suggestion
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Re: managing bullets
this was about bullet collision, not NPC I was suggesting just deleting them offscreen. That's also not foolproof but it would work, and for some game types that's the way it should be done
edit: but to elaborate, for your needs quadtrees would be the best solution
edit: but to elaborate, for your needs quadtrees would be the best solution