metro 0.2.1 → 0.2.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.
Files changed (45) hide show
  1. data/README.md +2 -0
  2. data/changelog.md +10 -0
  3. data/lib/assets/missing.mp3 +0 -0
  4. data/lib/assets/missing.wav +0 -0
  5. data/lib/gosu_ext/image.rb +4 -0
  6. data/lib/gosu_ext/sample.rb +18 -0
  7. data/lib/gosu_ext/song.rb +18 -0
  8. data/lib/metro.rb +2 -0
  9. data/lib/metro/animation/easing/ease_in.rb +15 -0
  10. data/lib/metro/animation/easing/easing.rb +51 -0
  11. data/lib/metro/animation/easing/linear.rb +15 -0
  12. data/lib/metro/animation/has_animations.rb +17 -0
  13. data/lib/metro/animation/implicit_animation.rb +5 -24
  14. data/lib/metro/models/draws.rb +10 -1
  15. data/lib/metro/models/model.rb +117 -89
  16. data/lib/metro/models/models/image.rb +8 -9
  17. data/lib/metro/models/models/label.rb +4 -8
  18. data/lib/metro/models/models/menu.rb +7 -9
  19. data/lib/metro/models/models/rectangle.rb +7 -12
  20. data/lib/metro/models/models/song.rb +33 -0
  21. data/lib/metro/models/properties/dimensions_property.rb +18 -1
  22. data/lib/metro/models/properties/image_property.rb +2 -2
  23. data/lib/metro/models/properties/position_property.rb +6 -0
  24. data/lib/metro/models/properties/property.rb +129 -23
  25. data/lib/metro/models/properties/sample_property.rb +97 -0
  26. data/lib/metro/models/properties/song_property.rb +113 -0
  27. data/lib/metro/scene.rb +2 -11
  28. data/lib/metro/scenes.rb +14 -7
  29. data/lib/metro/transitions/fade_transition_scene.rb +8 -1
  30. data/lib/metro/units/bounds.rb +8 -0
  31. data/lib/metro/units/dimensions.rb +23 -5
  32. data/lib/metro/units/point.rb +26 -1
  33. data/lib/metro/units/rectangle_bounds.rb +52 -0
  34. data/lib/metro/units/scale.rb +16 -0
  35. data/lib/metro/units/units.rb +3 -1
  36. data/lib/metro/version.rb +1 -1
  37. data/lib/metro/window.rb +7 -0
  38. data/lib/templates/game/README.md.tt +20 -1
  39. data/spec/metro/models/models/label_spec.rb +4 -4
  40. data/spec/metro/models/properties/dimensions_spec.rb +29 -0
  41. data/spec/metro/models/properties/position_property_spec.rb +5 -5
  42. data/spec/spec_helper.rb +3 -1
  43. metadata +22 -9
  44. data/lib/metro/animation/easing.rb +0 -31
  45. data/lib/metro/models/rectangle_bounds.rb +0 -28
@@ -11,10 +11,10 @@ describe Metro::Models::Label do
11
11
  before do
12
12
  # Reset the position of the label to the default
13
13
  subject.position = nil
14
- subject.scale = Metro::Scale.one
14
+ subject.scale = Scale.one
15
15
  end
16
16
 
17
- let(:expected_position) { Metro::Point.zero }
17
+ let(:expected_position) { Point.zero }
18
18
  its(:position) { should eq expected_position }
19
19
 
20
20
  its(:x) { should eq expected_position.x }
@@ -26,7 +26,7 @@ describe Metro::Models::Label do
26
26
 
27
27
  it "should be set succesfully" do
28
28
  subject.position = "10,10"
29
- subject.position.should eq Metro::Point.at(10,10)
29
+ subject.position.should eq Point.at(10,10)
30
30
  end
31
31
 
32
32
  context "when setting the x property" do
@@ -93,7 +93,7 @@ describe Metro::Models::Label do
93
93
 
94
94
  end
95
95
 
96
- let(:expected_scale) { Metro::Scale.one }
96
+ let(:expected_scale) { Scale.one }
97
97
 
98
98
  its(:scale) { should eq expected_scale }
99
99
  its(:x_factor) { should eq expected_scale.x_factor }
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Metro::Model::DimensionsProperty do
4
+
5
+ subject { desribed_class.new model }
6
+ let(:model) { mock("model", window: window) }
7
+ let(:window) do
8
+ mock('window',dimensions: window_dimensions )
9
+ end
10
+
11
+ let(:window_dimensions) { Dimensions.of(1,1) }
12
+
13
+ context "when defined with a default block" do
14
+
15
+ subject do
16
+ described_class.new model do
17
+ model.window.dimensions
18
+ end
19
+ end
20
+
21
+ let(:expected_dimensions) { window_dimensions }
22
+
23
+ it "should calculate the correct default value" do
24
+ subject.get(nil).should eq expected_dimensions
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -10,7 +10,7 @@ describe Metro::Model::PositionProperty do
10
10
  context "when the value is nil" do
