metro 0.1.2 → 0.1.3
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 +29 -13
- data/changelog.md +10 -0
- data/lib/core_ext/numeric.rb +59 -0
- data/lib/gosu_ext/gosu_constants.rb +53 -0
- data/lib/locale/en.yml +16 -0
- data/lib/locale/locale.rb +1 -0
- data/lib/metro.rb +30 -16
- data/lib/metro/animation/after_interval_factory.rb +12 -0
- data/lib/metro/animation/animation_factory.rb +3 -2
- data/lib/metro/animation/has_animations.rb +3 -3
- data/lib/metro/animation/implicit_animation.rb +33 -19
- data/lib/metro/animation/{animation.rb → on_update_operation.rb} +6 -4
- data/lib/metro/animation/scene_animation.rb +16 -0
- data/lib/metro/events/control_definition.rb +11 -0
- data/lib/metro/events/controls.rb +42 -0
- data/lib/metro/events/event_relay.rb +49 -11
- data/lib/metro/events/has_events.rb +6 -5
- data/lib/metro/game.rb +17 -11
- data/lib/metro/game/dsl.rb +8 -0
- data/lib/metro/models/image.rb +3 -1
- data/lib/metro/models/key_value_coding.rb +38 -0
- data/lib/metro/models/label.rb +18 -3
- data/lib/metro/models/menu.rb +6 -5
- data/lib/metro/models/model.rb +11 -4
- data/lib/metro/models/rectangle.rb +28 -0
- data/lib/metro/scene.rb +76 -15
- data/lib/metro/scene_view/yaml_view.rb +11 -4
- data/lib/metro/scenes.rb +27 -3
- data/lib/metro/template_message.rb +33 -4
- data/lib/metro/transitions/fade_transition_scene.rb +59 -0
- data/lib/metro/transitions/scene_transitions.rb +30 -0
- data/lib/metro/transitions/transition_scene.rb +18 -0
- data/lib/metro/version.rb +1 -1
- data/lib/metro/window.rb +0 -2
- data/lib/templates/game/metro.tt +13 -0
- data/lib/templates/game/scenes/brand_scene.rb +10 -4
- data/lib/templates/game/scenes/brand_to_title_scene.rb +3 -3
- data/lib/templates/game/scenes/title_scene.rb +1 -1
- data/lib/templates/game/views/brand_to_title.yaml +2 -4
- data/lib/templates/game/views/title.yaml +2 -4
- data/lib/templates/message.erb +1 -1
- data/lib/templates/model.rb.erb +2 -2
- data/lib/templates/scene.rb.erb +3 -3
- data/metro.gemspec +1 -0
- data/spec/core_ext/numeric_spec.rb +78 -0
- data/spec/metro/models/key_value_coding_spec.rb +61 -0
- data/spec/metro/scene_views/yaml_view_spec.rb +38 -0
- metadata +44 -6
- data/lib/metro/error.rb +0 -21
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative 'transition_scene'
|
2
|
+
|
3
|
+
module Metro
|
4
|
+
module SceneTransitions
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def insert_transition(scene,options)
|
8
|
+
return scene unless options.key?(:with)
|
9
|
+
generate_transition(name,scene,options)
|
10
|
+
end
|
11
|
+
|
12
|
+
alias_method :filter, :insert_transition
|
13
|
+
|
14
|
+
def generate_transition(name,next_scene,options)
|
15
|
+
transition = find_transition(name).new
|
16
|
+
transition.next_scene = next_scene
|
17
|
+
transition.options = options
|
18
|
+
transition
|
19
|
+
end
|
20
|
+
|
21
|
+
def find_transition(name)
|
22
|
+
supported_transitions[name]
|
23
|
+
end
|
24
|
+
|
25
|
+
def supported_transitions
|
26
|
+
Hash.new(FadeTransitionScene)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Metro
|
2
|
+
class TransitionScene < Scene
|
3
|
+
|
4
|
+
attr_accessor :next_scene, :previous_scene, :options
|
5
|
+
|
6
|
+
def prepare_transition_from(old_scene)
|
7
|
+
next_scene.prepare_transition_from(old_scene)
|
8
|
+
@previous_scene = old_scene
|
9
|
+
end
|
10
|
+
|
11
|
+
def prepare_transition_to(new_scene)
|
12
|
+
previous_scene.prepare_transition_to(new_scene)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
require_relative 'fade_transition_scene'
|
data/lib/metro/version.rb
CHANGED
data/lib/metro/window.rb
CHANGED
data/lib/templates/game/metro.tt
CHANGED
@@ -42,6 +42,19 @@ resolution 640, 480
|
|
42
42
|
#
|
43
43
|
first_scene :brand
|
44
44
|
|
45
|
+
|
46
|
+
#
|
47
|
+
# Defines controls which are meta events. They can be used group button
|
48
|
+
# events together under a single name so that you can use it throughout
|
49
|
+
# the game and also will allow for players of your game to redefine the
|
50
|
+
# keys.
|
51
|
+
#
|
52
|
+
controls do
|
53
|
+
# NAME_OF_EVENT, is: EVENT TYPE, with: [ ALL_EVENTS ]
|
54
|
+
confirmation is: :button_up, with: [ KbReturn, KbEnter, KbSpace, GpButton0 ]
|
55
|
+
cancel is: :button_up, with: [ KbEscape, KbDelete ]
|
56
|
+
end
|
57
|
+
|
45
58
|
#
|
46
59
|
# Enable debug mode for the game. Which could
|
47
60
|
# allow different logic. When this is set the
|
@@ -2,12 +2,18 @@ class BrandScene < Metro::Scene
|
|
2
2
|
|
3
3
|
draws :brand
|
4
4
|
|
5
|
-
|
5
|
+
after 2.seconds do
|
6
|
+
transition_to_brand_to_title
|
7
|
+
end
|
8
|
+
|
9
|
+
event :confirmation do
|
10
|
+
transition_to_brand_to_title
|
11
|
+
end
|
6
12
|
|
7
|
-
|
13
|
+
def transition_to_brand_to_title
|
14
|
+
animate :brand, to: { alpha: 0 }, interval: 1.second do
|
8
15
|
transition_to :brand_to_title
|
9
16
|
end
|
10
|
-
|
11
17
|
end
|
12
18
|
|
13
|
-
end
|
19
|
+
end
|
@@ -2,11 +2,11 @@ class BrandToTitleScene < Metro::Scene
|
|
2
2
|
|
3
3
|
draws :title
|
4
4
|
|
5
|
-
animate
|
6
|
-
transition_to :title
|
5
|
+
animate :title, to: { alpha: 255 }, interval: 2.seconds do
|
6
|
+
transition_to :title, with: :fade
|
7
7
|
end
|
8
8
|
|
9
|
-
event :
|
9
|
+
event :cancel do
|
10
10
|
transition_to :title
|
11
11
|
end
|
12
12
|
|
data/lib/templates/message.erb
CHANGED
data/lib/templates/model.rb.erb
CHANGED
@@ -11,11 +11,11 @@ class <%= model_name %> < Metro::Model
|
|
11
11
|
#
|
12
12
|
# @example Registering the keyboard up key to execute the method `jump`
|
13
13
|
#
|
14
|
-
# event :on_up,
|
14
|
+
# event :on_up, KbEscape, do: :jump
|
15
15
|
#
|
16
16
|
# @example Registering for button held events that would build the model's acceleration
|
17
17
|
#
|
18
|
-
# event :on_hold,
|
18
|
+
# event :on_hold, KbRight, Gosu::GpRight do
|
19
19
|
# acceleration += 1
|
20
20
|
# end
|
21
21
|
#
|
data/lib/templates/scene.rb.erb
CHANGED
@@ -29,7 +29,7 @@ class <%= scene_class_name %> < Metro::Scene
|
|
29
29
|
#
|
30
30
|
# @example of the title being moved to a new y position and the alpha level
|
31
31
|
#
|
32
|
-
# animate
|
32
|
+
# animate :title, to: { y: 80, alpha: 50 }, interval: 120 do
|
33
33
|
# puts "Done Animating!"
|
34
34
|
# end
|
35
35
|
#
|
@@ -45,11 +45,11 @@ class <%= scene_class_name %> < Metro::Scene
|
|
45
45
|
#
|
46
46
|
# @example Registering the keyboard up key to execute the method `leave_scene`
|
47
47
|
#
|
48
|
-
# event :on_up,
|
48
|
+
# event :on_up, KbEscape, do: :leave_scene
|
49
49
|
#
|
50
50
|
# @example Registering for button held events that would move an actor named `player`
|
51
51
|
#
|
52
|
-
# event :on_hold,
|
52
|
+
# event :on_hold, KbRight, Gosu::GpRight do
|
53
53
|
# title.alpha = title.alpha - 1
|
54
54
|
# end
|
55
55
|
# Keystroke and Game Event Reference
|
data/metro.gemspec
CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |gem|
|
|
27
27
|
gem.add_dependency 'gosu', '~> 0.7'
|
28
28
|
gem.add_dependency 'thor', '~> 0.16.0'
|
29
29
|
gem.add_dependency 'sender', '~> 1.5.10'
|
30
|
+
gem.add_dependency 'i18n', '~> 0.6.1'
|
30
31
|
gem.add_development_dependency 'rspec', '~> 2.11'
|
31
32
|
|
32
33
|
gem.files = `git ls-files`.split($/)
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Numeric do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
Numeric.tick_interval = 16.666666
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#tick(s)" do
|
10
|
+
context "when using an Integer" do
|
11
|
+
subject { 60 }
|
12
|
+
let(:expected_value) { 60 }
|
13
|
+
|
14
|
+
its(:tick) { should eq expected_value }
|
15
|
+
its(:ticks) { should eq expected_value }
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when using a Float" do
|
19
|
+
subject { 70.1 }
|
20
|
+
let(:expected_value) { 70.1 }
|
21
|
+
|
22
|
+
its(:tick) { should eq expected_value }
|
23
|
+
its(:ticks) { should eq expected_value }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#second(s)" do
|
28
|
+
|
29
|
+
context "when using an Integer" do
|
30
|
+
context "when the tick interval has not been set" do
|
31
|
+
subject { 2 }
|
32
|
+
let(:expected_value) { 120 }
|
33
|
+
|
34
|
+
its(:second) { should eq expected_value }
|
35
|
+
its(:seconds) { should eq expected_value }
|
36
|
+
its(:sec) { should eq expected_value }
|
37
|
+
its(:secs) { should eq expected_value }
|
38
|
+
end
|
39
|
+
|
40
|
+
context "when the tick interval has been set to 33.3333" do
|
41
|
+
before :each do
|
42
|
+
Numeric.tick_interval = 33.333333
|
43
|
+
end
|
44
|
+
|
45
|
+
subject { 2 }
|
46
|
+
let(:expected_value) { 60 }
|
47
|
+
|
48
|
+
its(:second) { should eq expected_value }
|
49
|
+
its(:seconds) { should eq expected_value }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "when using a Float" do
|
54
|
+
context "when the tick interval has not been set" do
|
55
|
+
subject { 2.5 }
|
56
|
+
let(:expected_value) { 150 }
|
57
|
+
|
58
|
+
its(:second) { should eq expected_value }
|
59
|
+
its(:seconds) { should eq expected_value }
|
60
|
+
its(:sec) { should eq expected_value }
|
61
|
+
its(:secs) { should eq expected_value }
|
62
|
+
end
|
63
|
+
|
64
|
+
context "when the tick interval has been set" do
|
65
|
+
before :each do
|
66
|
+
Numeric.tick_interval = 33.333333
|
67
|
+
end
|
68
|
+
|
69
|
+
subject { 3.5 }
|
70
|
+
let(:expected_value) { 105 }
|
71
|
+
|
72
|
+
its(:second) { should eq expected_value }
|
73
|
+
its(:seconds) { should eq expected_value }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metro::KeyValueCoding do
|
4
|
+
|
5
|
+
class KeyValueCodingObject
|
6
|
+
include Metro::KeyValueCoding
|
7
|
+
attr_accessor :description, :properties
|
8
|
+
end
|
9
|
+
|
10
|
+
subject do
|
11
|
+
object = KeyValueCodingObject.new
|
12
|
+
|
13
|
+
object.description = "Describe Yourself"
|
14
|
+
object.properties = { height: 100, width: 50 }
|
15
|
+
|
16
|
+
object
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#get" do
|
20
|
+
context "when given a key with a single attribute" do
|
21
|
+
let(:key) { :description }
|
22
|
+
let(:expected_value) { "Describe Yourself" }
|
23
|
+
|
24
|
+
it "should return the value" do
|
25
|
+
subject.get(key).should eq expected_value
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when given a key with multiple attributes" do
|
30
|
+
let(:key) { "properties.keys" }
|
31
|
+
let(:expected_value) { [ :height, :width ] }
|
32
|
+
|
33
|
+
it "should return the expected value" do
|
34
|
+
subject.get(key).should eq expected_value
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#set" do
|
40
|
+
context "when given a key with a single attribute" do
|
41
|
+
let(:key) { :description }
|
42
|
+
let(:expected_value) { "New Description" }
|
43
|
+
|
44
|
+
it "should set the value" do
|
45
|
+
subject.set(key,expected_value)
|
46
|
+
subject.get(key).should eq expected_value
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "when given a key with multiple attributes" do
|
51
|
+
let(:key) { "properties.default" }
|
52
|
+
let(:expected_value) { 0 }
|
53
|
+
|
54
|
+
it "should set the value" do
|
55
|
+
subject.set(key,expected_value)
|
56
|
+
subject.get(key).should eq expected_value
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metro::SceneView::YAMLView do
|
4
|
+
|
5
|
+
subject { described_class }
|
6
|
+
let(:view_name) { "example" }
|
7
|
+
|
8
|
+
before do
|
9
|
+
File.stub(:exists?).and_return(false)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ".exists?" do
|
13
|
+
context "when a view file exists with the extension YAML" do
|
14
|
+
before do
|
15
|
+
File.stub(:exists?).with(filepath_that_exists).and_return(true)
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:filepath_that_exists) { "#{view_name}.yaml" }
|
19
|
+
|
20
|
+
it "should return true" do
|
21
|
+
subject.exists?(view_name).should be_true
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
context "when a view file exists with the extension YML" do
|
26
|
+
before :each do
|
27
|
+
File.stub(:exists?).with(filepath_that_exists).and_return(true)
|
28
|
+
end
|
29
|
+
|
30
|
+
let(:filepath_that_exists) { "#{view_name}.yml" }
|
31
|
+
|
32
|
+
it "should return true" do
|
33
|
+
subject.exists?(view_name).should be_true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
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.1.
|
4
|
+
version: 0.1.3
|
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-10-
|
12
|
+
date: 2012-10-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gosu
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.5.10
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: i18n
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.6.1
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.6.1
|
62
78
|
- !ruby/object:Gem::Dependency
|
63
79
|
name: rspec
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,15 +115,22 @@ files:
|
|
99
115
|
- lib/commands/generate_scene.rb
|
100
116
|
- lib/commands/generate_view.rb
|
101
117
|
- lib/commands/thor.rb
|
118
|
+
- lib/core_ext/numeric.rb
|
102
119
|
- lib/core_ext/string.rb
|
103
120
|
- lib/gosu_ext/color.rb
|
121
|
+
- lib/gosu_ext/gosu_constants.rb
|
122
|
+
- lib/locale/en.yml
|
123
|
+
- lib/locale/locale.rb
|
104
124
|
- lib/metro.rb
|
105
|
-
- lib/metro/animation/
|
125
|
+
- lib/metro/animation/after_interval_factory.rb
|
106
126
|
- lib/metro/animation/animation_factory.rb
|
107
127
|
- lib/metro/animation/easing.rb
|
108
128
|
- lib/metro/animation/has_animations.rb
|
109
129
|
- lib/metro/animation/implicit_animation.rb
|
110
|
-
- lib/metro/
|
130
|
+
- lib/metro/animation/on_update_operation.rb
|
131
|
+
- lib/metro/animation/scene_animation.rb
|
132
|
+
- lib/metro/events/control_definition.rb
|
133
|
+
- lib/metro/events/controls.rb
|
111
134
|
- lib/metro/events/event_factory.rb
|
112
135
|
- lib/metro/events/event_relay.rb
|
113
136
|
- lib/metro/events/has_events.rb
|
@@ -118,10 +141,12 @@ files:
|
|
118
141
|
- lib/metro/models/draws.rb
|
119
142
|
- lib/metro/models/generic.rb
|
120
143
|
- lib/metro/models/image.rb
|
144
|
+
- lib/metro/models/key_value_coding.rb
|
121
145
|
- lib/metro/models/label.rb
|
122
146
|
- lib/metro/models/menu.rb
|
123
147
|
- lib/metro/models/model.rb
|
124
148
|
- lib/metro/models/model_factory.rb
|
149
|
+
- lib/metro/models/rectangle.rb
|
125
150
|
- lib/metro/scene.rb
|
126
151
|
- lib/metro/scene_view/json_view.rb
|
127
152
|
- lib/metro/scene_view/no_view.rb
|
@@ -129,6 +154,9 @@ files:
|
|
129
154
|
- lib/metro/scene_view/yaml_view.rb
|
130
155
|
- lib/metro/scenes.rb
|
131
156
|
- lib/metro/template_message.rb
|
157
|
+
- lib/metro/transitions/fade_transition_scene.rb
|
158
|
+
- lib/metro/transitions/scene_transitions.rb
|
159
|
+
- lib/metro/transitions/transition_scene.rb
|
132
160
|
- lib/metro/version.rb
|
133
161
|
- lib/metro/window.rb
|
134
162
|
- lib/templates/game/README.md.tt
|
@@ -145,16 +173,23 @@ files:
|
|
145
173
|
- lib/templates/scene.rb.erb
|
146
174
|
- lib/templates/view.yaml.erb
|
147
175
|
- metro.gemspec
|
176
|
+
- spec/core_ext/numeric_spec.rb
|
148
177
|
- spec/core_ext/string_spec.rb
|
149
178
|
- spec/gosu_ext/color_spec.rb
|
179
|
+
- spec/metro/models/key_value_coding_spec.rb
|
180
|
+
- spec/metro/scene_views/yaml_view_spec.rb
|
150
181
|
- spec/spec_helper.rb
|
151
182
|
homepage: https://github.com/burtlo/metro
|
152
183
|
licenses: []
|
153
184
|
post_install_message: ! " ______ ___ _____\n ___ |/ /_____ __ /_______________\n
|
154
185
|
\ __ /|_/ / _ _ \\_ __/__ ___/_ __ \\\n _ / / / / __// /_ _ / /
|
155
186
|
/_/ /\n /_/ /_/ \\___/ \\__/ /_/ \\____/\n\n Thank you for installing
|
156
|
-
metro 0.1.
|
157
|
-
\ Changes:\n \n *
|
187
|
+
metro 0.1.3 / 2012-10-28.\n ---------------------------------------------------------------------\n
|
188
|
+
\ Changes:\n \n * Fade Scene Transition support added\n * Numeric#seconds and
|
189
|
+
Numeric#ticks helpers added\n * Scenes can now define delayed events `after 2.seconds
|
190
|
+
do ; end`\n * Labels have more defaults and more font options and size\n * Labels
|
191
|
+
and images will default to center of screen\n * Able to define game controls within
|
192
|
+
your metro file\n * Implicit animations support color change.\n \n\n ---------------------------------------------------------------------\n"
|
158
193
|
rdoc_options: []
|
159
194
|
require_paths:
|
160
195
|
- lib
|
@@ -179,7 +214,10 @@ summary: Metro is a 2D Gaming framework built around gosu (game development libr
|
|
179
214
|
Metro makes it easy to create games by enforcing common conceptual structures and
|
180
215
|
conventions.
|
181
216
|
test_files:
|
217
|
+
- spec/core_ext/numeric_spec.rb
|
182
218
|
- spec/core_ext/string_spec.rb
|
183
219
|
- spec/gosu_ext/color_spec.rb
|
220
|
+
- spec/metro/models/key_value_coding_spec.rb
|
221
|
+
- spec/metro/scene_views/yaml_view_spec.rb
|
184
222
|
- spec/spec_helper.rb
|
185
223
|
has_rdoc:
|