gosu_tiled 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +3 -0
- data/CONTRIBUTING.md +7 -0
- data/Gemfile +4 -0
- data/Guardfile +9 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +53 -0
- data/Rakefile +2 -0
- data/examples/panorama.rb +47 -0
- data/examples/screenshots/gosu_tiled.gif +0 -0
- data/examples/screenshots/tiled.png +0 -0
- data/gosu_tiled.gemspec +28 -0
- data/lib/gosu_tiled/empty_tile.rb +8 -0
- data/lib/gosu_tiled/layer.rb +110 -0
- data/lib/gosu_tiled/layers.rb +35 -0
- data/lib/gosu_tiled/map.rb +28 -0
- data/lib/gosu_tiled/tilesets.rb +48 -0
- data/lib/gosu_tiled/version.rb +5 -0
- data/lib/gosu_tiled.rb +16 -0
- data/spec/files/ground.png +0 -0
- data/spec/files/tiled_map.json +733 -0
- data/spec/files/tiled_map.tmx +278 -0
- data/spec/files/trees.png +0 -0
- data/spec/files/water.png +0 -0
- data/spec/gosu_tiled/layer_spec.rb +60 -0
- data/spec/gosu_tiled/layers_spec.rb +37 -0
- data/spec/gosu_tiled/map_spec.rb +58 -0
- data/spec/gosu_tiled/tilesets_spec.rb +53 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/utils/test_game_window.rb +39 -0
- metadata +170 -0
@@ -0,0 +1,278 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<map version="1.0" orientation="orthogonal" width="10" height="10" tilewidth="128" tileheight="128">
|
3
|
+
<tileset firstgid="1" name="ground" tilewidth="128" tileheight="128">
|
4
|
+
<image source="ground.png" width="1024" height="1024"/>
|
5
|
+
<tile id="1">
|
6
|
+
<properties>
|
7
|
+
<property name="name" value="second"/>
|
8
|
+
</properties>
|
9
|
+
</tile>
|
10
|
+
</tileset>
|
11
|
+
<tileset firstgid="65" name="water" tilewidth="128" tileheight="128">
|
12
|
+
<image source="water.png" width="128" height="128"/>
|
13
|
+
<tile id="0">
|
14
|
+
<properties>
|
15
|
+
<property name="death" value="sinking"/>
|
16
|
+
<property name="name" value="water"/>
|
17
|
+
</properties>
|
18
|
+
</tile>
|
19
|
+
</tileset>
|
20
|
+
<tileset firstgid="66" name="Trees" tilewidth="128" tileheight="128">
|
21
|
+
<image source="trees.png" width="704" height="704"/>
|
22
|
+
</tileset>
|
23
|
+
<layer name="Water" width="10" height="10">
|
24
|
+
<data>
|
25
|
+
<tile gid="65"/>
|
26
|
+
<tile gid="65"/>
|
27
|
+
<tile gid="65"/>
|
28
|
+
<tile gid="65"/>
|
29
|
+
<tile gid="65"/>
|
30
|
+
<tile gid="65"/>
|
31
|
+
<tile gid="65"/>
|
32
|
+
<tile gid="65"/>
|
33
|
+
<tile gid="65"/>
|
34
|
+
<tile gid="65"/>
|
35
|
+
<tile gid="65"/>
|
36
|
+
<tile gid="65"/>
|
37
|
+
<tile gid="65"/>
|
38
|
+
<tile gid="0"/>
|
39
|
+
<tile gid="0"/>
|
40
|
+
<tile gid="65"/>
|
41
|
+
<tile gid="65"/>
|
42
|
+
<tile gid="65"/>
|
43
|
+
<tile gid="65"/>
|
44
|
+
<tile gid="65"/>
|
45
|
+
<tile gid="65"/>
|
46
|
+
<tile gid="65"/>
|
47
|
+
<tile gid="65"/>
|
48
|
+
<tile gid="0"/>
|
49
|
+
<tile gid="0"/>
|
50
|
+
<tile gid="65"/>
|
51
|
+
<tile gid="65"/>
|
52
|
+
<tile gid="65"/>
|
53
|
+
<tile gid="65"/>
|
54
|
+
<tile gid="65"/>
|
55
|
+
<tile gid="65"/>
|
56
|
+
<tile gid="65"/>
|
57
|
+
<tile gid="65"/>
|
58
|
+
<tile gid="0"/>
|
59
|
+
<tile gid="0"/>
|
60
|
+
<tile gid="0"/>
|
61
|
+
<tile gid="65"/>
|
62
|
+
<tile gid="65"/>
|
63
|
+
<tile gid="65"/>
|
64
|
+
<tile gid="65"/>
|
65
|
+
<tile gid="65"/>
|
66
|
+
<tile gid="65"/>
|
67
|
+
<tile gid="65"/>
|
68
|
+
<tile gid="0"/>
|
69
|
+
<tile gid="0"/>
|
70
|
+
<tile gid="0"/>
|
71
|
+
<tile gid="0"/>
|
72
|
+
<tile gid="65"/>
|
73
|
+
<tile gid="65"/>
|
74
|
+
<tile gid="65"/>
|
75
|
+
<tile gid="65"/>
|
76
|
+
<tile gid="65"/>
|
77
|
+
<tile gid="65"/>
|
78
|
+
<tile gid="0"/>
|
79
|
+
<tile gid="0"/>
|
80
|
+
<tile gid="0"/>
|
81
|
+
<tile gid="0"/>
|
82
|
+
<tile gid="65"/>
|
83
|
+
<tile gid="65"/>
|
84
|
+
<tile gid="65"/>
|
85
|
+
<tile gid="65"/>
|
86
|
+
<tile gid="65"/>
|
87
|
+
<tile gid="65"/>
|
88
|
+
<tile gid="65"/>
|
89
|
+
<tile gid="65"/>
|
90
|
+
<tile gid="65"/>
|
91
|
+
<tile gid="65"/>
|
92
|
+
<tile gid="65"/>
|
93
|
+
<tile gid="65"/>
|
94
|
+
<tile gid="65"/>
|
95
|
+
<tile gid="65"/>
|
96
|
+
<tile gid="65"/>
|
97
|
+
<tile gid="65"/>
|
98
|
+
<tile gid="65"/>
|
99
|
+
<tile gid="65"/>
|
100
|
+
<tile gid="65"/>
|
101
|
+
<tile gid="65"/>
|
102
|
+
<tile gid="65"/>
|
103
|
+
<tile gid="65"/>
|
104
|
+
<tile gid="65"/>
|
105
|
+
<tile gid="65"/>
|
106
|
+
<tile gid="65"/>
|
107
|
+
<tile gid="65"/>
|
108
|
+
<tile gid="65"/>
|
109
|
+
<tile gid="65"/>
|
110
|
+
<tile gid="65"/>
|
111
|
+
<tile gid="65"/>
|
112
|
+
<tile gid="65"/>
|
113
|
+
<tile gid="65"/>
|
114
|
+
<tile gid="65"/>
|
115
|
+
<tile gid="65"/>
|
116
|
+
<tile gid="65"/>
|
117
|
+
<tile gid="65"/>
|
118
|
+
<tile gid="65"/>
|
119
|
+
<tile gid="65"/>
|
120
|
+
<tile gid="65"/>
|
121
|
+
<tile gid="65"/>
|
122
|
+
<tile gid="65"/>
|
123
|
+
<tile gid="65"/>
|
124
|
+
<tile gid="65"/>
|
125
|
+
</data>
|
126
|
+
</layer>
|
127
|
+
<layer name="Ground" width="10" height="10">
|
128
|
+
<data>
|
129
|
+
<tile gid="0"/>
|
130
|
+
<tile gid="0"/>
|
131
|
+
<tile gid="7"/>
|
132
|
+
<tile gid="5"/>
|
133
|
+
<tile gid="57"/>
|
134
|
+
<tile gid="43"/>
|
135
|
+
<tile gid="0"/>
|
136
|
+
<tile gid="0"/>
|
137
|
+
<tile gid="0"/>
|
138
|
+
<tile gid="0"/>
|
139
|
+
<tile gid="0"/>
|
140
|
+
<tile gid="0"/>
|
141
|
+
<tile gid="28"/>
|
142
|
+
<tile gid="1"/>
|
143
|
+
<tile gid="1"/>
|
144
|
+
<tile gid="42"/>
|
145
|
+
<tile gid="0"/>
|
146
|
+
<tile gid="0"/>
|
147
|
+
<tile gid="0"/>
|
148
|
+
<tile gid="0"/>
|
149
|
+
<tile gid="0"/>
|
150
|
+
<tile gid="0"/>
|
151
|
+
<tile gid="44"/>
|
152
|
+
<tile gid="1"/>
|
153
|
+
<tile gid="1"/>
|
154
|
+
<tile gid="42"/>
|
155
|
+
<tile gid="0"/>
|
156
|
+
<tile gid="0"/>
|
157
|
+
<tile gid="0"/>
|
158
|
+
<tile gid="0"/>
|
159
|
+
<tile gid="0"/>
|
160
|
+
<tile gid="0"/>
|
161
|
+
<tile gid="28"/>
|
162
|
+
<tile gid="1"/>
|
163
|
+
<tile gid="1"/>
|
164
|
+
<tile gid="27"/>
|
165
|
+
<tile gid="43"/>
|
166
|
+
<tile gid="0"/>
|
167
|
+
<tile gid="0"/>
|
168
|
+
<tile gid="0"/>
|
169
|
+
<tile gid="0"/>
|
170
|
+
<tile gid="0"/>
|
171
|
+
<tile gid="28"/>
|
172
|
+
<tile gid="1"/>
|
173
|
+
<tile gid="1"/>
|
174
|
+
<tile gid="1"/>
|
175
|
+
<tile gid="27"/>
|
176
|
+
<tile gid="43"/>
|
177
|
+
<tile gid="0"/>
|
178
|
+
<tile gid="0"/>
|
179
|
+
<tile gid="0"/>
|
180
|
+
<tile gid="0"/>
|
181
|
+
<tile gid="28"/>
|
182
|
+
<tile gid="1"/>
|
183
|
+
<tile gid="1"/>
|
184
|
+
<tile gid="1"/>
|
185
|
+
<tile gid="59"/>
|
186
|
+
<tile gid="16"/>
|
187
|
+
<tile gid="0"/>
|
188
|
+
<tile gid="0"/>
|
189
|
+
<tile gid="0"/>
|
190
|
+
<tile gid="0"/>
|
191
|
+
<tile gid="48"/>
|
192
|
+
<tile gid="62"/>
|
193
|
+
<tile gid="61"/>
|
194
|
+
<tile gid="61"/>
|
195
|
+
<tile gid="16"/>
|
196
|
+
<tile gid="0"/>
|
197
|
+
<tile gid="0"/>
|
198
|
+
<tile gid="0"/>
|
199
|
+
<tile gid="0"/>
|
200
|
+
<tile gid="0"/>
|
201
|
+
<tile gid="0"/>
|
202
|
+
<tile gid="0"/>
|
203
|
+
<tile gid="0"/>
|
204
|
+
<tile gid="0"/>
|
205
|
+
<tile gid="0"/>
|
206
|
+
<tile gid="0"/>
|
207
|
+
<tile gid="0"/>
|
208
|
+
<tile gid="0"/>
|
209
|
+
<tile gid="0"/>
|
210
|
+
<tile gid="0"/>
|
211
|
+
<tile gid="0"/>
|
212
|
+
<tile gid="0"/>
|
213
|
+
<tile gid="0"/>
|
214
|
+
<tile gid="0"/>
|
215
|
+
<tile gid="0"/>
|
216
|
+
<tile gid="0"/>
|
217
|
+
<tile gid="0"/>
|
218
|
+
<tile gid="0"/>
|
219
|
+
<tile gid="0"/>
|
220
|
+
<tile gid="0"/>
|
221
|
+
<tile gid="0"/>
|
222
|
+
<tile gid="0"/>
|
223
|
+
<tile gid="0"/>
|
224
|
+
<tile gid="0"/>
|
225
|
+
<tile gid="0"/>
|
226
|
+
<tile gid="0"/>
|
227
|
+
<tile gid="0"/>
|
228
|
+
<tile gid="0"/>
|
229
|
+
</data>
|
230
|
+
</layer>
|
231
|
+
<objectgroup name="obj" width="10" height="10" visible="0"/>
|
232
|
+
<objectgroup name="Trees" width="10" height="10">
|
233
|
+
<object gid="66" x="580" y="506"/>
|
234
|
+
<object gid="66" x="615" y="302"/>
|
235
|
+
<object gid="74" x="408" y="238"/>
|
236
|
+
<object gid="77" x="314" y="420"/>
|
237
|
+
<object gid="79" x="474" y="654"/>
|
238
|
+
<object gid="80" x="672" y="610"/>
|
239
|
+
<object gid="81" x="403" y="726"/>
|
240
|
+
<object gid="81" x="323" y="787"/>
|
241
|
+
<object gid="86" x="654" y="827"/>
|
242
|
+
<object gid="87" x="282" y="552"/>
|
243
|
+
<object gid="87" x="665" y="597"/>
|
244
|
+
<object gid="90" x="698" y="633"/>
|
245
|
+
<object gid="90" x="718" y="636"/>
|
246
|
+
<object gid="80" x="456" y="426"/>
|
247
|
+
<object gid="82" x="464" y="434"/>
|
248
|
+
<object gid="82" x="505" y="412"/>
|
249
|
+
<object gid="82" x="512" y="454"/>
|
250
|
+
<object gid="76" x="313" y="202"/>
|
251
|
+
<object gid="76" x="574" y="251"/>
|
252
|
+
<object gid="76" x="588" y="702"/>
|
253
|
+
<object gid="76" x="723" y="694"/>
|
254
|
+
<object gid="87" x="462" y="724"/>
|
255
|
+
<object gid="87" x="483" y="763"/>
|
256
|
+
<object gid="87" x="487" y="735"/>
|
257
|
+
<object gid="87" x="534" y="758"/>
|
258
|
+
<object gid="87" x="505" y="772"/>
|
259
|
+
<object gid="87" x="544" y="802"/>
|
260
|
+
<object gid="87" x="519" y="801"/>
|
261
|
+
<object gid="87" x="478" y="809"/>
|
262
|
+
<object gid="87" x="420" y="796"/>
|
263
|
+
<object gid="87" x="406" y="825"/>
|
264
|
+
<object gid="87" x="446" y="844"/>
|
265
|
+
<object gid="87" x="483" y="844"/>
|
266
|
+
<object gid="87" x="545" y="853"/>
|
267
|
+
<object gid="87" x="509" y="845"/>
|
268
|
+
<object gid="87" x="578" y="848"/>
|
269
|
+
<object gid="87" x="582" y="829"/>
|
270
|
+
<object gid="87" x="293" y="258"/>
|
271
|
+
<object gid="87" x="289" y="305"/>
|
272
|
+
<object gid="87" x="302" y="285"/>
|
273
|
+
<object gid="87" x="298" y="337"/>
|
274
|
+
<object gid="78" x="373" y="615"/>
|
275
|
+
<object gid="78" x="301" y="639"/>
|
276
|
+
<object gid="78" x="336" y="671"/>
|
277
|
+
</objectgroup>
|
278
|
+
</map>
|
Binary file
|
Binary file
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Gosu::Tiled::Layer do
|
4
|
+
|
5
|
+
let(:files_dir) { File.join(File.dirname(File.dirname(__FILE__)), 'files') }
|
6
|
+
let(:target_class) { Gosu::Tiled::Layer }
|
7
|
+
let(:map_json) { JSON.load(File.open(File.join(files_dir, 'tiled_map.json'))) }
|
8
|
+
let(:game_window) { TestGameWindow.instance }
|
9
|
+
let(:options) { { width: 128 * 10, height: 128 * 10, tile_width: 128, tile_height: 128 } }
|
10
|
+
|
11
|
+
subject(:tilesets) { Gosu::Tiled::Tilesets.new(game_window, map_json['tilesets'], files_dir) }
|
12
|
+
subject(:tile_layer) { target_class.new(game_window, map_json['layers'][1], options) }
|
13
|
+
subject(:object_layer) { target_class.new(game_window, map_json['layers'][3], options) }
|
14
|
+
|
15
|
+
describe '#initialize' do
|
16
|
+
it 'initializes' do
|
17
|
+
expect { tile_layer }.to_not raise_error
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#visible?' do
|
22
|
+
it "knows when it's visible" do
|
23
|
+
expect(tile_layer).to be_visible
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#type' do
|
28
|
+
it 'knows correct type' do
|
29
|
+
expect(tile_layer.type).to eq 'tilelayer'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#draw' do
|
34
|
+
it 'draws tile layer' do
|
35
|
+
error = game_window.while_showing do
|
36
|
+
tile_layer.draw(0, 0, tilesets)
|
37
|
+
end
|
38
|
+
expect(error).to be_nil
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'draws object layer' do
|
42
|
+
error = game_window.while_showing do
|
43
|
+
object_layer.draw(0, 0, tilesets)
|
44
|
+
end
|
45
|
+
expect(error).to be_nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#screen_width_in_tiles' do
|
50
|
+
it 'knows how many tiles to draw' do
|
51
|
+
expect(tile_layer.screen_width_in_tiles).to be (game_window.width / 128.0).ceil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#screen_height_in_tiles' do
|
56
|
+
it 'knows how many tiles to draw' do
|
57
|
+
expect(tile_layer.screen_height_in_tiles).to be (game_window.height / 128.0).ceil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Gosu::Tiled::Layers do
|
4
|
+
|
5
|
+
let(:files_dir) { File.join(File.dirname(File.dirname(__FILE__)), 'files') }
|
6
|
+
let(:target_class) { Gosu::Tiled::Layers }
|
7
|
+
let(:map_json) { JSON.load(File.open(File.join(files_dir, 'tiled_map.json'))) }
|
8
|
+
let(:game_window) { TestGameWindow.instance }
|
9
|
+
let(:options) { { width: 128 * 10, height: 128 * 10, tile_width: 128, tile_height: 128 } }
|
10
|
+
|
11
|
+
subject(:layers) { target_class.new(game_window, map_json['layers'], options) }
|
12
|
+
|
13
|
+
describe '#initialize' do
|
14
|
+
it 'works' do
|
15
|
+
expect { layers }.to_not raise_error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#tile' do
|
20
|
+
it 'loads correct number of tile layers' do
|
21
|
+
expect(layers.tile.size).to be 2
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#object' do
|
26
|
+
it 'loads correct number of object layers' do
|
27
|
+
expect(layers.object.size).to be 1
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#size' do
|
32
|
+
it 'loads correct number of layers' do
|
33
|
+
expect(layers.size).to eq map_json['layers'].size
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Gosu::Tiled::Map do
|
4
|
+
|
5
|
+
let(:files_dir) { File.join(File.dirname(File.dirname(__FILE__)), 'files') }
|
6
|
+
let(:target_class) { Gosu::Tiled::Map }
|
7
|
+
let(:map_json) { JSON.load(File.open(File.join(files_dir, 'tiled_map.json'))) }
|
8
|
+
let(:game_window) { TestGameWindow.instance }
|
9
|
+
|
10
|
+
subject(:map) { target_class.new(game_window, map_json, files_dir) }
|
11
|
+
|
12
|
+
describe '#initialize' do
|
13
|
+
it 'initializes with window and hash' do
|
14
|
+
expect { map }.to_not raise_error
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#tilesets' do
|
19
|
+
it 'returns instance of Tilesets' do
|
20
|
+
expect(map.tilesets).to be_a Gosu::Tiled::Tilesets
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#layers' do
|
25
|
+
it 'returns instance of Layers' do
|
26
|
+
expect(map.layers).to be_a Gosu::Tiled::Layers
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#width' do
|
31
|
+
it "knows it's width" do
|
32
|
+
expect(map.width).to be 128 * 10
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#height' do
|
37
|
+
it "knows it's height" do
|
38
|
+
expect(map.height).to be 128 * 10
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#draw' do
|
43
|
+
it 'draws the map on game window' do
|
44
|
+
error = game_window.while_showing do
|
45
|
+
map.draw(0, 0)
|
46
|
+
end
|
47
|
+
expect(error).to be_nil
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'draws shifted map on game window' do
|
51
|
+
error = game_window.while_showing do
|
52
|
+
map.draw(300, 400)
|
53
|
+
end
|
54
|
+
expect(error).to be_nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Gosu::Tiled::Tilesets do
|
4
|
+
|
5
|
+
let(:files_dir) { File.join(File.dirname(File.dirname(__FILE__)), 'files') }
|
6
|
+
let(:target_class) { Gosu::Tiled::Tilesets }
|
7
|
+
let(:map_json) { JSON.load(File.open(File.join(files_dir, 'tiled_map.json'))) }
|
8
|
+
let(:game_window) { TestGameWindow.instance }
|
9
|
+
let(:water_tile) { 65 }
|
10
|
+
let(:sand_tile) { 1 }
|
11
|
+
|
12
|
+
subject(:tilesets) { target_class.new(game_window, map_json['tilesets'], files_dir) }
|
13
|
+
|
14
|
+
describe '#initialize' do
|
15
|
+
it 'initializes with game window and hash' do
|
16
|
+
expect { tilesets }.to_not raise_error
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#size' do
|
21
|
+
it 'loads correct number of tilesets' do
|
22
|
+
expect(tilesets.size).to eq map_json['tilesets'].size
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#get' do
|
27
|
+
it 'gets the right water tile' do
|
28
|
+
expect(tilesets.get(water_tile)).to be_a Gosu::Image
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'gets the right sand tile' do
|
32
|
+
expect(tilesets.get(sand_tile)).to be_a Gosu::Image
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'can draw the tile that was retrieved' do
|
36
|
+
error = game_window.while_showing do
|
37
|
+
tilesets.get(sand_tile).draw(0, 0, 0)
|
38
|
+
end
|
39
|
+
expect(error).to be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'returns empty tile' do
|
43
|
+
expect(tilesets.get(0)).to be_a Gosu::Tiled::EmptyTile
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#properties' do
|
48
|
+
it 'retrieves tile properties' do
|
49
|
+
expect(tilesets.properties(water_tile)['name']).to eq 'water'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
class TestGameWindow < Gosu::Window
|
4
|
+
include Singleton
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
super(1200, 800, false)
|
8
|
+
self.caption = "Esc = quit"
|
9
|
+
end
|
10
|
+
|
11
|
+
def update
|
12
|
+
unless ENV['NO_CLOSE']
|
13
|
+
close if @start && Gosu.milliseconds - @start > 500
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def draw
|
18
|
+
@draw_block.call
|
19
|
+
rescue => e
|
20
|
+
unless @error
|
21
|
+
puts e
|
22
|
+
puts e.backtrace
|
23
|
+
end
|
24
|
+
@error = e
|
25
|
+
end
|
26
|
+
|
27
|
+
def button_down(id)
|
28
|
+
close if id == Gosu::KbEscape
|
29
|
+
end
|
30
|
+
|
31
|
+
def while_showing(&block)
|
32
|
+
@start = Gosu.milliseconds
|
33
|
+
@error = nil
|
34
|
+
@draw_block = block
|
35
|
+
show
|
36
|
+
@start = false
|
37
|
+
@error
|
38
|
+
end
|
39
|
+
end
|