11
11
  context "when no default value has been specified" do
12
12
 
13
- let(:expected_position) { Metro::Point.at 0.0, 0.0 }
13
+ let(:expected_position) { Point.at 0.0, 0.0 }
14
14
 
15
15
  it "should return the default position" do
16
16
  subject.get(nil).should eq expected_position
@@ -20,7 +20,7 @@ describe Metro::Model::PositionProperty do
20
20
  context "when a default value has been specified" do
21
21
 
22
22
  subject { described_class.new model, default: expected_position }
23
- let(:expected_position) { Metro::Point.at 4.0, 3.3 }
23
+ let(:expected_position) { Point.at 4.0, 3.3 }
24
24
 
25
25
  it "should return the specified default position" do
26
26
  subject.get(nil).should eq expected_position
@@ -31,7 +31,7 @@ describe Metro::Model::PositionProperty do
31
31
  context "when the value is a string" do
32
32
 
33
33
  let(:point) { "22.0,33.0" }
34
- let(:expected_position) { Metro::Point.at 22.0, 33.0 }
34
+ let(:expected_position) { Point.at 22.0, 33.0 }
35
35
 
36
36
  it "should return the position" do
37
37
  subject.get(point).should eq expected_position
@@ -56,7 +56,7 @@ describe Metro::Model::PositionProperty do
56
56
  context "when a default value has been specified" do
57
57
 
58
58
  subject { described_class.new model, default: default_point }
59
- let(:default_point) { Metro::Point.at 12, 24 }
59
+ let(:default_point) { Point.at 12, 24 }
60
60
  let(:expected_position) { "12.0,24.0,0.0" }
61
61
 
62
62
  it "should return the specified default position" do
@@ -67,7 +67,7 @@ describe Metro::Model::PositionProperty do
67
67
 
68
68
  context "when the value is a point" do
69
69
 
70
- let(:point) { Metro::Point.at 10.0, 20.0 }
70
+ let(:point) { Point.at 10.0, 20.0 }
71
71
  let(:expected_position) { "10.0,20.0,0.0" }
72
72
 
73
73
  it "should return the same position" do
data/spec/spec_helper.rb CHANGED
@@ -15,4 +15,6 @@ RSpec.configure do |config|
15
15
  # the seed, which is printed after each run.
16
16
  # --seed 1234
17
17
  config.order = 'random'
18
- end
18
+ end
19
+
20
+ include Metro::Units
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-08 00:00:00.000000000 Z
12
+ date: 2012-11-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gosu
@@ -110,7 +110,9 @@ files:
110
110
  - Rakefile
111
111
  - bin/metro
112
112
  - changelog.md
113
+ - lib/assets/missing.mp3
113
114
  - lib/assets/missing.png
115
+ - lib/assets/missing.wav
114
116
  - lib/assets/missing_animation.png
115
117
  - lib/commands/generate_game.rb
116
118
  - lib/commands/generate_model.rb
@@ -122,12 +124,16 @@ files:
122
124
  - lib/gosu_ext/color.rb
123
125
  - lib/gosu_ext/gosu_constants.rb
124
126
  - lib/gosu_ext/image.rb
127
+ - lib/gosu_ext/sample.rb
128
+ - lib/gosu_ext/song.rb
125
129
  - lib/locale/en.yml
126
130
  - lib/locale/locale.rb
127
131
  - lib/metro.rb
128
132
  - lib/metro/animation/after_interval_factory.rb
129
133
  - lib/metro/animation/animation_factory.rb
130
- - lib/metro/animation/easing.rb
134
+ - lib/metro/animation/easing/ease_in.rb
135
+ - lib/metro/animation/easing/easing.rb
136
+ - lib/metro/animation/easing/linear.rb
131
137
  - lib/metro/animation/has_animations.rb
132
138
  - lib/metro/animation/implicit_animation.rb
133
139
  - lib/metro/animation/on_update_operation.rb
@@ -156,6 +162,7 @@ files:
156
162
  - lib/metro/models/models/label.rb
157
163
  - lib/metro/models/models/menu.rb
158
164
  - lib/metro/models/models/rectangle.rb
165
+ - lib/metro/models/models/song.rb
159
166
  - lib/metro/models/properties/animation_property.rb
160
167
  - lib/metro/models/properties/color_property.rb
161
168
  - lib/metro/models/properties/dimensions_property.rb
@@ -164,9 +171,10 @@ files:
164
171
  - lib/metro/models/properties/numeric_property.rb
165
172
  - lib/metro/models/properties/position_property.rb
166
173
  - lib/metro/models/properties/property.rb
174
+ - lib/metro/models/properties/sample_property.rb
167
175
  - lib/metro/models/properties/scale_property.rb
176
+ - lib/metro/models/properties/song_property.rb
168
177
  - lib/metro/models/properties/text_property.rb
