Friday, October 7, 2022
HomeGame DevelopmentThousents of bullets logic/efficiency logic - cocos2d-x

Thousents of bullets logic/efficiency logic – cocos2d-x


Howdy,
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 screen. And any of them may kill you.
I’ve been studying some cocos books (previous however nonetheless legitimate I suppose), and evidently the logic is to retailer all of the bulllets on display screen in a ccArray and within the replace methodology you do a CCARRAY_FOREACH (which i suppose in cocos3dx 4.0 is now CCARRAYDATA_FOREACH).
So in case you have say, 200 bullets, and the sport is 60 fps, it implies that the replace methodology is checking 12000 intersections per second!! + all the things 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’m wondering, being new into recreation 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 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 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 test 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 fascinating(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 an alternative of making and destroying the sprites cases, they will all be created directly off display screen at loading time, after which simply transfer then round. As an illustration, when colliding, as a substitute 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 comparable with some background clouds. Create as soon as, and as soon as they depart the display screen, set the place out once more and restart.

Sure thats the enjoyable half about video games programming, you make it up as you go alongside optimisation is vital, however keep in mind it’s all faux so when your swimming in water your not likely it’s simply graphics, however just like the matrix “Your thoughts makes it actual”, I discover it enjoyable programming and animation, it’s like a great previous cartoon it’s left to your creativeness.
We use many tips like hiding issues off display screen or as a result of cocos makes use of nodes you’ll be able to simply present or cover node that tells the engine if its is to be drawn, utilizing one participant and altering the colure so it appears to be like like many various gamers to save lots of reminiscence or tile maps reuse the identical tiles to create an infinite scrolling map that was the arcades favour trick in case you performed MAME earlier than you’ll be able to see they rotate pallets and use tiles and every kind of trick’s to create the phantasm. Cocos2x can pull off all these tips and them some, “On steroids”, the extra you get into it the extra enjoyable cocos is. I don’t know in case you program in any respect or in case you do or begin studying it is a actual enjoyable engine to play with plenty of assistance on right here the admins on listed below are implausible at serving to out too they actually helped me with my ip & photographs this was one thing I ignored and so they picked up on sensible. anyway take pleasure in and have enjoyable.

sure, I’ve been a software program dev for the final 15 years. I exploit to work within the movie CGI business the place I wrote rigging software program in python and C++ plugins when heavy realtime computation the place required.
I just lately swap to the sport business (obtained a bit burned from working in huge movies studios).
This the sport I at the moment creating

shootem up recreation dev WIP

It’s small recreation that I’m utilizing as a “workshop” for future extra severe and lengthy video games.

Hay thats superior is there an finish boss? jogs my memory of – R TYPE cherished that recreation. is it working on Android or IOS appears to be like like its on home windows?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments