Drawing blood

Discussion in 'Programming' started by stepup2000, Dec 5, 2018.

  1. stepup2000

    stepup2000 Member

    Joined:
    Sep 26, 2018
    Posts:
    41
    So i have a project now with a lot of blood.How the blood system works: one blood object gets created, that objects creates 15 little objects that go in a random 360 direction. When they hit something they stop moving and give their x and y coords to a master blood controller. that controller then draws all the sprites at the right coords. When the master controller is full of coords he pushes the oldest one out. i did this system because it thought it would save me a lot of fps. But in reality it still takes a lot of my fps. Is there any way to do this better because blood is a big part of my game.
     
  2. JeffJ

    JeffJ Member

    Joined:
    Jun 20, 2016
    Posts:
    228
    Once the blood drops have landed and you know they're going to stay there, you could draw them to a surface that holds all the blood and then remove the actual instance. In this way, you can literally cover your entire level with blood without keeping a single instance in memory. You'll still need the instances temporarily, but once you know they're done moving, just draw them to a surface and erase them.

    That will also remove your need for a "master" object to keep track of a single coordinate. And the blood will be able to stay forever if you want it to.
     
  3. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    5,647
    Are you destroying ALL the blood objects before you have the controller draw them, oris the room just piling up with objects?

    Edit: kinda ninjaed
     
    stepup2000 likes this.
  4. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,127
  5. stepup2000

    stepup2000 Member

    Joined:
    Sep 26, 2018
    Posts:
    41
    i have never used a surface before, how would you do this?
     
  6. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    5,647
    As surface is just another canvas to draw on. There are lots of guys or tutorials on how to use them. Since they do take up a chunk of memory just buy existing, you do kind of need to be careful with them. You can havea surface the size of the entire room, or surface the size of the current view, or somewhere in between. Or you can have multiple services being drawn at various points around the room as needed. Too big of a surface, and you waste memory with all of those blank pixels; too small of a surface, you'll need more, and I think that increases the number of texture swaps. In any case, you basically tell the game to draw whatever you want on to that service and then you draw that surface yourself at some point during the drawing phases. Surfaces stay in memory until you free them yourself or until the operating system clears it to make use of the memory elsewhere (happens more frequently on phones I think).

    Open the help file, read the manual on surfaces. Ear covers pretty much everything you will need to know about surfaces.
     
    stepup2000 likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice