-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmini_tile_palette.rb
76 lines (72 loc) · 2.7 KB
/
mini_tile_palette.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
require 'gosu'
# rubocop:disable MethodLength
# Some common colors defined here to be reused.
class MiniTilePalette
def initialize(parent_window, path_prefix = '')
@water_tile = Gosu::Image.new(parent_window, path_prefix +
'/media/water.png', true)
@grass_tile = Gosu::Image.new(parent_window, path_prefix +
'/media/grass.png', true)
@mountain_tile = Gosu::Image.new(parent_window, path_prefix +
'/media/mountain.png', true)
@sand_tile = Gosu::Image.new(parent_window, path_prefix +
'/media/sand.png', true)
@forest_tile = Gosu::Image.new(parent_window, path_prefix +
'/media/forest.png', true)
@cave_tile = Gosu::Image.new(parent_window, path_prefix +
'/media/cave.png', true)
@city_tile = Gosu::Image.new(parent_window, path_prefix +
'/media/city.png', true)
@snow_tile = Gosu::Image.new(parent_window, path_prefix +
'/media/snow.png', true)
@snow_forest_tile = Gosu::Image.new(parent_window, path_prefix +
'/media/snow-forest.png', true)
@road_tile = Gosu::Image.new(parent_window, path_prefix +
'/media/road.png', true)
@open_tile = Gosu::Image.new(parent_window, path_prefix +
'/media/open.png', true)
@wall_tile = Gosu::Image.new(parent_window, path_prefix +
'/media/wall.png', true)
@door_tile = Gosu::Image.new(parent_window, path_prefix +
'/media/door.png', true)
@entrance_tile = Gosu::Image.new(parent_window, path_prefix +
'/media/entrance.png', true)
@empty_tile = Gosu::Image.new(parent_window, path_prefix +
'/media/empty_tile.png', true)
end
def get_mini_tile_resource(tile)
if tile.type == :water
tile_to_draw = @water_tile
elsif tile.type == :grass
tile_to_draw = @grass_tile
elsif tile.type == :sand
tile_to_draw = @sand_tile
elsif tile.type == :forest
tile_to_draw = @forest_tile
elsif tile.type == :mountain
tile_to_draw = @mountain_tile
elsif tile.type == :cave
tile_to_draw = @cave_tile
elsif tile.type == :city
tile_to_draw = @city_tile
elsif tile.type == :snow
tile_to_draw = @snow_tile
elsif tile.type == :snow_forest
tile_to_draw = @snow_forest_tile
elsif tile.type == :road
tile_to_draw = @road_tile
elsif tile.type == :open
tile_to_draw = @open_tile
elsif tile.type == :wall
tile_to_draw = @wall_tile
elsif tile.type == :door
tile_to_draw = @door_tile
elsif tile.type == :entrance
tile_to_draw = @entrance_tile
else
tile_to_draw = @empty_tile
end
tile_to_draw
end
end
# rubocop:enable MethodLength