Thousents of bullets logic/performance logic

Hello,
I was playing some old retro games and started wondering how did they do it back then. There where shootemups games where you literally had hundreds of bullets flying around the screen. And any of them could kill you.
I have been reading some cocos books (old but still valid I guess), and it seems that the logic is to store all the bulllets on screen in a ccArray and in the update method you do a CCARRAY_FOREACH (which i guess in cocos3dx 4.0 is now CCARRAYDATA_FOREACH).
So if you have say, 200 bullets, and the game is 60 fps, it means that the update method is checking 12000 intersections per second!! + everything else in your game logic.

I come from a CGI background where you move meshes with thousents of vertices per second ar 24 fps, which is kind of normal. So I wonder, being new into game development, if 12000 intersection checks per seconds is crazy or is doable.

thanks,
R

ok, I’ve been reading abit on the topic and it seems that the best way to do it is to use a pool and sphere colliders (apparently faster than box colliders). So insteand of instanciating and destroying all the bullets,
they are created all at once off screen, and then just move around and reposition out of screen when not needed.

1 Like

Hi there, I think they would of just check the distance from and object to object,
not all the points of a physics object in an engine.

Example code.

float diffY = p1.y - p2.y;
float diffX = p1.x - p2.x;
return sqrt((diffY * diffY) + (diffX * diffX));
then if the distance is less then say 2 then collide, but back in the day it would of also been Assembly language.

That’s is interesting(You can save some performance though without applying the square root)
My concern was more about creating the sprites instances than the collisions. Instead of creating and destroying the sprites instances, they can all be created at once off screen at loading time, and then just move then around. For instance, when colliding, instead of destroying the sprite and creating a new one again, just move it back off screen until you need it.
I do something similar with some background clouds. Create once, and once they leave the screen, set the position out again and restart.

Yes thats the fun part about games programming, you make it up as you go along optimisation is key, but remember it’s all fake so when your swimming in water your not really it’s just graphics, but like the matrix “Your mind makes it real”, I find it fun programming and animation, it’s like a good old cartoon it’s left to your imagination.
We use many tricks like hiding things off screen or because cocos uses nodes you can just show or hide node that tells the engine if its is to be drawn, using one player and changing the colure so it looks like many different players to save memory or tile maps reuse the same tiles to create an infinite scrolling map that was the arcades favour trick if you played MAME before you can see they rotate pallets and use tiles and all kinds of trick’s to create the illusion. Cocos2x can pull off all these tricks and them some, “On steroids”, the more you get into it the more fun cocos is. I don’t know if you program at all or if you do or start learning this is a real fun engine to play with lots of help on here the admins on here are fantastic at helping out too they really helped me with my ip & images this was something I overlooked and they picked up on brilliant. anyway enjoy and have fun.

yes, I have been a software dev for the last 15 years. I use to work in the film CGI industry where I wrote rigging software in python and C++ plugins when heavy realtime computation where required.
I recently switch to the game industry (got a bit burned from working in big films studios).
This the game I currently developing

shootem up game dev WIP

It is small game that I am using as a “workshop” for future more serious and long games.

Hay thats awesome is there an end boss? reminds me of - R TYPE loved that game. is it running on Android or IOS looks like its on windows?
Make me want to write one now should only take about 20 mins with this engine

Cheers.
Yeah, love rtype, last resort, bomber ride… So many fantastic games.
The game is one level with increasing difficulty with different sections that correspond to new enemies and at the end it will be a final boss yes.
I do post wips on Instagram if you want to have a look, search for rudi_hammad.
The platform is PC. I am not targeting Mobil, at least with this one.

is it using cocos2dx or a different engine

Yes, cocos2dx 4.0

oh cool so you can recompile for anything then, nice one. I mite have to break out the compiler and have a go at something like that forgot how much I love all them shoot em ups, I’m so old school I’m a scrambler , defender, sinister all them 8 bit arcade game was lucky when I was young I lived on the cost of Bournemouth in uk we had to 2 pier’s and they where choked full of all the 80 games when they was new, So had a misspent childhood playing all them arcade games lol:).
but you have sparked me into attempting a shoot em up game now thanks.

Cool.
A lot of old games hold very well today. And it’s not all about 3d, raytracing and the last tech… Look at the last ninja turtles games, it sold really well.
Anyway, getting off topic here. Good luck with your projects.