Class: MessageLevel

Inherits:
Level
  • Object
show all
Defined in:
lib/rubyhop/level.rb

Direct Known Subclasses

FailLevel, TitleLevel

Instance Method Summary collapse

Methods inherited from Level

#continue!, #fail!, #on_continue, #on_fail, #on_quit, #quit!

Constructor Details

#initializeMessageLevel

Returns a new instance of MessageLevel.



123
124
125
126
127
128
# File 'lib/rubyhop/level.rb', line 123

def initialize
  super
  @rubyguy = Rubyhop.image "rubyguy.png"

  create_image!
end

Instance Method Details

#create_image!Object



134
135
136
# File 'lib/rubyhop/level.rb', line 134

def create_image!
  @msg = Rubyhop.text_image message
end

#drawObject



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/rubyhop/level.rb', line 149

def draw
  c = Math.cos(Rubyhop.time*4)
  half_w = Rubyhop.width / 2
  half_h = Rubyhop.height / 2
  scale  = 1.0+c*0.1
  @rubyguy.draw_rot(half_w, half_h - 80, 1,
                    0, 0.5, 0.5, scale, scale)

  s = Math.sin Rubyhop.time
  scale = 1.0+(0.1*s**3).abs
  @msg.draw_rot( (half_w + (100*(s)).to_i),
                 (half_h + 160 + (50*s**3).abs),
                 1, s*5, 0.5, 0.5, scale, scale,
                 Gosu::Color::RED )
end

#messageObject



130
131
132
# File 'lib/rubyhop/level.rb', line 130

def message
  "This is a dumb message, you should override it"
end

#start!Object



138
139
140
# File 'lib/rubyhop/level.rb', line 138

def start!
  create_image!
end

#updateObject



142
143
144
145
146
147
# File 'lib/rubyhop/level.rb', line 142

def update
  quit!     if Rubyhop.button_down? Gosu::KbEscape
  continue! if ( Rubyhop.button_down?(Gosu::KbSpace)  ||
                 Rubyhop.button_down?(Gosu::KbReturn) ||
                 Rubyhop.button_down?(Gosu::KbEnter)  )
end