Class: ApplePlayer
- Inherits:
-
Object
- Object
- ApplePlayer
- Defined in:
- lib/games_paradise/gui/gosu/garden_hero/core/player/apple_player.rb
Overview
#
ApplePlayer - apple class (player’s weapon)
Instance Attribute Summary collapse
-
#drawing ⇒ Object
Returns the value of attribute drawing.
-
#last_direction ⇒ Object
Returns the value of attribute last_direction.
-
#player ⇒ Object
readonly
Returns the value of attribute player.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
-
#draw ⇒ Object
draw.
-
#initialize(window, player) ⇒ ApplePlayer
constructor
A new instance of ApplePlayer.
-
#update ⇒ Object
update.
Constructor Details
#initialize(window, player) ⇒ ApplePlayer
Returns a new instance of ApplePlayer.
8 9 10 11 12 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/apple_player.rb', line 8 def initialize window, player @window, @player, @x, @y = window, player, player.x - 6, player.y + 4 @img = Gosu::Image.new window, "images/player/apple-player.png", true @drawing, @last_direction = false, 'left' end |
Instance Attribute Details
#drawing ⇒ Object
Returns the value of attribute drawing.
15 16 17 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/apple_player.rb', line 15 def drawing @drawing end |
#last_direction ⇒ Object
Returns the value of attribute last_direction.
15 16 17 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/apple_player.rb', line 15 def last_direction @last_direction end |
#player ⇒ Object (readonly)
Returns the value of attribute player.
14 15 16 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/apple_player.rb', line 14 def player @player end |
#x ⇒ Object
Returns the value of attribute x.
15 16 17 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/apple_player.rb', line 15 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
15 16 17 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/apple_player.rb', line 15 def y @y end |
Instance Method Details
#draw ⇒ Object
draw
18 19 20 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/apple_player.rb', line 18 def draw @img.draw(@x, @y, 1) if @drawing end |
#update ⇒ Object
update
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/apple_player.rb', line 23 def update if @drawing case @last_direction when 'left' @x -= 5 if @x >= 2 when 'right' @x += 5 if @x <= 632 when 'up' @y -= 5 if @y >= 2 when 'down' @y += 5 if @y <= 476 end if @x <= 4 || @x >= 630 || @y <= 4 || @y >= 476 @drawing = false @last_direction = player.face end end end |