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.

Curving/ Circle/ Advanced Display Bars

no you need to have waited 14 more minutes for 72 hours, I will now destroy your family since you didn't wait the full 72 hours (just kidding + inside joke :p), no you aren't in trouble since it is so close to that amount, but don't do it again just to be safe.

as for your script, It is possible with Math (and I'm a Math + CS Major)

I see the bar as two parts

the rectangle and the curved portion

Now there are few ways to approach this script

1) Use Pictures and have a pic for every decrease (you'd want to do this for the curved portion you can crop the rectangular portion)

2) Code the formula (I'll dig something up for you to help you with this, that is, when I get the chance)

1 would require alot of pictures and 2 would be a bit of trouble trying to derive a formula for it.
 
It was just a simplified fill_rect function like so:

Code:
class Bitmap
  def clear(x, y, w, h)
    self.contents.fill_rect(x, y, w, h, Color.new(0, 0, 0, 0))
  end
end

I might look into this and see if I can't brush up on some old math skills.
 
The way Near and Acedent_Prone did this with Near's SBABS and Acedent_Prone's Personality Engine demo would only work with a semi circle, or quarter circle. But essentially you create a graphic of a ring, with only one half visible. Then you simply make a small viewport that only encompasses one side of the image, and then rotate it based on the value.
 
Thanks you guys. But I must say, I'm a seriously afraid. I'm doing 8th Grade slope. And that circle stuff on wikipedia even looks hard. I almost peed my pants. That stuff is way over my head. I appreciate all of this.
 
I did this in last night with a few mintues I had to spare.

Code:
class Bitmap
  def draw_circle(x, y, radius, color = Color.new(255, 255, 255, 255))
    for i in (x - radius)...x
      sa = (x - i).abs
      y_ = Integer((radius ** 2 - sa ** 2) ** 0.5)
      self.fill_rect(x - sa, y - y_, 1, y_ * 2, color)
      self.fill_rect(x + sa, y - y_, 1, y_ * 2, color)
    end
    self.fill_rect(x, y - radius, 1, radius * 2, color)
  end
  def draw_annulus(x, y, min_radius, max_radius, color = Color.new(255, 255, 255)) 
    for i in (x - max_radius)...x
      sa = (x - i).abs
      if (x - sa).between?((x - min_radius), x)
        y1 = Integer((max_radius ** 2 - sa ** 2) ** 0.5)
        y2 = Integer((min_radius ** 2 - sa ** 2) ** 0.5)
        self.fill_rect(x - sa, y - y1, 1, y1 - y2, color)
        self.fill_rect(x - sa, y + y2, 1, y1 - y2, color)
        self.fill_rect(x + sa, y - y1, 1, y1 - y2, color)
        self.fill_rect(x + sa, y + y2, 1, y1 - y2, color)
      else
        y1 = Integer((max_radius ** 2 - sa ** 2) ** 0.5)
        self.fill_rect(x - sa, y - y1, 1, y1 * 2, color)
        self.fill_rect(x + sa, y - y1, 1, y1 * 2, color)
      end
    end
    self.fill_rect(x, y - max_radius, 1, (max_radius - min_radius), color)
    self.fill_rect(x, y + min_radius, 1, (max_radius - min_radius), color)
  end
end

Right now it's just basic functions that I will use. When I done, I hope to allow you to do something like:
Code:
<bitmap>.draw_kh_bar(center_x, center_y, max_radius, min_radius, tail_length, current, max [, border_color, bar_color ])

I have most of it planned out so maybe in a few days I will finish it.
 
I'll test it asap.

@arevulopapo. Those circles are cool. Thanks for helping.


EDIT:::: rofl... I thought it was finished for a second lol. Still I really appreciate it. Am I getting annoying?

EDIT:::: WOAH!!!!! That is truly amazing. I found my color already: color = Color.new(36, 185, 63).

I'm shivering all over. I can't wait.
 
lol. Thanks. erm... About the slave thing. I want to be both of yours.... >_> <_< Can you help me decide? v_v

This is gonna be great when you finish it. (It's already great btw. It'll be greater.) For those who think I'm stupid: It's great because it's a script. If it was an image it would be stupid.
 
Sorry about that. I am working on several ways to do this:

Straight Draw from the fill_rect method / set_pixel
Draw From an Image File
Combo

Just give me a little time. I am trying to work on an arc_fill method, that will help out a bunch for this.
 

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