Class: UI::VoltorbFlip::Cursor
- Inherits:
-
Sprite
- Object
- LiteRGSS::Disposable
- LiteRGSS::Drawable
- LiteRGSS::Sprite
- LiteRGSS::ShaderedSprite
- Sprite
- UI::VoltorbFlip::Cursor
- Defined in:
- scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb
Overview
Cursor shown in VoltorbFlip scene
Instance Attribute Summary collapse
-
#board_x ⇒ Integer
readonly
The X coords on the board of the cursor.
-
#board_y ⇒ Integer
readonly
The Y coords on the board of the cursor.
-
#mode ⇒ Symbol
The cursor mode :normal, :memo.
Attributes inherited from LiteRGSS::ShaderedSprite
Attributes inherited from LiteRGSS::Sprite
#__index__, #angle, #bitmap, #height, #mirror, #opacity, #ox, #oy, #src_rect, #viewport, #visible, #width, #x, #y, #z, #zoom, #zoom_x, #zoom_y
Instance Method Summary collapse
-
#get_board_position(x, y) ⇒ Array(Integer, Integer)
Convert board coord in pixel coords.
-
#initialize(viewport) ⇒ Cursor
constructor
Create a new cursor.
-
#move_on_board(dx, dy)
Start the cursor mouvement.
-
#moveto(board_x, board_y)
Move the cursor to a dedicated board coordinate.
-
#update_move ⇒ Boolean
Update the cursor mouvement, return true if the mouvement has been updated.
Methods inherited from Sprite
#load, #mouse_in?, #set_origin_div, #set_rect, #set_rect_div, #set_z, #simple_mouse_in?, #translate_mouse_coords, #update
Methods inherited from LiteRGSS::Sprite
new, #set_origin, #set_position
Methods inherited from LiteRGSS::Disposable
Constructor Details
#initialize(viewport) ⇒ Cursor
Create a new cursor
71 72 73 74 75 76 77 78 79 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 71 def initialize() super() set_bitmap('voltorbflip/markers', :interface) self.mode = :normal @move_count = false @board_x = 0 @board_y = 0 set_position(*get_board_position(@board_x, @board_y)) end |
Instance Attribute Details
#board_x ⇒ Integer (readonly)
The X coords on the board of the cursor
61 62 63 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 61 def board_x @board_x end |
#board_y ⇒ Integer (readonly)
The Y coords on the board of the cursor
64 65 66 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 64 def board_y @board_y end |
#mode ⇒ Symbol
The cursor mode :normal, :memo
67 68 69 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 67 def mode @mode end |
Instance Method Details
#get_board_position(x, y) ⇒ Array(Integer, Integer)
Convert board coord in pixel coords
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 96 def get_board_position(x, y) if y > 4 # Quit button return GamePlay::Casino::VoltorbFlip::QuitDispX, GamePlay::Casino::VoltorbFlip::QuitDispY elsif x > 4 # Memo return GamePlay::Casino::VoltorbFlip::MemoDispX, GamePlay::Casino::VoltorbFlip::MemoDispY + y * ::GamePlay::Casino::VoltorbFlip::MemoTileSize else # Board return GamePlay::Casino::VoltorbFlip::BoardDispX + x * ::GamePlay::Casino::VoltorbFlip::TileOffset, GamePlay::Casino::VoltorbFlip::BoardDispY + y * ::GamePlay::Casino::VoltorbFlip::TileOffset end end |
#move_on_board(dx, dy)
Start the cursor mouvement
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 112 def move_on_board(dx, dy) # Update board coords if @board_y == 5 && dx != 0 @board_x = (dx < 0 ? 4 : 5) @board_y = 4 else @board_x += dx @board_y += dy end # Correct boundaries @board_x = 0 if @board_x < 0 @board_y = 0 if @board_y < 0 @board_x = 5 if @board_x > 5 @board_y = 5 if @board_y > 5 # Init mouvement @move_count = 0 @move_data = [x, y, *get_board_position(@board_x, @board_y)] end |
#moveto(board_x, board_y)
Move the cursor to a dedicated board coordinate
134 135 136 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 134 def moveto(board_x, board_y) set_position(*get_board_position(@board_x = board_x, @board_y = board_y)) end |
#update_move ⇒ Boolean
Update the cursor mouvement, return true if the mouvement has been updated
83 84 85 86 87 88 89 90 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 83 def update_move return false unless @move_count cursor_duration = GamePlay::Casino::VoltorbFlip::CursorMoveDuration self.x = @move_data[0] + (@move_data[2] - @move_data[0]) * @move_count / cursor_duration self.y = @move_data[1] + (@move_data[3] - @move_data[1]) * @move_count / cursor_duration @move_count = false if (@move_count += 1) > cursor_duration return true end |