Making a circular radar

For questions about using Classic.

Post » Fri Oct 03, 2008 4:37 pm

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.
B
2
S
2
G
5
Posts: 448
Reputation: 2,546

Post » Fri Oct 03, 2008 5:11 pm

I don't quite understand, but of two options:
:arrow: mask
:arrow: blit to canvas, erase

The first sounds faster because it doesn't modify canvas on every render.
B
6
S
3
G
6
Posts: 219
Reputation: 3,013

Post » Fri Oct 03, 2008 5:15 pm

I think that the first is faster and easier.
B
3
S
2
G
5
Posts: 263
Reputation: 2,201

Post » Fri Oct 03, 2008 5:17 pm

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.
B
2
S
2
G
5
Posts: 448
Reputation: 2,546

Post » Fri Oct 03, 2008 5:30 pm

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.
B
4
S
2
G
4
Posts: 719
Reputation: 2,938

Post » Fri Oct 03, 2008 5:41 pm

[quote="alee":jg1htodn]
Basically, when objects go outside of the circle, they must be hidden, but only in part (so i can't just make them invisible).[/quote:jg1htodn]


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 :D
B
2
S
2
G
5
Posts: 448
Reputation: 2,546

Post » Fri Oct 03, 2008 9:36 pm

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.
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Sat Oct 04, 2008 6:41 pm

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!
B
2
S
2
G
5
Posts: 448
Reputation: 2,546

Post » Sat Oct 04, 2008 6:49 pm

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?
B
4
S
2
G
5
Posts: 149
Reputation: 2,025

Post » Sat Oct 04, 2008 8:39 pm

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)
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests