Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Drawing from a wedge rather than a rect?

Hallooo. I'm hoping there's someone who can lend a hand with a brain squeezer I have.

I'm trying to set up a rounded gauge something like this:

http://i17.photobucket.com/albums/b73/e ... geBase.png[/img]

In-game, the red is being drawn from a seperate PNG with transparency. What I'm looking to be able to do is draw a section of the gauge based on a segment of a circle, or an angle radiating from the centre of the gauge; currently, I only know the standard Rect.new method of drawing sections of an image. To explain:

http://i17.photobucket.com/albums/b73/e ... eSmall.png[/IMG]http://i17.photobucket.com/albums/b73/earthofmine/RMXP/designexamples/SampleGaugeResultSmall.png[/IMG]
http://i17.photobucket.com/albums/b73/e ... dgeBig.png[/IMG]http://i17.photobucket.com/albums/b73/earthofmine/RMXP/designexamples/SampleGaugeResultBig.png[/IMG]

In the examples above, the left image shows the angle to be used while the right shows the resulting draw in-game.

I'm perfectly aware that this may be unfeasible, but if anyone's got any pointers at all on how to define the angled segment for drawing, it'd be immensely helpful. Thanks.
 
I was trying to work on a decent algorithm for this.

It's a bit complicated, because you have to draw it a pixel at a time.

What you need to do is:

~ define your starting angel
~ define your ending angel (max angel - start angel = angel distance)
~ define major diameter
~ define max diameter

Then, the best way would probably be to pass pixel by pixel, from the negative radius value to a positive radius value, along both the x. Then pass from the top to bottom, skipping pixels in the middle. Then need to check if it is within the arc region.

I had something for this a while back. Let me dig it up and finish it. I should have finished it a long time ago anyways...
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top