Class: GamesAndRpgParadise::GardenHero::ApplePlayer
- Inherits:
-
Object
- Object
- GamesAndRpgParadise::GardenHero::ApplePlayer
- Defined in:
- lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/player/apple_player.rb
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.
12 13 14 15 16 |
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/player/apple_player.rb', line 12 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.
19 20 21 |
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/player/apple_player.rb', line 19 def drawing @drawing end |
#last_direction ⇒ Object
Returns the value of attribute last_direction.
19 20 21 |
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/player/apple_player.rb', line 19 def last_direction @last_direction end |
#player ⇒ Object (readonly)
Returns the value of attribute player.
18 19 20 |
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/player/apple_player.rb', line 18 def player @player end |
#x ⇒ Object
Returns the value of attribute x.
19 20 21 |
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/player/apple_player.rb', line 19 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
19 20 21 |
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/player/apple_player.rb', line 19 def y @y end |
Instance Method Details
#draw ⇒ Object
draw
22 23 24 |
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/player/apple_player.rb', line 22 def draw @img.draw(@x, @y, 1) if @drawing end |
#update ⇒ Object
update
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/player/apple_player.rb', line 27 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 |