Class: GamesAndRpgParadise::Enemy
- Inherits:
-
Object
- Object
- GamesAndRpgParadise::Enemy
- Defined in:
- lib/games_and_rpg_paradise/gui/gosu/aero_exploder/enemy.rb
Instance Attribute Summary collapse
-
#speed ⇒ Object
Returns the value of attribute speed.
-
#time ⇒ Object
Returns the value of attribute time.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
-
#button_down(id, mx, my) ⇒ Object
# === button_down ========================================================================= #.
-
#draw ⇒ Object
# === draw ========================================================================= #.
-
#initialize(x, y, speed, time, parent_widget) ⇒ Enemy
constructor
# === initialize ========================================================================= #.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#update(mx, my) ⇒ Object
# === update ========================================================================= #.
Constructor Details
#initialize(x, y, speed, time, parent_widget) ⇒ Enemy
#
initialize
#
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/games_and_rpg_paradise/gui/gosu/aero_exploder/enemy.rb', line 19 def initialize( x, y, speed, time, ) @x, @y, @speed, @time = x, y, speed, time @angle_arr = [-7, -6, 6, 7] @angle = @speed / @angle_arr[rand(0..3)] img_num = rand(1..5) @enemy_img = ::Gosu::Image.new("data/enemy#{img_num}.png") @boom = ::Gosu::Sample.new('data/boom.wav') @parent_widget = reset end |
Instance Attribute Details
#speed ⇒ Object
Returns the value of attribute speed.
13 14 15 |
# File 'lib/games_and_rpg_paradise/gui/gosu/aero_exploder/enemy.rb', line 13 def speed @speed end |
#time ⇒ Object
Returns the value of attribute time.
14 15 16 |
# File 'lib/games_and_rpg_paradise/gui/gosu/aero_exploder/enemy.rb', line 14 def time @time end |
#x ⇒ Object
Returns the value of attribute x.
11 12 13 |
# File 'lib/games_and_rpg_paradise/gui/gosu/aero_exploder/enemy.rb', line 11 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
12 13 14 |
# File 'lib/games_and_rpg_paradise/gui/gosu/aero_exploder/enemy.rb', line 12 def y @y end |
Instance Method Details
#button_down(id, mx, my) ⇒ Object
#
button_down
#
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/games_and_rpg_paradise/gui/gosu/aero_exploder/enemy.rb', line 56 def (id, mx, my) case id when ::Gosu::MsLeft if mx >= @x and mx <= @x + @enemy_img.width and my >= @y and my <= @y + @enemy_img.height and (@parent_widget.n_bullets? > 0) @boom.play() @shot_down = true @x += 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @parent_widget.increment_the_score_by_plus_one end end end |
#draw ⇒ Object
#
draw
#
73 74 75 |
# File 'lib/games_and_rpg_paradise/gui/gosu/aero_exploder/enemy.rb', line 73 def draw @enemy_img.draw(@x, @y, 2) unless @shot_down end |
#reset ⇒ Object
#
reset
#
35 36 37 38 39 40 |
# File 'lib/games_and_rpg_paradise/gui/gosu/aero_exploder/enemy.rb', line 35 def reset # ======================================================================= # # === @shot_down # ======================================================================= # @shot_down = false end |
#update(mx, my) ⇒ Object
#
update
#
45 46 47 48 49 50 51 |
# File 'lib/games_and_rpg_paradise/gui/gosu/aero_exploder/enemy.rb', line 45 def update(mx, my) @time_now = Time.now if @time_now >= @time && @shot_down == false @x += @speed @y += @angle end end |