Home Game Development Thousents of bullets logic/efficiency logic – cocos2d-x

Thousents of bullets logic/efficiency logic – cocos2d-x

0
Thousents of bullets logic/efficiency logic – cocos2d-x

[ad_1]

Hello,
I used to be enjoying some outdated retro video games and began questioning how did they do it again then. There the place shootemups video games the place you actually had a whole lot of bullets flying across the display. And any of them might kill you.
I’ve been studying some cocos books (outdated however nonetheless legitimate I assume), and evidently the logic is to retailer all of the bulllets on display in a ccArray and within the replace methodology you do a CCARRAY_FOREACH (which i assume in cocos3dx 4.0 is now CCARRAYDATA_FOREACH).
So you probably have say, 200 bullets, and the sport is 60 fps, it implies that the replace methodology is checking 12000 intersections per second!! + every thing else in your sport logic.

I come from a CGI background the place you progress meshes with thousents of vertices per second ar 24 fps, which is sort of regular. So I’m wondering, being new into sport improvement, if 12000 intersection checks per seconds is loopy or is doable.

thanks,
R

okay, I’ve been studying abit on the subject and evidently one of the simplest ways to do it’s to make use of a pool and sphere colliders (apparently quicker than field colliders). So insteand of instanciating and destroying all of the bullets,
they’re created unexpectedly off display, after which simply transfer round and reposition out of display when not wanted.

1 Like

Hi there, I believe they might of simply examine the gap from and object to object,
not all of the factors 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 gap is much less then say 2 then collide, however again within the day it could of additionally been Assembly language.

That’s is attention-grabbing(You can avoid wasting efficiency although with out making use of the sq. root)
My concern was extra about creating the sprites situations than the collisions. Instead of making and destroying the sprites situations, they will all be created directly off display at loading time, after which simply transfer then round. For occasion, when colliding, as an alternative of destroying the sprite and creating a brand new one once more, simply transfer it again off display till you want it.
I do one thing comparable with some background clouds. Create as soon as, and as soon as they go away the display, set the place out once more and restart.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here