Whats up,
I used to be taking part in 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 lot of bullets flying across the display screen. And any of them might kill you.
I’ve been studying some cocos books (previous however nonetheless legitimate I assume), and evidently the logic is to retailer all of the bulllets on display screen in a ccArray and within the replace technique you do a CCARRAY_FOREACH (which i assume in cocos3dx 4.0 is now CCARRAYDATA_FOREACH).
So when you’ve got say, 200 bullets, and the sport is 60 fps, it signifies that the replace technique is checking 12000 intersections per second!! + all the pieces 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 form 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 sooner than field colliders). So insteand of instanciating and destroying all of the bullets,
they’re created off display screen, after which simply transfer round and reposition out of display screen when not wanted.
1 Like
Hello there, I feel they might of simply verify the space from and object to object,
not all of the factors of a physics object in an engine.
Instance code.
float diffY = p1.y – p2.y;
float diffX = p1.x – p2.x;
return sqrt((diffY * diffY) + (diffX * diffX));
then if the space is much less then say 2 then collide, however again within the day it will of additionally been Meeting language.
That’s is attention-grabbing(It can save you some efficiency although with out making use of the sq. root)
My concern was extra about creating the sprites cases than the collisions. As a substitute of making and destroying the sprites cases, they’ll all be created without delay off display screen at loading time, after which simply transfer then round. For example, when colliding, as an alternative of destroying the sprite and creating a brand new one once more, simply transfer it again off display screen till you want it.
I do one thing related with some background clouds. Create as soon as, and as soon as they go away the display screen, set the place out once more and restart.