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 previous 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 bunch of bullets flying across the display. And any of them might kill you.
I’ve been studying some cocos books (previous however nonetheless legitimate I assume), and it appears that 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 when you have say, 200 bullets, and the sport is 60 fps, it implies that the replace methodology is checking 12000 intersections per second!! + the whole lot else in your recreation logic.

I come from a CGI background the place you progress meshes with thousents of vertices per second ar 24 fps, which is form of regular. So I ponder, being new into recreation growth, if 12000 intersection checks per seconds is loopy or is doable.

thanks,
R

okay, I’ve been studying abit on the subject and it appears that evidently one of the best ways to do it’s to make use of a pool and sphere colliders (apparently sooner 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 feel they’d 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 might of additionally been Assembly language.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here