-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogressbar.rb
44 lines (36 loc) · 1.16 KB
/
progressbar.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class ProgressBar
attr_accessor :width, :height, :percentage
attr_accessor :position, :color, :border_color, :text_color
attr_accessor :text
def initialize(width, height, percentage)
@width = width
@height = height
@percentage = percentage
@position = Vec2.new(0, 0)
@color = Color::RED
@border_color = Color::WHITE
@text_color = Color::BLACK
@text = ""
end
def draw
Gosu.draw_rect(@position.x,
@position.y,
@width + 4,
@height + 4,
@border_color,
500)
Gosu.draw_rect(@position.x + 2,
@position.y + 2,
@percentage * @width / 100,
@height,
@color,
500)
$font.draw(@text,
@position.x + (@width - $font.text_width(@text, 0.25))/2,
@position.y + (@height - $font.height * 0.25) / 2,
500,
0.25,
0.25,
@text_color)
end
end