gosu_extensions 0.1.16 → 0.1.17
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/VERSION +1 -1
- data/lib/core/game_window.rb +11 -8
- data/spec/lib/core/game_window_spec.rb +53 -0
- metadata +3 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.17
|
data/lib/core/game_window.rb
CHANGED
@@ -25,7 +25,7 @@ class GameWindow < Gosu::Window
|
|
25
25
|
:caption,
|
26
26
|
:screen_width,
|
27
27
|
:screen_height,
|
28
|
-
:
|
28
|
+
:gravity_vector
|
29
29
|
attr_reader :environment,
|
30
30
|
:moveables,
|
31
31
|
:font
|
@@ -41,6 +41,7 @@ class GameWindow < Gosu::Window
|
|
41
41
|
super self.screen_width, self.screen_height, self.full_screen, 16
|
42
42
|
|
43
43
|
setup_background
|
44
|
+
|
44
45
|
setup_menu
|
45
46
|
|
46
47
|
setup_steps
|
@@ -118,13 +119,13 @@ class GameWindow < Gosu::Window
|
|
118
119
|
@screen_height || DEFAULT_SCREEN_HEIGHT
|
119
120
|
end
|
120
121
|
def gravity_vector
|
121
|
-
@
|
122
|
+
@gravity_vector || @gravity_vector = CP::Vec2.new(0, 0.98/SUBSTEPS)
|
122
123
|
end
|
123
124
|
|
124
125
|
class << self
|
125
126
|
def gravity amount = 0.98
|
126
127
|
InitializerHooks.register self do
|
127
|
-
self.
|
128
|
+
self.gravity_vector = CP::Vec2.new(0, amount.to_f/SUBSTEPS)
|
128
129
|
end
|
129
130
|
end
|
130
131
|
def width value = DEFAULT_SCREEN_WIDTH
|
@@ -180,13 +181,15 @@ class GameWindow < Gosu::Window
|
|
180
181
|
self.caption = self.class.caption || ""
|
181
182
|
end
|
182
183
|
def setup_background
|
183
|
-
|
184
|
+
if self.background_path
|
185
|
+
@background_image = Gosu::Image.new self, File.join(Resources.root, self.background_path), self.background_hard_borders
|
186
|
+
end
|
184
187
|
end
|
185
188
|
def setup_containers
|
186
|
-
@moveables
|
187
|
-
@controls
|
189
|
+
@moveables = []
|
190
|
+
@controls = []
|
188
191
|
@remove_shapes = []
|
189
|
-
@players
|
192
|
+
@players = []
|
190
193
|
end
|
191
194
|
def setup_steps
|
192
195
|
@step = 0
|
@@ -222,7 +225,7 @@ class GameWindow < Gosu::Window
|
|
222
225
|
# add_collision_func ...
|
223
226
|
#
|
224
227
|
def setup_collisions
|
225
|
-
|
228
|
+
self.environment.instance_eval &@collision_definitions if @collision_definitions
|
226
229
|
end
|
227
230
|
|
228
231
|
# Add controls for a player.
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '/../../spec_helper')
|
2
|
+
|
3
|
+
describe GameWindow do
|
4
|
+
|
5
|
+
class Gosu::Window
|
6
|
+
def initialize(*)
|
7
|
+
# Note: Let's not initialize a real window.
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class GameWindowTest < GameWindow
|
12
|
+
def setup_font
|
13
|
+
# Note: Causes errors, test separately.
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
@window = GameWindowTest.new
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "gravity_vector" do
|
22
|
+
context 'default' do
|
23
|
+
it "should have a calculated value" do
|
24
|
+
@window.gravity_vector.x.should == 0.0
|
25
|
+
@window.gravity_vector.y.should == 0.098
|
26
|
+
end
|
27
|
+
end
|
28
|
+
context 'user defined' do
|
29
|
+
before(:each) do
|
30
|
+
GameWindowTest.class_eval do
|
31
|
+
gravity 100
|
32
|
+
end
|
33
|
+
@window = GameWindowTest.new
|
34
|
+
end
|
35
|
+
it "should have a user defined value" do
|
36
|
+
@window.gravity_vector.x.should == 0.0
|
37
|
+
@window.gravity_vector.y.should == 10.0
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "draw" do
|
43
|
+
it "should call other draw methods in sequence" do
|
44
|
+
@window.should_receive(:draw_background).once.with
|
45
|
+
@window.should_receive(:draw_ambient).once.with
|
46
|
+
@window.should_receive(:draw_moveables).once.with
|
47
|
+
@window.should_receive(:draw_ui).once.with
|
48
|
+
|
49
|
+
@window.draw
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 17
|
9
|
+
version: 0.1.17
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Florian Hanke
|
@@ -116,6 +116,7 @@ signing_key:
|
|
116
116
|
specification_version: 3
|
117
117
|
summary: Default extensions built onto the popular Gosu Framework. Uses Chipmunk for game physics. That's it for now. I'm working on them. Anyway, GAME ON!
|
118
118
|
test_files:
|
119
|
+
- spec/lib/core/game_window_spec.rb
|
119
120
|
- spec/lib/core/initializer_hooks_spec.rb
|
120
121
|
- spec/lib/core/it_is_a_spec.rb
|
121
122
|
- spec/lib/core/trait_spec.rb
|