Class: Yuki::Tilemap
- Defined in:
- scripts/01450 Systems/00003 Map Engine/00002 Logic/00300 Tilemap/00001 Tilemap.rb,
scripts/01450 Systems/00003 Map Engine/00002 Logic/00300 Tilemap/00010 MapData.rb
Overview
Class responsive of displaying the map
Direct Known Subclasses
Defined Under Namespace
Classes: MapData
Constant Summary collapse
- PRIORITY_LAYER_COUNT =
Array telling how much layer each priority layer can show
[3, 2, 2, 1, 1, 1]
Instance Attribute Summary collapse
-
#map_datas ⇒ Array<Yuki::Tilemap::MapData>
Get all the map data used by the tilemap.
-
#ox ⇒ Integer
Get the ox.
-
#oy ⇒ Integer
Get the oy.
Instance Method Summary collapse
-
#dispose
Dispose the tilemap.
-
#disposed? ⇒ Boolean
Is the tilemap disposed.
-
#initialize(viewport) ⇒ Tilemap
constructor
Create a new Tilemap.
-
#reset
Reset the tilemap in order to force it to draw the frame.
-
#update
Update the tilemap.
Constructor Details
#initialize(viewport) ⇒ Tilemap
Create a new Tilemap
18 19 20 21 22 23 24 25 26 27 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00300 Tilemap/00001 Tilemap.rb', line 18 def initialize() @viewport = create_sprites @disposed = false @map_datas = [] @ox = 0 @oy = 0 @autotile_idle_count = Configs.display.tilemap_settings.autotile_idle_frame_count reset end |
Instance Attribute Details
#map_datas ⇒ Array<Yuki::Tilemap::MapData>
Get all the map data used by the tilemap
8 9 10 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00300 Tilemap/00001 Tilemap.rb', line 8 def map_datas @map_datas end |
#ox ⇒ Integer
Get the ox
11 12 13 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00300 Tilemap/00001 Tilemap.rb', line 11 def ox @ox end |
#oy ⇒ Integer
Get the oy
14 15 16 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00300 Tilemap/00001 Tilemap.rb', line 14 def oy @oy end |
Instance Method Details
#dispose
Dispose the tilemap
69 70 71 72 73 74 75 76 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00300 Tilemap/00001 Tilemap.rb', line 69 def dispose return if @disposed @all_sprites.each(&:dispose) @all_sprites = nil @sprites = nil @disposed = true end |
#disposed? ⇒ Boolean
Is the tilemap disposed
56 57 58 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00300 Tilemap/00001 Tilemap.rb', line 56 def disposed? return @disposed end |
#reset
Reset the tilemap in order to force it to draw the frame
30 31 32 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00300 Tilemap/00001 Tilemap.rb', line 30 def reset @last_x = @last_y = @last_ox = @last_oy = nil end |
#update
Update the tilemap
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00300 Tilemap/00001 Tilemap.rb', line 35 def update return if @disposed # ox / 32 = first visible tile (x), oy / 32 first visible tile (y) x = @ox / 32 - 1 y = @oy / 32 - 1 if x != @last_x || y != @last_y || (update_autotile = (Graphics.frame_count % @autotile_idle_count == 0)) @map_datas.each(&:update_counters) if update_autotile draw(@last_x = x, @last_y = y) update_position(@ox % 32, @oy % 32) elsif ox != @last_ox || oy != @last_oy update_position(@ox % 32, @oy % 32) end @last_ox = @ox @last_oy = @oy end |