169
- - lib/metro/models/rectangle_bounds.rb
170
178
  - lib/metro/scene.rb
171
179
  - lib/metro/scenes.rb
172
180
  - lib/metro/template_message.rb
@@ -174,8 +182,10 @@ files:
174
182
  - lib/metro/transitions/fade_transition_scene.rb
175
183
  - lib/metro/transitions/scene_transitions.rb
176
184
  - lib/metro/transitions/transition_scene.rb
185
+ - lib/metro/units/bounds.rb
177
186
  - lib/metro/units/dimensions.rb
178
187
  - lib/metro/units/point.rb
188
+ - lib/metro/units/rectangle_bounds.rb
179
189
  - lib/metro/units/scale.rb
180
190
  - lib/metro/units/units.rb
181
191
  - lib/metro/version.rb
@@ -209,6 +219,7 @@ files:
209
219
  - spec/metro/models/key_value_coding_spec.rb
210
220
  - spec/metro/models/models/label_spec.rb
211
221
  - spec/metro/models/properties/color_spec.rb
222
+ - spec/metro/models/properties/dimensions_spec.rb
212
223
  - spec/metro/models/properties/font_spec.rb
213
224
  - spec/metro/models/properties/numeric_property_spec.rb
214
225
  - spec/metro/models/properties/position_property_spec.rb
@@ -223,11 +234,12 @@ licenses: []
223
234
  post_install_message: ! " ______ ___ _____\n ___ |/ /_____ __ /_______________\n
224
235
  \ __ /|_/ / _ _ \\_ __/__ ___/_ __ \\\n _ / / / / __// /_ _ / /
225
236
  /_/ /\n /_/ /_/ \\___/ \\__/ /_/ \\____/\n\n Thank you for installing
226
- metro 0.2.1 / 2012-11-08.\n ---------------------------------------------------------------------\n
227
- \ Changes:\n \n * FIX Scene fade transition color changing and implicit animations
228
- \n for colors\n * Games creating custom properties will appear in the property
229
- list\n * Properties now correctly default to numeric properties\n * Point objects
230
- can be added to other point objects. \n \n\n ---------------------------------------------------------------------\n"
237
+ metro 0.2.2 / 2012-11-10.\n ---------------------------------------------------------------------\n
238
+ \ Changes:\n \n * Song support added (scene methods and model properties)\n
239
+ \ * Sample support added (model properties)\n * Added a missing sample/song\n *
240
+ Implicit Animation easings can now be more easily created and registered.\n * Properties
241
+ can now be defined with a block\n * FIX Dimensions parse creation called wrong
242
+ method\n * Removed support for specifying a color in animation\n \n\n ---------------------------------------------------------------------\n"
231
243
  rdoc_options: []
232
244
  require_paths:
233
245
  - lib
@@ -258,6 +270,7 @@ test_files:
258
270
  - spec/metro/models/key_value_coding_spec.rb
259
271
  - spec/metro/models/models/label_spec.rb
260
272
  - spec/metro/models/properties/color_spec.rb
273
+ - spec/metro/models/properties/dimensions_spec.rb
261
274
  - spec/metro/models/properties/font_spec.rb
262
275
  - spec/metro/models/properties/numeric_property_spec.rb
263
276
  - spec/metro/models/properties/position_property_spec.rb
@@ -1,31 +0,0 @@
1
- module Metro
2
- module Easing
3
-
4
- module Linear
5
- extend self
6
-
7
- def linear(moment,start,change,interval)
8
- change * moment / interval + start
9
- end
10
-
11
- def calculate(start,final,interval)
12
- change = final - start
13
- (1..interval).map { |time| linear(time.to_f,start,change,interval) }
14
- end
15
- end
16
-
17
- module EaseIn
18
- extend self
19
-
20
- def ease_in_quad(moment,start,change,interval)
21
- change * (moment = moment / interval) * moment + start
22
- end
23
-
24
- def calculate(start,final,interval)
25
- change = final - start
26
- (1..interval).map { |time| ease_in_quad(time.to_f,start,change,interval) }
27
- end
28
- end
29
-
30
- end
31
- end
@@ -1,28 +0,0 @@
1
- module Metro
2
- module Models
3
-
4
- class RectangleBounds
5
-
6
- attr_reader :min_x, :min_y, :max_x, :max_y
7
-
8
- def initialize(min_x,min_y,max_x,max_y)
9
- @min_x = min_x
10
- @min_y = min_y
11
- @max_x = max_x
12
- @max_y = max_y
13
- end
14
-
15
- def contains?(x,y)
16
- x > min_x and x < max_x and y > min_y and y < max_y
17
- end
18
-
19
- def to_s
20
- "(#{min_x},#{min_y}) to (#{max_x},#{max_y})"
21
- end
22
-
23
- end
24
-
25
- Bounds = RectangleBounds
26
-
27
- end
28
- end