Most Efficient way to deal with bullets (when there's dozens on screen)

ozz

  • *
  • Posts: 512
I’ve been trying to prevent fps dips in a bullet hell shooter and I’m wonder what the most effect way to get rid of a bullet when it’s done is?

Needs to be able to go away (die/recycle)
-When it hits something
-When it leaves the screen
-When it’s been onscreen for too long
-Do so while there are many other actors onscreen

How can I do that with as little impact on the frame rate as possible?

gruffman

  • *
  • Posts: 564
ok, to start with make sure you are creating recycled actors and not "create actor".

Next be sure you have read
http://www.stencyl.com/help/view/optimize-game-performance/
http://www.stencyl.com/help/view/optimize-actor-performance/

Then make sure everything else in the scene is running super smooth as you will need all the help you can get. But ultimately stencyl has limitations on how many actors, depending on size, speed etc and I think this may be at least partially dictated by flash itself.

Last thought would be to increase bullet screen to get it off screen asap.
Now available for all Android Devices - Happy Face Concentration
My Games To Date
Find A Face / Hero Of Oda / Snakes And Ladders
Hungry Monkey available at fgl.com for Sponsorship
My site - Gruffgames.com

dtrungle

  • Posts: 1938
http://www.stencyl.com/help/viewArticle/163

Version 3.0 has better performance in this area. I would assume that you can have around 2x more actors than 2.0.

ozz

  • *
  • Posts: 512
About this snippet, why is the "If Actor has value" bit necessary?  isn't it enough to have "If Self is alive"?

Tuo

  • *
  • Posts: 2469
What isn't needed is the "recycle self"... unless your levels last until you have like 1000 dead bullets, there isn't much of a difference in performance in kill/create vs. recycle (but a ton of differences in the number of issues you will have).

If it's a simple shooter, you can just use:
when created
  kill self after leaving screen
  (if needed, then a screen bounds changer here)

If this is going to have a ton of bullets, then the primary method is the lagless route: http://www.kongregate.com/games/Abigayl/stencyl-2-0-advanced-tutorial-lagless-actors
Don't look to me but rather to the One who is the reason for what I do. :)

If you need help, send me a PM. Even if I haven't been on in the forums in ages, I still receive those messages via email notifications. You can also reply to any of my forum posts, regardless of the age (especially if I created it), and I will likely reply.

If you want to see the programming behind certain types of games, feel free to check out my "Demo-" games on StencylForge (http://community.stencyl.com/index.php/topic,16160.0.html)

ozz

  • *
  • Posts: 512
 I finally got some time and worked this into my game ( /games/Abigayl/stencyl-2-0-advanced-tutorial-lagless-actors ), but while it works great, I'm not entirely sure how or why.  Which is a problem because I need enemy ships to be able to fire the bullets at the player.  How do I get these lagless bullets to be fired from a enemy at the player?

Tuo

  • *
  • Posts: 2469
Put the coding in the enemy ship's events instead of the scene's events and instead of using random numbers to create the position of the bullets, use the x/y of the enemy ship for firing.
Don't look to me but rather to the One who is the reason for what I do. :)

If you need help, send me a PM. Even if I haven't been on in the forums in ages, I still receive those messages via email notifications. You can also reply to any of my forum posts, regardless of the age (especially if I created it), and I will likely reply.

If you want to see the programming behind certain types of games, feel free to check out my "Demo-" games on StencylForge (http://community.stencyl.com/index.php/topic,16160.0.html)

ozz

  • *
  • Posts: 512
Ah, I see, one other question, if the "always/Updating" tag creates more lag, why doesn't it here?

Tuo

  • *
  • Posts: 2469
Because it really doesn't cause a lot of lag, at least not to my own tests.
Don't look to me but rather to the One who is the reason for what I do. :)

If you need help, send me a PM. Even if I haven't been on in the forums in ages, I still receive those messages via email notifications. You can also reply to any of my forum posts, regardless of the age (especially if I created it), and I will likely reply.

If you want to see the programming behind certain types of games, feel free to check out my "Demo-" games on StencylForge (http://community.stencyl.com/index.php/topic,16160.0.html)

ozz

  • *
  • Posts: 512
Put the coding in the enemy ship's events instead of the scene's events and instead of using random numbers to create the position of the bullets, use the x/y of the enemy ship for firing.

This makes the bullet fly right though the player to no effect.  How can I fix this?

« Last Edit: February 09, 2013, 07:43:02 pm by ozz »

Tuo

  • *
  • Posts: 2469
Just like in the tutorial, you have to set an actor attribute to the player and use x/y collision boundaries to see if the bullet hits the player.
Don't look to me but rather to the One who is the reason for what I do. :)

If you need help, send me a PM. Even if I haven't been on in the forums in ages, I still receive those messages via email notifications. You can also reply to any of my forum posts, regardless of the age (especially if I created it), and I will likely reply.

If you want to see the programming behind certain types of games, feel free to check out my "Demo-" games on StencylForge (http://community.stencyl.com/index.php/topic,16160.0.html)

ozz

  • *
  • Posts: 512
I'm afraid I don't understand, I haven't changed the code from the tutorial and it does work when the scene spawns it, how is the X/Y location different when spawned from an actor?

Tuo

  • *
  • Posts: 2469
Perhaps upload it to StencylForge (and make it public) and I'll see what the troubles are.
Don't look to me but rather to the One who is the reason for what I do. :)

If you need help, send me a PM. Even if I haven't been on in the forums in ages, I still receive those messages via email notifications. You can also reply to any of my forum posts, regardless of the age (especially if I created it), and I will likely reply.

If you want to see the programming behind certain types of games, feel free to check out my "Demo-" games on StencylForge (http://community.stencyl.com/index.php/topic,16160.0.html)

ozz

  • *
  • Posts: 512
Thanks I re-uploaded "Bullet Hell",  The Actor doing the shooting is 075 Fighter 00.

Tuo

  • *
  • Posts: 2469
Not seeing it... did you make it public?
Don't look to me but rather to the One who is the reason for what I do. :)

If you need help, send me a PM. Even if I haven't been on in the forums in ages, I still receive those messages via email notifications. You can also reply to any of my forum posts, regardless of the age (especially if I created it), and I will likely reply.

If you want to see the programming behind certain types of games, feel free to check out my "Demo-" games on StencylForge (http://community.stencyl.com/index.php/topic,16160.0.html)