Class: UI::MiningGame::Tiles_Stack
- Inherits:
-
SpriteStack
- Object
- SpriteStack
- UI::MiningGame::Tiles_Stack
- Defined in:
- scripts/01450 Systems/08001 Mining Game/00030 UI_Mining_Game/00007 Tiles_Stack.rb
Overview
Class that describes the Tiles_Stack object
Constant Summary
Constants inherited from SpriteStack
Instance Attribute Summary collapse
-
#tile_array ⇒ Array<UI::MiningGame::Tiles] the array containing all the Tiles sprite
Array<UI::MiningGame::Tiles] the array containing all the Tiles sprite.
Attributes inherited from SpriteStack
#animated, #data, #moving, #stack, #viewport, #x, #y
Instance Method Summary collapse
-
#get_adjacent_of(x, y) ⇒ Array<UI::MiningGame::Tiles>
Get the Tiles sprite adjacent to the one at given coordinates.
-
#get_tile(x, y) ⇒ UI::MiningGame::Tiles
Get the Tiles sprite at given coordinates.
-
#initialize(viewport, arr) ⇒ Tiles_Stack
constructor
Create the Tiles_Stack.
Methods inherited from SpriteStack
#[], #add_background, #add_line, #add_text, #anime, #anime_delta_set, #dispose, #each, #execute_anime, #move, #move_to, #opacity, #opacity=, #push, #push_sprite, #set_origin, #set_position, #simple_mouse_in?, #size, #stop_animation, #translate_mouse_coords, #update, #update_animation, #update_position, #visible, #visible=, #with_cache, #with_font, #with_surface, #z, #z=
Constructor Details
#initialize(viewport, arr) ⇒ Tiles_Stack
Create the Tiles_Stack
10 11 12 13 14 15 16 17 18 19 |
# File 'scripts/01450 Systems/08001 Mining Game/00030 UI_Mining_Game/00007 Tiles_Stack.rb', line 10 def initialize(, arr) super(, initial_x, initial_y) @tile_array = Array.new(arr.size) { [] } arr.each_with_index do |line, y_index| line.each_with_index do |state, x_index| push(texture_length * x_index, texture_width * y_index, bitmap_filename, state, type: Tiles) end end stack.each_with_index { |tile, index| @tile_array[index / 16] << tile } end |
Instance Attribute Details
#tile_array ⇒ Array<UI::MiningGame::Tiles] the array containing all the Tiles sprite
Returns Array<UI::MiningGame::Tiles] the array containing all the Tiles sprite.
6 7 8 |
# File 'scripts/01450 Systems/08001 Mining Game/00030 UI_Mining_Game/00007 Tiles_Stack.rb', line 6 def tile_array @tile_array end |
Instance Method Details
#get_adjacent_of(x, y) ⇒ Array<UI::MiningGame::Tiles>
Get the Tiles sprite adjacent to the one at given coordinates
33 34 35 36 37 38 39 40 |
# File 'scripts/01450 Systems/08001 Mining Game/00030 UI_Mining_Game/00007 Tiles_Stack.rb', line 33 def get_adjacent_of(x, y) arr = [] arr << get_tile(x - 1, y) unless x == 0 arr << get_tile(x + 1, y) unless x == @tile_array[0].size - 1 arr << get_tile(x, y - 1) unless y == 0 arr << get_tile(x, y + 1) unless y == @tile_array.size - 1 return arr end |
#get_tile(x, y) ⇒ UI::MiningGame::Tiles
Get the Tiles sprite at given coordinates
25 26 27 |
# File 'scripts/01450 Systems/08001 Mining Game/00030 UI_Mining_Game/00007 Tiles_Stack.rb', line 25 def get_tile(x, y) return @tile_array[y][x] end |