metro 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/changelog.md +8 -0
- data/lib/metro.rb +1 -1
- data/lib/metro/animation/implicit_animation.rb +11 -8
- data/lib/metro/events/event_dictionary.rb +1 -1
- data/lib/metro/events/event_relay.rb +1 -1
- data/lib/metro/models/model.rb +2 -3
- data/lib/metro/models/properties/{animation.rb → animation_property.rb} +0 -0
- data/lib/metro/models/properties/{color.rb → color_property.rb} +3 -0
- data/lib/metro/models/properties/{dimensions.rb → dimensions_property.rb} +0 -0
- data/lib/metro/models/properties/{font.rb → font_property.rb} +0 -2
- data/lib/metro/models/properties/{image.rb → image_property.rb} +0 -0
- data/lib/metro/models/properties/{numeric.rb → numeric_property.rb} +0 -0
- data/lib/metro/models/properties/{position.rb → position_property.rb} +0 -0
- data/lib/metro/models/properties/property.rb +18 -27
- data/lib/metro/models/properties/{scale.rb → scale_property.rb} +0 -0
- data/lib/metro/models/properties/{text.rb → text_property.rb} +0 -0
- data/lib/metro/transitions/scene_transitions.rb +1 -1
- data/lib/metro/units/point.rb +5 -0
- data/lib/metro/version.rb +1 -1
- metadata +16 -20
- data/lib/metro/models/properties/angle.rb +0 -43
- data/lib/metro/models/properties/velocity.rb +0 -80
data/changelog.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Metro
|
2
2
|
|
3
|
+
## 0.2.1 / 2012-11-08
|
4
|
+
|
5
|
+
* FIX Scene fade transition color changing and implicit animations
|
6
|
+
for colors
|
7
|
+
* Games creating custom properties will appear in the property list
|
8
|
+
* Properties now correctly default to numeric properties
|
9
|
+
* Point objects can be added to other point objects.
|
10
|
+
|
3
11
|
## 0.2.0 / 2012-11-07
|
4
12
|
|
5
13
|
* Views now use position instead of `x`, `y`, and `z-order`
|
data/lib/metro.rb
CHANGED
@@ -128,7 +128,7 @@ module Metro
|
|
128
128
|
def load_path(path,options = {})
|
129
129
|
files = Dir["#{path}/**/*.rb"]
|
130
130
|
files.sort! {|file| File.basename(file) == options[:prioritize] ? -1 : 1 }
|
131
|
-
files.each {|
|
131
|
+
files.each {|file| require_or_load file }
|
132
132
|
end
|
133
133
|
|
134
134
|
def load_game_configuration(filename)
|
@@ -55,11 +55,14 @@ module Metro
|
|
55
55
|
|
56
56
|
if attribute == :color
|
57
57
|
final = Gosu::Color.new final
|
58
|
+
|
59
|
+
# @TODO: This is not going to work when the color uses a non-standard
|
60
|
+
# name for the color property.
|
58
61
|
|
59
|
-
animations.push build_animation_step(:
|
60
|
-
animations.push build_animation_step(:
|
61
|
-
animations.push build_animation_step(:
|
62
|
-
animations.push build_animation_step(:
|
62
|
+
animations.push build_animation_step(:red,start.red,final.red)
|
63
|
+
animations.push build_animation_step(:green,start.green,final.green)
|
64
|
+
animations.push build_animation_step(:blue,start.blue,final.blue)
|
65
|
+
animations.push build_animation_step(:alpha,start.alpha,final.alpha)
|
63
66
|
else
|
64
67
|
animations.push build_animation_step(attribute,start,final)
|
65
68
|
end
|
@@ -89,11 +92,11 @@ module Metro
|
|
89
92
|
#
|
90
93
|
def stepping(stepping)
|
91
94
|
@steppings ||= begin
|
92
|
-
hash =
|
93
|
-
hash.merge! linear: Easing::Linear,
|
94
|
-
ease_in: Easing::EaseIn
|
95
|
+
hash = HashWithIndifferentAccess.new("Metro::Easing::Linear")
|
96
|
+
hash.merge! linear: "Metro::Easing::Linear",
|
97
|
+
ease_in: "Metro::Easing::EaseIn"
|
95
98
|
end
|
96
|
-
@steppings[stepping]
|
99
|
+
@steppings[stepping].constantize
|
97
100
|
end
|
98
101
|
|
99
102
|
#
|
data/lib/metro/models/model.rb
CHANGED
@@ -275,13 +275,12 @@ module Metro
|
|
275
275
|
def self.model(name)
|
276
276
|
@models_hash ||= begin
|
277
277
|
|
278
|
-
hash =
|
278
|
+
hash = HashWithIndifferentAccess.new("Metro::Models::Generic")
|
279
279
|
|
280
280
|
models.each do |model|
|
281
|
-
common_name = model.to_s.underscore
|
282
281
|
hash[model.to_s] = model
|
283
282
|
hash[model.downcase] = model
|
284
|
-
hash[
|
283
|
+
hash[model.to_s.underscore] = model
|
285
284
|
end
|
286
285
|
|
287
286
|
hash
|
File without changes
|
@@ -56,6 +56,9 @@ module Metro
|
|
56
56
|
class ColorProperty < Property
|
57
57
|
|
58
58
|
define_property :alpha
|
59
|
+
define_property :red
|
60
|
+
define_property :green
|
61
|
+
define_property :blue
|
59
62
|
|
60
63
|
# By default convert the value to the default color if it
|
61
64
|
# cannot be processed by the other get filters.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -3,7 +3,7 @@ module Metro
|
|
3
3
|
|
4
4
|
class Property
|
5
5
|
include Units
|
6
|
-
|
6
|
+
|
7
7
|
attr_reader :model, :options
|
8
8
|
|
9
9
|
def initialize(model,options={})
|
@@ -13,7 +13,7 @@ module Metro
|
|
13
13
|
|
14
14
|
def self.gets
|
15
15
|
@gets ||= begin
|
16
|
-
hash =
|
16
|
+
hash = HashWithIndifferentAccess.new { |hash,key| hash["NilClass"] }
|
17
17
|
hash["NilClass"] = lambda { |value| raise "#{self} is not able to translate the #{value} (#{value.class})" }
|
18
18
|
hash
|
19
19
|
end
|
@@ -30,7 +30,7 @@ module Metro
|
|
30
30
|
|
31
31
|
def self.sets
|
32
32
|
@sets ||= begin
|
33
|
-
hash =
|
33
|
+
hash = HashWithIndifferentAccess.new { |hash,key| hash["NilClass"] }
|
34
34
|
hash["NilClass"] = lambda { |value| raise "#{self} is not able to translate the #{value} (#{value.class})" }
|
35
35
|
hash
|
36
36
|
end
|
@@ -59,7 +59,8 @@ module Metro
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def self.inherited(subclass)
|
62
|
-
|
62
|
+
property_name = subclass.to_s.gsub(/Property$/,'').split("::").last.underscore
|
63
|
+
properties_hash[property_name] = subclass.to_s
|
63
64
|
end
|
64
65
|
|
65
66
|
def self.properties
|
@@ -67,21 +68,12 @@ module Metro
|
|
67
68
|
end
|
68
69
|
|
69
70
|
def self.property(name)
|
70
|
-
properties_hash[name]
|
71
|
+
property_classname = properties_hash[name]
|
72
|
+
property_classname.constantize
|
71
73
|
end
|
72
74
|
|
73
75
|
def self.properties_hash
|
74
|
-
@properties_hash ||=
|
75
|
-
hash = ActiveSupport::HashWithIndifferentAccess.new(NumericProperty)
|
76
|
-
# TODO: do not store classes within the structure - this will misbehave on reloading
|
77
|
-
properties.each do |prop|
|
78
|
-
prop_name = prop.to_s.gsub(/Property$/,'').split("::").last.underscore
|
79
|
-
hash[prop_name] = prop
|
80
|
-
hash[prop_name.to_sym] = prop
|
81
|
-
end
|
82
|
-
# puts hash
|
83
|
-
hash
|
84
|
-
end
|
76
|
+
@properties_hash ||= ActiveSupport::HashWithIndifferentAccess.new { |hash,key| hash[:numeric] }
|
85
77
|
end
|
86
78
|
|
87
79
|
end
|
@@ -100,14 +92,13 @@ module Metro
|
|
100
92
|
|
101
93
|
end
|
102
94
|
|
103
|
-
require_relative '
|
104
|
-
require_relative '
|
105
|
-
|
106
|
-
require_relative '
|
107
|
-
require_relative '
|
108
|
-
require_relative '
|
109
|
-
require_relative '
|
110
|
-
require_relative '
|
111
|
-
require_relative '
|
112
|
-
require_relative '
|
113
|
-
require_relative 'velocity'
|
95
|
+
require_relative 'numeric_property'
|
96
|
+
require_relative 'text_property'
|
97
|
+
|
98
|
+
require_relative 'animation_property'
|
99
|
+
require_relative 'color_property'
|
100
|
+
require_relative 'dimensions_property'
|
101
|
+
require_relative 'font_property'
|
102
|
+
require_relative 'image_property'
|
103
|
+
require_relative 'position_property'
|
104
|
+
require_relative 'scale_property'
|
File without changes
|
File without changes
|
@@ -26,7 +26,7 @@ module Metro
|
|
26
26
|
|
27
27
|
def supported_transitions
|
28
28
|
@supported_transitions ||= begin
|
29
|
-
hash =
|
29
|
+
hash = HashWithIndifferentAccess.new("Metro::FadeTransitionScene")
|
30
30
|
hash[:edit] = "Metro::EditTransitionScene"
|
31
31
|
hash
|
32
32
|
end
|
data/lib/metro/units/point.rb
CHANGED
@@ -20,6 +20,11 @@ module Metro
|
|
20
20
|
"#{x},#{y},#{z}"
|
21
21
|
end
|
22
22
|
|
23
|
+
def +(value)
|
24
|
+
raise "Unabled to add point to #{value} #{value.class}" if [ :x, :y, :z ].find { |method| ! value.respond_to?(method) }
|
25
|
+
self.class.new((x + value.x),(y + value.y),(z + value.z))
|
26
|
+
end
|
27
|
+
|
23
28
|
end
|
24
29
|
end
|
25
30
|
end
|
data/lib/metro/version.rb
CHANGED
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.
|
4
|
+
version: 0.2.1
|
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-
|
12
|
+
date: 2012-11-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gosu
|
@@ -156,18 +156,16 @@ files:
|
|
156
156
|
- lib/metro/models/models/label.rb
|
157
157
|
- lib/metro/models/models/menu.rb
|
158
158
|
- lib/metro/models/models/rectangle.rb
|
159
|
-
- lib/metro/models/properties/
|
160
|
-
- lib/metro/models/properties/
|
161
|
-
- lib/metro/models/properties/
|
162
|
-
- lib/metro/models/properties/
|
163
|
-
- lib/metro/models/properties/
|
164
|
-
- lib/metro/models/properties/
|
165
|
-
- lib/metro/models/properties/
|
166
|
-
- lib/metro/models/properties/position.rb
|
159
|
+
- lib/metro/models/properties/animation_property.rb
|
160
|
+
- lib/metro/models/properties/color_property.rb
|
161
|
+
- lib/metro/models/properties/dimensions_property.rb
|
162
|
+
- lib/metro/models/properties/font_property.rb
|
163
|
+
- lib/metro/models/properties/image_property.rb
|
164
|
+
- lib/metro/models/properties/numeric_property.rb
|
165
|
+
- lib/metro/models/properties/position_property.rb
|
167
166
|
- lib/metro/models/properties/property.rb
|
168
|
-
- lib/metro/models/properties/
|
169
|
-
- lib/metro/models/properties/
|
170
|
-
- lib/metro/models/properties/velocity.rb
|
167
|
+
- lib/metro/models/properties/scale_property.rb
|
168
|
+
- lib/metro/models/properties/text_property.rb
|
171
169
|
- lib/metro/models/rectangle_bounds.rb
|
172
170
|
- lib/metro/scene.rb
|
173
171
|
- lib/metro/scenes.rb
|
@@ -225,13 +223,11 @@ licenses: []
|
|
225
223
|
post_install_message: ! " ______ ___ _____\n ___ |/ /_____ __ /_______________\n
|
226
224
|
\ __ /|_/ / _ _ \\_ __/__ ___/_ __ \\\n _ / / / / __// /_ _ / /
|
227
225
|
/_/ /\n /_/ /_/ \\___/ \\__/ /_/ \\____/\n\n Thank you for installing
|
228
|
-
metro 0.2.
|
229
|
-
\ Changes:\n \n *
|
230
|
-
\ *
|
231
|
-
|
232
|
-
|
233
|
-
\ * Model properties now make it easier to store/retrieve various\n common numeric,
|
234
|
-
position font, image, and animation properties.\n \n \n\n ---------------------------------------------------------------------\n"
|
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"
|
235
231
|
rdoc_options: []
|
236
232
|
require_paths:
|
237
233
|
- lib
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Metro
|
2
|
-
class Model
|
3
|
-
|
4
|
-
class AngleProperty < Property
|
5
|
-
|
6
|
-
def get(value)
|
7
|
-
value ? value : Angle.new(0.0, options[:step])
|
8
|
-
end
|
9
|
-
|
10
|
-
def set(value)
|
11
|
-
Angle.new(value.to_f, options[:step])
|
12
|
-
end
|
13
|
-
|
14
|
-
class Angle
|
15
|
-
|
16
|
-
attr_reader :value
|
17
|
-
|
18
|
-
def initialize(value = 0.0,step = 1.0)
|
19
|
-
@value = value.to_f
|
20
|
-
@step = step || 1.0
|
21
|
-
end
|
22
|
-
|
23
|
-
def turn(direction)
|
24
|
-
send(direction) if [ :left, :right ].include?(direction)
|
25
|
-
end
|
26
|
-
|
27
|
-
def left
|
28
|
-
@value -= @step
|
29
|
-
end
|
30
|
-
|
31
|
-
def right
|
32
|
-
@value += @step
|
33
|
-
end
|
34
|
-
|
35
|
-
def to_f
|
36
|
-
@value.to_f
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
module Metro
|
2
|
-
class Model
|
3
|
-
|
4
|
-
class VectorProperty < Property
|
5
|
-
|
6
|
-
def get(value)
|
7
|
-
value ? value : Vector.new
|
8
|
-
end
|
9
|
-
|
10
|
-
def set(value)
|
11
|
-
Vector.new value
|
12
|
-
end
|
13
|
-
|
14
|
-
class Vector
|
15
|
-
|
16
|
-
def initialize(angle,velocity)
|
17
|
-
@angle = angle
|
18
|
-
@velocity = velocity
|
19
|
-
end
|
20
|
-
|
21
|
-
def decay!
|
22
|
-
@velocity.decay!
|
23
|
-
end
|
24
|
-
|
25
|
-
def accelerate(amount,angle)
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
def apply_x(x_position)
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
def apply_y(y_position)
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
class VelocityProperty < Property
|
43
|
-
|
44
|
-
def get(value)
|
45
|
-
value ? value : Velocity.new(0.0,0.95)
|
46
|
-
end
|
47
|
-
|
48
|
-
def set(value)
|
49
|
-
Velocity.new value
|
50
|
-
end
|
51
|
-
|
52
|
-
class Velocity
|
53
|
-
|
54
|
-
def initialize(value,decay = default_decay)
|
55
|
-
@value = value.to_f
|
56
|
-
@decay = decay || default_decay
|
57
|
-
end
|
58
|
-
|
59
|
-
def default_decay
|
60
|
-
0.95
|
61
|
-
end
|
62
|
-
|
63
|
-
def decay
|
64
|
-
@value *= @decay
|
65
|
-
end
|
66
|
-
|
67
|
-
def accelerate(amount)
|
68
|
-
@value += amount
|
69
|
-
end
|
70
|
-
|
71
|
-
def to_f
|
72
|
-
@value
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
80
|
-
end
|