Class: Sprite_Page
- Inherits:
-
Object
- Object
- Sprite_Page
- Defined in:
- lib/games_and_rpg_paradise/gui/gosu/books/book.rb
Instance Method Summary collapse
-
#draw ⇒ Object
draw.
- #flip(kind) ⇒ Object
- #flip? ⇒ Boolean
-
#initialize(x, y, index, page) ⇒ Sprite_Page
constructor
A new instance of Sprite_Page.
-
#update ⇒ Object
update.
Constructor Details
#initialize(x, y, index, page) ⇒ Sprite_Page
Returns a new instance of Sprite_Page.
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/games_and_rpg_paradise/gui/gosu/books/book.rb', line 44 def initialize(x, y, index, page) @index, @ticks, @ticks_max, @c = index, 0, 10, Color[:white] @sprite = Library.book_page(page) width, height = @sprite.width, @sprite.height @x1, @y1, @x2, @y2, @x3, @y3, @x4, @y4 = x, y, x+width, y, x, y+504, x+width, y+504 @offset = width / @ticks_max @even = index % 2 == 0 @z = 50 - index return if @even @x1, @x2, @x3, @x4 = @x1 - width + @offset * @ticks_max, @x2 - width, @x3 - width + @offset * @ticks_max, @x4 - width @y1, @y3 = @y1 - @offset * @ticks_max, @y3 - @offset * @ticks_max end |
Instance Method Details
#draw ⇒ Object
draw
91 92 93 |
# File 'lib/games_and_rpg_paradise/gui/gosu/books/book.rb', line 91 def draw @sprite.draw_as_quad(@x1,@y1,@c,@x2,@y2,@c,@x3,@y3,@c,@x4,@y4,@c,@z) end |
#flip(kind) ⇒ Object
88 |
# File 'lib/games_and_rpg_paradise/gui/gosu/books/book.rb', line 88 def flip(kind) @flip, @ticks, @z = kind, @ticks_max, 50 end |
#flip? ⇒ Boolean
89 |
# File 'lib/games_and_rpg_paradise/gui/gosu/books/book.rb', line 89 def flip?() @flip end |
#update ⇒ Object
update
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 |
# File 'lib/games_and_rpg_paradise/gui/gosu/books/book.rb', line 58 def update @ticks -= 1 if @ticks > 0 if @flip == :left if @even @x2 += @offset @y2 += @offset @x4 += @offset @y4 += @offset else @x1 += @offset @y1 -= @offset @x3 += @offset @y3 -= @offset end elsif @flip == :right if @even @x2 -= @offset @y2 -= @offset @x4 -= @offset @y4 -= @offset else @x1 -= @offset @y1 += @offset @x3 -= @offset @y3 += @offset end end @z = 50 - @index if @flip == :left and @ticks == 0 @flip = nil if @ticks == 0 end |