You can check out the game I am working on at : http://members.home.net/chris-man/
Hope this helps.
You can check out the game I am working on at : http://members.home.net/chris-man/
Hope this helps.
I have used linked lists to hold it and have found that to work quite well (and I think wasting a whole mb of memory for holding bullets is a great big waste... but maybe it's just me.)
The reason i don't like the array idea is when you have a lot of enemies and a lot of shots alive. Say you have 10 enemies... each has shot 5 times. And you yourself have shot 3 times yourself. In one iteration, 6 of your enemies and yourself decide to shoot... now think of all the searching that goes on just to find an empty slot!!! I used to do the array idea, but i found it to be just too slow.
With linked list i could just allocate and dealloc as I please. It may cost more time with fewer shots on screen, but if there's only a few shots you won't notice... as more shots/enemies appear, the list starts to go faster as it doesn't have to search. Also, it saves memory.
Just my thoughts...
and g'luck with the game.
------------------
FlyFire/CodeX
http://codexorg.webjump.com
------------------
Lack
Thanks LackOfKnack - most weapons hit automatically, but for a rocket launcher, I though it would be cool to have a rocket actually on the screen.
Anyway, i'd just like to say thanks...
On another note, I noticed that when I changed to the array, the game did not slow down noticeably when I had more bullets on screen (Well, it did, but that was because of all of the explosions happening; this slowdown occurred with the linked list as well). But you are right, I certainly do not like the idea of having all that memory used for bullets when it could be as clean as a linked list.
Thanks
There's no need to search for an empty slot if you're doing array bullets. Make a static integer, say, curbullet, set it to 0 at the start of the program. Whenever you need a new bullet, put it in bulletarray[curbullet], then increment curbullet. if curbullet is greater than the size of the array, set it back to zero.
I've found that this method usually works well, with one catch: you have to calc every bullet in the array, so it's best to keep the arrays small (I think I set mine to like 50 or 100, tops). The good news is that this helps to avoid slowdown, since you're doing the same amount of work regardless of how many bullets are actually on the screen; the bad news is that when a new bullet is created, it has the potential to overwrite one that's still active... but with 50 bullets on the screen, no-one's going to notice.
Mason McCuskey
Spin Studios
www.spin-studios.com
-ddn
Yes, i've had your problem before, and the solution was pretty stupid
Heh, what was happening to me (and i'm not sure about you) was that my ptr to the head of the list was not updated to see the next element. So basically... i guess all i can say is be careful when you allocate the next element, and make sure it's linked properly.
If you want (and if i have time ) i can look at that part of the source for you...
And about the speed issue... i have found from experience that it's faster without the arrays (way back in the dos days). But if you (guys) say there's no speed difference when you tried it then i guess i'm wrong