Making a circular radar

This forum is currently in read-only mode.
0 favourites
From the Asset Store
Is a circular loading screen with code ready to use. No Animation.
  • Hi there,

    I'm making a circular radar, similar to this - http://www.crestock.com/images/440000-4 ... 234-xs.jpg

    Basically, when objects go outside of the circle, they must be hidden, but only in part (so i can't just make them invisible).

    The two ways I can see of doing this so far is-

    • Make a radar layer, use the mask effect and make a square the size of the screen with a circle cut out in it to allow to see into the radar. This way when objects move out they are hidden by the large mask object.
    • Paste the blips into a canvas, then use erase effect on the canvas to delete any pixels outside of the circle.

    Which is the more CPU/GFX card efficient way? Is it even possible to use the canvas method? I tried and it doesn't seem you can choose where to paste images in (x,y) and generally feels a little bit limited?

    But im mostly keen on keeping CPU usage low, as this game will one day be a bit of a beast and thus i want to keep it fast from the start.

  • I don't quite understand, but of two options:

    mask

    blit to canvas, erase

    The first sounds faster because it doesn't modify canvas on every render.

  • I think that the first is faster and easier.

  • Well I just noticed that even having an object with mask enabled reduced my average FPS by 50! Hah thats not good!

    I'll wait for some more info before I get stuck in with development.

  • Maybe use a Distance function to determine if they are out of boundary then if they are in range they are visible, if not they are invisible.

    So no mask, and no erase.

  • Basically, when objects go outside of the circle, they must be hidden, but only in part (so i can't just make them invisible).

    Sorry man, i dont think that would work. Like, if i had a planet on the radar, that means when it hit the edge it would just disappear. Hope that made sense, thats what i was trying to say in the above but it was a bit unclear

  • why dont you just paste the radar on a canvas, drawing blips take absolutely no time at all and you could use an erase effect which would be pretty fast and way less gpu intensive

    btw if youre aiming for speed, i suggest you avoid SQRT at all costs, its a pretty big drain if you have enough of them. there are faster, but less accurate methods (you dont need that much accuracy anyways) that you could use.

  • So are you suggesting the second method? So basically I just always paste blips into the canvas at certain X,Y positions relative to your current position on the map (Divided by a large number to scale down the map size to fit into the radar), then just erase everything outside of the radar's circle. Is this possible with the canvas object now? Can you paste in images at specific X,Y points?

    Also what can i use instead of SQRT? I'll keep that in mind, thanks!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • i'm trying to make a circular energy bar right now in a similar vein and need to erase the bar in a circular manner, it overlays on top of the game on the HUD, I was wondering if any of these functions mentioned would be applicable?

  • to paste a sprite at certain xy just do this

    first create/position a sprite at the point that youd like it to be at on the canvas, then paste the sprite in, and then destroy/move the sprite out of the scene before the frame updates

    and this is a faster non SQRT distance formula but it deviates from the true distance by about 3%

    ((Max(Abs((A.x - B.x)), Abs((A.y - B.y)))) * 0.941246) + ((Min(Abs((A.x - B.x) ), Abs((A.y - B.y)))) * 0.41)

  • i'm trying to make a circular energy bar right now in a similar vein and need to erase the bar in a circular manner, it overlays on top of the game on the HUD, I was wondering if any of these functions mentioned would be applicable?

    You could make a half-circle with the erase effect, then place it's hotspot in the center of the flat side, like so:

    <img src="http://i37.tinypic.com/2il213.jpg">

    Then when health is depleted, rotate the half-circle.

    To make a full circle, create the second half of the health bar and the second half of the eraser on a separate layer.

    I can't think of any efficient way to keep the circle in one piece and still use the erase method. But you could do it without the erase method by animating a bunch of separate sprite frames for the circle itself, even though that might be a bit tedious. Though in the long run it might actually be the best way. You could have the same number of frames as you do units of health, so it would just be a matter of setting the animation to frame (value.health) or whatever. Longer to set up, but way easier to code for.

  • The Mask and Erase effects are definitely the way to go for this. You don't need the canvas object - it would actually be slower. Mask and Erase are very simple effects and don't require pixel shaders - they should still be very efficient. All you need to do is draw a circle on a sprite and give it one of the effects (one erases the transparent areas, one erases the solid areas). It even works with alpha blended sprites to erase smooth edges!

    A drop of 50fps is not always bad news - the difference between 1050fps and 1000fps is pretty much negligable, whereas 100fps to 50fps is significant. In other words, a difference of a fixed number of FPS is a fairly meaningless statement. 1 divided by the framerate is the time in seconds it takes to render each frame - you can use this to work out exactly how much extra time it takes to process an effect, per frame.

  • thanks deadeye, you are truly the man...

    I often wonder what the best approach is witb some of these things, I think just building a depleting animation works best in this case.

  • When i have a problem, i'm like, 'what would deadeye do?'

  • Ahg, stop it you guys .

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)