Optimization for Bullet Hells

RosalinaGalaxer

  • Posts: 239
Hey,

So some of you might know that I recently released a bullet hell game on Flash. I used Abigayl's lagless method (which from here on out will be referred to as ALM), but I still had to turn Simple Physics on and lock the framerate to 30. I also couldn't rotate bullets to point in the direction of their motion with ALM. Also, because of some other limitations of the HTML5 beta with ALM, I wasn't able to publish to HTML5, which resulted in a lot of sponsors turning the game down.

And making new bullets with ALM is a pain...

So I was wondering if there was any way I could optimize things so that I could have a steady framerate of 60, and still be able to define hitboxes, rotate bullets, and have a ton of them on screen.

Thanks!

(I am in no way harping on ALM as being horrible. It rocks, it just doesn't really fit what I need it to do.)
Ģ̷̓l̴̥̒͑̕͝ì̷̘͈̬͈̖̂͂̔̕t̷͔͇̯̥̬̀̽̓͜͝c̵͇̦̼̮̉̐̈́̕͝ͅͅḣ̵̡̫̞͚̐̅ͅë̶̗̦̪̖͚̜́͊̄͑s̵̺̹̖̼̥̃.̴̮̫͐ ̶̛̓̇̾̎

“I have never seen a more heated discussion about context, jazz, and cats.” - VanillaButterz

merrak

  • *
  • Posts: 2738
I'm not familiar with ALM. I looked up "Abigayl's lagless method " and found it on Kongregate, dated back to 2014. If that's the guide you were working from, keep in mind there are some very significant differences between Stencyl 2.0 and 3.x.

RosalinaGalaxer

  • Posts: 239
Yeah, I'm aware that the two versions are different, but it worked for Project Innocence: I was just hoping that there was a better way to go about optimization that didn't limit what's possible so much. Because the bullets are all being drawn with an actual draw block, I can't define actual collision boxes or rotate the bullet. I also can't make the bullet itself do much, because each bullet is stored in a list, and it's really difficult to work around all the other bullets to get one of them to do something.
Ģ̷̓l̴̥̒͑̕͝ì̷̘͈̬͈̖̂͂̔̕t̷͔͇̯̥̬̀̽̓͜͝c̵͇̦̼̮̉̐̈́̕͝ͅͅḣ̵̡̫̞͚̐̅ͅë̶̗̦̪̖͚̜́͊̄͑s̵̺̹̖̼̥̃.̴̮̫͐ ̶̛̓̇̾̎

“I have never seen a more heated discussion about context, jazz, and cats.” - VanillaButterz

JeffreyDriver

  • Posts: 2262
Did you try using actors and removing the collision shapes? If you use maths to check if actors are overlapping instead of using collision shapes, you can get away with using lots of actors.

RosalinaGalaxer

  • Posts: 239
That's one of the things that ALM does. It also stores each instance of one bullet in a list, and then draws the bullet at the correct xy coordinates. How much framerate do I lose if I have more bullets on screen, all rendering?
Ģ̷̓l̴̥̒͑̕͝ì̷̘͈̬͈̖̂͂̔̕t̷͔͇̯̥̬̀̽̓͜͝c̵͇̦̼̮̉̐̈́̕͝ͅͅḣ̵̡̫̞͚̐̅ͅë̶̗̦̪̖͚̜́͊̄͑s̵̺̹̖̼̥̃.̴̮̫͐ ̶̛̓̇̾̎

“I have never seen a more heated discussion about context, jazz, and cats.” - VanillaButterz

RosalinaGalaxer

  • Posts: 239
So I made a test scene with nothing in it, and a test bullet with no coding apart from facing the direction of motion, and no hitbox. I'm spawning a new bullet every frame (if there are less than 300 bullets on-screen) that has random speed and x-position. I get a framerate of about 10-15 fps.

I'm not quite sure what to do from here...
Ģ̷̓l̴̥̒͑̕͝ì̷̘͈̬͈̖̂͂̔̕t̷͔͇̯̥̬̀̽̓͜͝c̵͇̦̼̮̉̐̈́̕͝ͅͅḣ̵̡̫̞͚̐̅ͅë̶̗̦̪̖͚̜́͊̄͑s̵̺̹̖̼̥̃.̴̮̫͐ ̶̛̓̇̾̎

“I have never seen a more heated discussion about context, jazz, and cats.” - VanillaButterz


RosalinaGalaxer

  • Posts: 239
Sure, here you go. There's not much to see, but I'll take any help I can get.
Ģ̷̓l̴̥̒͑̕͝ì̷̘͈̬͈̖̂͂̔̕t̷͔͇̯̥̬̀̽̓͜͝c̵͇̦̼̮̉̐̈́̕͝ͅͅḣ̵̡̫̞͚̐̅ͅë̶̗̦̪̖͚̜́͊̄͑s̵̺̹̖̼̥̃.̴̮̫͐ ̶̛̓̇̾̎

“I have never seen a more heated discussion about context, jazz, and cats.” - VanillaButterz

JeffreyDriver

  • Posts: 2262
Sorry to say I haven't done any better. I made a few changes like adjusting physics settings and removing code from 'always/updating' events, such as checking every second if a bullet was off screen rather than every frame.

I checked in HTML5 and it seemed fine, but Flash performance was poor. Flash is crap though.

RosalinaGalaxer

  • Posts: 239
Well, we got it up to 25 fps...

I didn't even think about the fact that HTML5 is more powerful than Flash (in my head I dismissed them as equal, and that one was just becoming more accepted). Is there some sort of fps monitor for HTML5? The built-in one doesn't work for it, and fps is crazy important for this kind of game...
Ģ̷̓l̴̥̒͑̕͝ì̷̘͈̬͈̖̂͂̔̕t̷͔͇̯̥̬̀̽̓͜͝c̵͇̦̼̮̉̐̈́̕͝ͅͅḣ̵̡̫̞͚̐̅ͅë̶̗̦̪̖͚̜́͊̄͑s̵̺̹̖̼̥̃.̴̮̫͐ ̶̛̓̇̾̎

“I have never seen a more heated discussion about context, jazz, and cats.” - VanillaButterz

JeffreyDriver

  • Posts: 2262
I guess you can probably get the fps with a bit of custom code and just draw it to screen, but I don't know what that code would be.

RosalinaGalaxer

  • Posts: 239
So I set the bullet limit to 1000 and tested it on HTML5. It got up to ~800 bullets before they started being killed too fast, and there was minimal lag. I set the physics to Box2D and added a collision box, and everything ran fine, so I guess I don't even need to do any optimization with HTML5...
Ģ̷̓l̴̥̒͑̕͝ì̷̘͈̬͈̖̂͂̔̕t̷͔͇̯̥̬̀̽̓͜͝c̵͇̦̼̮̉̐̈́̕͝ͅͅḣ̵̡̫̞͚̐̅ͅë̶̗̦̪̖͚̜́͊̄͑s̵̺̹̖̼̥̃.̴̮̫͐ ̶̛̓̇̾̎

“I have never seen a more heated discussion about context, jazz, and cats.” - VanillaButterz

JeffreyDriver

  • Posts: 2262
Awesome. HTML5 exporting isn't stable yet. I read a post that Stencyl 3.5 should get a public release in a matter of weeks, and I hope that any issues with HTML5 will be resolved.

RosalinaGalaxer

  • Posts: 239
Really? That's the greatest thing I've heard in ages!
Ģ̷̓l̴̥̒͑̕͝ì̷̘͈̬͈̖̂͂̔̕t̷͔͇̯̥̬̀̽̓͜͝c̵͇̦̼̮̉̐̈́̕͝ͅͅḣ̵̡̫̞͚̐̅ͅë̶̗̦̪̖͚̜́͊̄͑s̵̺̹̖̼̥̃.̴̮̫͐ ̶̛̓̇̾̎

“I have never seen a more heated discussion about context, jazz, and cats.” - VanillaButterz