flonkerton 0.0.1 → 0.0.2
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.
- data/README.md +3 -0
- data/flonkerton.gemspec +3 -3
- data/lib/flonkerton.rb +1 -1
- data/test/integration_test.rb +2 -4
- data/test/test_helper.rb +3 -5
- data/test/unit_tests.rb +102 -100
- metadata +8 -15
data/README.md
CHANGED
@@ -72,8 +72,11 @@ See [examples](/apillet/flonkerton/tree/master/examples/).
|
|
72
72
|
## Related Projects
|
73
73
|
|
74
74
|
* [Chingu](http://github.com/ippa/chingu)
|
75
|
+
* [Compote](http://github.com/HakubJozak/compote)
|
75
76
|
* [Exuberant](http://github.com/adamsanderson/lexery/tree/master/lib/exuberant)
|
76
77
|
* [FWD](http://github.com/walski/FWD)
|
78
|
+
* [Gosu Extensions](http://github.com/floere/gosu_extensions)
|
79
|
+
* [Grandpa](http://github.com/arirusso/grandpa)
|
77
80
|
* [Lotu](http://github.com/lobo-tuerto/lotu)
|
78
81
|
* [Nimo](http://github.com/moonpxi/nimo)
|
79
82
|
* [PuitUniverse](http://github.com/oneup/puituniverse)
|
data/flonkerton.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "flonkerton"
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.2"
|
4
4
|
s.summary = "Gosu toys for the bored rubyist."
|
5
5
|
s.description = "A simple framework that aims to improve your Gosu experience."
|
6
6
|
s.authors = ["Ariel H. Pillet"]
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
|
11
11
|
s.rubyforge_project = "flonkerton"
|
12
12
|
s.add_dependency "gosu", ">= 0.7.19"
|
13
|
-
s.add_development_dependency "protest", ">= 0.
|
14
|
-
s.add_development_dependency "
|
13
|
+
s.add_development_dependency "protest", ">= 0.4.1"
|
14
|
+
s.add_development_dependency "override", ">= 0.0.10"
|
15
15
|
s.add_development_dependency "watchr", ">= 0.6"
|
16
16
|
end
|
data/lib/flonkerton.rb
CHANGED
data/test/integration_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
|
2
2
|
|
3
3
|
Protest.context('A Game example') do
|
4
4
|
module Example
|
@@ -108,8 +108,6 @@ Protest.context('A Game example') do
|
|
108
108
|
end
|
109
109
|
|
110
110
|
it "should work." do
|
111
|
-
|
112
|
-
Flonkerton::Game.start(Example::LogoScreen)
|
113
|
-
end
|
111
|
+
Flonkerton::Game.start(Example::LogoScreen)
|
114
112
|
end
|
115
113
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'protest'
|
2
|
-
require '
|
2
|
+
require 'override'
|
3
3
|
require File.dirname(__FILE__) + '/../lib/flonkerton'
|
4
4
|
|
5
|
-
|
6
|
-
include RR::Adapters::TestUnit
|
7
|
-
end
|
5
|
+
include Override
|
8
6
|
|
9
|
-
Protest.report_with(:documentation)
|
7
|
+
Protest.report_with(:documentation)
|
data/test/unit_tests.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
|
2
|
+
|
3
|
+
class Protest::TestCase
|
4
|
+
def window
|
5
|
+
@@window ||= Flonkerton::Window.new
|
6
|
+
end
|
7
|
+
end
|
2
8
|
|
3
9
|
Protest.describe('Flonkerton') do
|
4
10
|
it 'has a CONFIG hash.' do
|
@@ -37,72 +43,82 @@ Protest.describe('Flonkerton') do
|
|
37
43
|
end
|
38
44
|
|
39
45
|
Protest.describe('A Game Window') do
|
40
|
-
setup do
|
41
|
-
@window = Flonkerton::Window.new
|
42
|
-
end
|
43
|
-
|
44
46
|
it 'has a current screen. (default: WelcomeScreen)' do
|
45
|
-
|
47
|
+
assert window.screen.is_a?(Flonkerton::WelcomeScreen)
|
46
48
|
end
|
47
49
|
|
48
50
|
it 'has a next screen. (default: nil)' do
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'updates the current screen.' do
|
53
|
-
mock(@window.screen).update
|
54
|
-
@window.update
|
51
|
+
assert window.next_screen.nil?
|
55
52
|
end
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
54
|
+
context('when running') do
|
55
|
+
module Example
|
56
|
+
class LogoScreen < Flonkerton::Screen
|
57
|
+
def setup
|
58
|
+
params[:log] = Array.new
|
59
|
+
end
|
61
60
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
61
|
+
def button_down(id)
|
62
|
+
params[:log] << 'press'
|
63
|
+
end
|
66
64
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
65
|
+
def button_up(id)
|
66
|
+
params[:log] << 'release'
|
67
|
+
end
|
71
68
|
|
72
|
-
context('when working with several screens') do
|
73
|
-
module Example
|
74
|
-
class LogoScreen < Flonkerton::Screen
|
75
69
|
def update
|
70
|
+
params[:log] << 'update'
|
71
|
+
end
|
72
|
+
|
73
|
+
def draw
|
74
|
+
params[:log] << 'draw'
|
76
75
|
go_to(GameScreen)
|
77
76
|
end
|
78
77
|
end
|
79
78
|
class GameScreen < Flonkerton::Screen
|
80
|
-
def
|
81
|
-
|
79
|
+
def setup
|
80
|
+
params[:log] << 'new screen'
|
82
81
|
end
|
83
82
|
end
|
84
|
-
class CreditsScreen < Flonkerton::Screen; end
|
85
83
|
end
|
86
84
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
85
|
+
setup do
|
86
|
+
window.next_screen = Example::LogoScreen
|
87
|
+
window.update
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'draw and update the current screen.' do
|
91
|
+
assert window.params[:log].empty?
|
92
|
+
|
93
|
+
# Fake a Gosu::Window.show loop iteration
|
94
|
+
#
|
95
|
+
window.button_down(Gosu::KbSpace)
|
96
|
+
window.button_up(Gosu::KbSpace)
|
97
|
+
window.update
|
98
|
+
window.draw
|
99
|
+
|
100
|
+
result = {:log => ['press', 'release', 'update', 'draw']}
|
101
|
+
assert_equal result, window.params
|
102
|
+
|
103
|
+
# Change screen on next tick
|
104
|
+
window.update
|
105
|
+
|
106
|
+
assert window.params[:log].include?('new screen')
|
107
|
+
end
|
108
|
+
|
109
|
+
after do
|
110
|
+
window.params.clear
|
94
111
|
end
|
95
112
|
end
|
96
113
|
|
97
114
|
it 'has a params hash.' do
|
98
|
-
assert_equal Hash.new,
|
115
|
+
assert_equal Hash.new, window.params
|
99
116
|
end
|
100
117
|
end
|
101
118
|
|
102
119
|
Protest.describe('A Screen') do
|
103
120
|
setup do
|
104
|
-
@
|
105
|
-
@screen = Flonkerton::Screen.new(@game)
|
121
|
+
@screen = Flonkerton::Screen.new(window)
|
106
122
|
end
|
107
123
|
|
108
124
|
# Gosu::Window methods
|
@@ -116,18 +132,20 @@ Protest.describe('A Screen') do
|
|
116
132
|
end
|
117
133
|
|
118
134
|
it 'has mouse coordinates.' do
|
119
|
-
|
120
|
-
|
135
|
+
assert @screen.mouse_x.is_a?(Numeric)
|
136
|
+
assert @screen.mouse_y.is_a?(Numeric)
|
121
137
|
end
|
122
138
|
|
123
139
|
it 'closes itself when Escape is pressed.' do
|
124
|
-
|
140
|
+
override(@screen, :close => lambda { params[:close] = true })
|
141
|
+
|
142
|
+
assert @screen.params.empty?
|
125
143
|
@screen.button_down(Gosu::KbEscape)
|
144
|
+
assert !@screen.params.empty?
|
126
145
|
end
|
127
146
|
|
128
147
|
it 'knows if a button is down.' do
|
129
|
-
|
130
|
-
stub(@game).button_down?(Gosu::KbZ) { false }
|
148
|
+
override(window, :button_down? => lambda {|id| id == Gosu::KbA })
|
131
149
|
assert @screen.button_down?(Gosu::KbA)
|
132
150
|
assert !@screen.button_down?(Gosu::KbZ)
|
133
151
|
end
|
@@ -135,38 +153,19 @@ Protest.describe('A Screen') do
|
|
135
153
|
# Empty methods to override.
|
136
154
|
#
|
137
155
|
it 'can setup before game loop.' do
|
138
|
-
|
156
|
+
assert @screen.respond_to?(:setup)
|
139
157
|
end
|
140
158
|
|
141
159
|
it 'check button_up events while in game loop.' do
|
142
|
-
|
160
|
+
assert @screen.respond_to?(:button_up)
|
143
161
|
end
|
144
162
|
|
145
163
|
it 'updates game logic while in game loop.' do
|
146
|
-
|
164
|
+
assert @screen.respond_to?(:update)
|
147
165
|
end
|
148
166
|
|
149
167
|
it 'draws while in game loop.' do
|
150
|
-
|
151
|
-
end
|
152
|
-
|
153
|
-
it 'can switch to another screen.' do
|
154
|
-
module Example
|
155
|
-
class LogoScreen < Flonkerton::Screen
|
156
|
-
def update
|
157
|
-
go_to(GameScreen)
|
158
|
-
end
|
159
|
-
end
|
160
|
-
class GameScreen < Flonkerton::Screen
|
161
|
-
def update
|
162
|
-
close
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
@game = Flonkerton::Window.new(Example::LogoScreen)
|
168
|
-
mock(@game).next_screen=(Example::GameScreen)
|
169
|
-
@game.update
|
168
|
+
assert @screen.respond_to?(:draw)
|
170
169
|
end
|
171
170
|
|
172
171
|
it 'shares a params hash with other screens.' do
|
@@ -196,13 +195,11 @@ Protest.describe('A Screen') do
|
|
196
195
|
end
|
197
196
|
|
198
197
|
it 'can close itself.' do
|
199
|
-
|
200
|
-
@screen.close
|
198
|
+
assert @screen.respond_to?(:close) # ...
|
201
199
|
end
|
202
200
|
|
203
201
|
it 'can clip an image.' do
|
204
|
-
|
205
|
-
@screen.clip_to(10, 20, 200, 300)
|
202
|
+
assert @screen.respond_to?(:clip_to) # ...
|
206
203
|
end
|
207
204
|
|
208
205
|
it 'calls setup method after initialization.' do
|
@@ -219,75 +216,82 @@ Protest.describe('A Screen') do
|
|
219
216
|
end
|
220
217
|
|
221
218
|
Protest.describe('A WelcomeScreen') do
|
219
|
+
module DrawLog
|
220
|
+
def data
|
221
|
+
@data ||= []
|
222
|
+
end
|
223
|
+
|
224
|
+
def draw options = {}
|
225
|
+
data << options[:text]
|
226
|
+
end
|
227
|
+
|
228
|
+
def wrote? text
|
229
|
+
data.include? text
|
230
|
+
end
|
231
|
+
end
|
232
|
+
Flonkerton::Font.send(:include, DrawLog)
|
233
|
+
|
222
234
|
setup do
|
223
|
-
@
|
224
|
-
@welcome_screen = Flonkerton::WelcomeScreen.new(@game)
|
235
|
+
@welcome_screen = Flonkerton::WelcomeScreen.new(window)
|
225
236
|
end
|
226
237
|
|
227
238
|
it 'shows a brief explanation about Flonkerton.' do
|
228
|
-
|
239
|
+
font = Flonkerton::Fonts[:default]
|
240
|
+
assert !font.wrote?('Welcome')
|
229
241
|
@welcome_screen.draw
|
242
|
+
assert font.wrote?('Welcome')
|
230
243
|
end
|
231
244
|
end
|
232
245
|
|
233
246
|
Protest.describe('A Sample') do
|
234
247
|
setup do
|
235
|
-
@
|
236
|
-
@sample = Flonkerton::Sample.new(@game, 'media/select.wav')
|
248
|
+
@sample = Flonkerton::Sample.new(window, 'media/select.wav')
|
237
249
|
end
|
238
250
|
|
239
251
|
it 'is a Gosu::Sample.' do
|
240
|
-
|
252
|
+
assert @sample.is_a?(Gosu::Sample)
|
241
253
|
end
|
242
254
|
end
|
243
255
|
|
244
256
|
Protest.describe('A Song') do
|
245
257
|
setup do
|
246
|
-
@
|
247
|
-
@song = Flonkerton::Song.new(@game, 'media/catch_me_song.ogg')
|
258
|
+
@song = Flonkerton::Song.new(window, 'media/catch_me_song.ogg')
|
248
259
|
end
|
249
260
|
|
250
261
|
it 'is a Gosu::Song.' do
|
251
|
-
|
262
|
+
assert @song.is_a?(Gosu::Song)
|
252
263
|
end
|
253
264
|
|
254
265
|
it 'has a loop method.' do
|
255
|
-
|
256
|
-
@song.loop
|
266
|
+
assert @song.respond_to?(:loop) # ...
|
257
267
|
end
|
258
268
|
end
|
259
269
|
|
260
270
|
Protest.describe('A Font') do
|
261
271
|
setup do
|
262
|
-
@
|
263
|
-
@font = Flonkerton::Font.new(@game, 'media/ArcadeClassic.ttf')
|
272
|
+
@font = Flonkerton::Font.new(window, 'media/ArcadeClassic.ttf')
|
264
273
|
end
|
265
274
|
|
266
275
|
it 'is a Gosu::Font.' do
|
267
|
-
|
276
|
+
assert @font.is_a?(Gosu::Font)
|
268
277
|
end
|
269
278
|
|
270
279
|
it 'has a draw method that takes an options hash.' do
|
271
|
-
|
272
|
-
@font.draw :text => 'test', :color => Gosu::Color::RED
|
273
|
-
end
|
280
|
+
@font.draw :text => 'test', :color => Gosu::Color::RED
|
274
281
|
end
|
275
282
|
end
|
276
283
|
|
277
284
|
Protest.describe('An Image') do
|
278
285
|
setup do
|
279
|
-
@
|
280
|
-
@image = Flonkerton::Image.new(@game, 'media/gosu_logo.png')
|
286
|
+
@image = Flonkerton::Image.new(window, 'media/gosu_logo.png')
|
281
287
|
end
|
282
288
|
|
283
289
|
it 'is a Gosu::Image.' do
|
284
|
-
|
290
|
+
assert @image.is_a?(Gosu::Image)
|
285
291
|
end
|
286
292
|
|
287
293
|
it 'has a draw method that takes an options hash.' do
|
288
|
-
|
289
|
-
@image.draw :x => 20, :mode => :additive
|
290
|
-
end
|
294
|
+
@image.draw :x => 20, :mode => :additive
|
291
295
|
end
|
292
296
|
end
|
293
297
|
|
@@ -299,7 +303,7 @@ end
|
|
299
303
|
|
300
304
|
Protest.describe('Resource - Fonts') do
|
301
305
|
it 'has a :default font.' do
|
302
|
-
|
306
|
+
assert Flonkerton::Fonts[:default].is_a?(Flonkerton::Font)
|
303
307
|
end
|
304
308
|
|
305
309
|
it 'loads all fonts in CONFIG[:media_path].' do
|
@@ -368,12 +372,10 @@ Protest.describe('Resource - Tiles') do
|
|
368
372
|
|
369
373
|
# returns Gosu::Image
|
370
374
|
image = tiles.first.first
|
371
|
-
|
375
|
+
assert image.is_a?(Gosu::Image)
|
372
376
|
|
373
377
|
# ..but draw takes a hash, same as Flonkerton::Image
|
374
|
-
|
375
|
-
image.draw :x => 20, :mode => :additive
|
376
|
-
end
|
378
|
+
image.draw :x => 20, :mode => :additive
|
377
379
|
end
|
378
380
|
end
|
379
381
|
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flonkerton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 29
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Ariel H. Pillet
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-09-17 00:00:00 -03:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 37
|
30
28
|
segments:
|
31
29
|
- 0
|
32
30
|
- 7
|
@@ -42,28 +40,26 @@ dependencies:
|
|
42
40
|
requirements:
|
43
41
|
- - ">="
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 17
|
46
43
|
segments:
|
47
44
|
- 0
|
48
|
-
-
|
45
|
+
- 4
|
49
46
|
- 1
|
50
|
-
version: 0.
|
47
|
+
version: 0.4.1
|
51
48
|
type: :development
|
52
49
|
version_requirements: *id002
|
53
50
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
51
|
+
name: override
|
55
52
|
prerelease: false
|
56
53
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
54
|
none: false
|
58
55
|
requirements:
|
59
56
|
- - ">="
|
60
57
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 33
|
62
58
|
segments:
|
63
59
|
- 0
|
60
|
+
- 0
|
64
61
|
- 10
|
65
|
-
|
66
|
-
version: 0.10.11
|
62
|
+
version: 0.0.10
|
67
63
|
type: :development
|
68
64
|
version_requirements: *id003
|
69
65
|
- !ruby/object:Gem::Dependency
|
@@ -74,7 +70,6 @@ dependencies:
|
|
74
70
|
requirements:
|
75
71
|
- - ">="
|
76
72
|
- !ruby/object:Gem::Version
|
77
|
-
hash: 7
|
78
73
|
segments:
|
79
74
|
- 0
|
80
75
|
- 6
|
@@ -144,7 +139,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
139
|
requirements:
|
145
140
|
- - ">="
|
146
141
|
- !ruby/object:Gem::Version
|
147
|
-
hash: 3
|
148
142
|
segments:
|
149
143
|
- 0
|
150
144
|
version: "0"
|
@@ -153,7 +147,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
147
|
requirements:
|
154
148
|
- - ">="
|
155
149
|
- !ruby/object:Gem::Version
|
156
|
-
hash: 3
|
157
150
|
segments:
|
158
151
|
- 0
|
159
152
|
version: "0"
|