Class: GUI
- Inherits:
-
Chingu::GameObject
- Object
- Chingu::GameObject
- GUI
- Defined in:
- lib/games_paradise/gui/gosu/chinguroids/gui.rb
Overview
GUI CLASS
Health Meter, Star Meter, Score
Instance Method Summary collapse
-
#draw ⇒ Object
draw health meter and star meter according to $health and $stars.
-
#initialize(player) ⇒ GUI
constructor
A new instance of GUI.
- #update ⇒ Object
Constructor Details
#initialize(player) ⇒ GUI
Returns a new instance of GUI.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/games_paradise/gui/gosu/chinguroids/gui.rb', line 5 def initialize(player) super() @gui_player = player @heart_full = Image["media/assets/heart.png"] @heart_half = Image["media/assets/heart_half.png"] @heart_empty = Image["media/assets/heart_empty.png"] @star_full = Image["media/assets/star_full.png"] # @star_half = Gosu::Image.new($window, "media/assets/star_half.png") @star_empty = Image["media/assets/star_empty.png"] @score_text = Chingu::Text.create("Score: #{$score}", :y => 0, :font => "GeosansLight", :size => 20, :color => Colors::White, :zorder => Zorder::GUI) @score_text.x = 800/2 - @score_text.width/2 end |
Instance Method Details
#draw ⇒ Object
draw health meter and star meter according to $health and $stars
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/games_paradise/gui/gosu/chinguroids/gui.rb', line 24 def draw # draw health meter and star meter according to $health and $stars if $health == 6 # Health Meter for i in 0..2 @heart_full.draw(18*i+2, 0, Zorder::GUI) end elsif $health == 5 for i in 0..1 @heart_full.draw(18*i+2, 0, Zorder::GUI) end for i in 2..2 @heart_half.draw(18*i+2, 0, Zorder::GUI) end elsif $health == 4 for i in 0..1 @heart_full.draw(18*i+2, 0, Zorder::GUI) end for i in 2..2 @heart_empty.draw(18*i+2, 0, Zorder::GUI) end elsif $health == 3 for i in 0..0 @heart_full.draw(18*i+2, 0, Zorder::GUI) end for i in 1..1 @heart_half.draw(18*i+2, 0, Zorder::GUI) end for i in 2..2 @heart_empty.draw(18*i+2, 0, Zorder::GUI) end elsif $health == 2 for i in 0..0 @heart_full.draw(18*i+2, 0, Zorder::GUI) end for i in 1..2 @heart_empty.draw(18*i+2, 0, Zorder::GUI) end elsif $health == 1 for i in 0..0 @heart_half.draw(18*i+2, 0, Zorder::GUI) end for i in 1..2 @heart_empty.draw(18*i+2, 0, Zorder::GUI) end end if $stars == 0 # Star Meter for i in 0..2 @star_empty.draw(18*i+70, 0, Zorder::GUI) end elsif $stars == 1 for i in 0..0 @star_full.draw(18*i+70, 0, Zorder::GUI) end for i in 1..2 @star_empty.draw(18*i+70, 0, Zorder::GUI) end elsif $stars == 2 for i in 0..1 @star_full.draw(18*i+70, 0, Zorder::GUI) end for i in 2..2 @star_empty.draw(18*i+70, 0, Zorder::GUI) end elsif $stars == 3 for i in 0..2 @star_full.draw(18*i+70, 0, Zorder::GUI) end end end |
#update ⇒ Object
19 20 21 22 |
# File 'lib/games_paradise/gui/gosu/chinguroids/gui.rb', line 19 def update super @score_text.text = "Score: #{$score}" end |