metro 0.1.6 → 0.2.0

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/changelog.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Metro
2
2
 
3
+ ## 0.2.0 / 2012-11-07
4
+
5
+ * Views now use position instead of `x`, `y`, and `z-order`
6
+ * Point, Scale, and Dimensions is available in model and scenes.
7
+ * Events are shared from superclasses to subclases.
8
+ * Templates updated to use GameScene and GameModel for each game.
9
+ * Models are automatically added to the update loop
10
+ * Model properties now make it easier to store/retrieve various
11
+ common numeric, position font, image, and animation properties.
12
+
13
+
3
14
  ## 0.1.6 / 2012-11-07
4
15
 
5
16
  * Events are shared from superclasses to subclases.
Binary file
File without changes
@@ -1,5 +1,38 @@
1
- class Gosu::Image
1
+ module Metro
2
2
 
3
- attr_accessor :path, :tileable
3
+ #
4
+ # Image is a wrapper class for a Gosu Image. This allows for additional data to be stored
5
+ # without relying on monkey-patching on functionality.
6
+ #
7
+ class Image < SimpleDelegator
4
8
 
9
+ #
10
+ # Generate an image given the Gosu window and path. Consider using a model and an image
11
+ # property instead of using this method.
12
+ #
13
+ # @note this goes through the image property because that current performs the caching.
14
+ #
15
+ # @example Creating an Image
16
+ #
17
+ # Metro::Image.create path: "relative_imagepath.png", window: window
18
+ #
19
+ # @see Metro::Model::ImageProperty
20
+ #
21
+ def self.create(params = {})
22
+ Model::ImageProperty.image_for params
23
+ end
24
+
25
+ def initialize(gosu_image,path,tileable)
26
+ super(gosu_image)
27
+ @path = path
28
+ @tileable = tileable
29
+ end
30
+
31
+ # The relative path of the image
32
+ attr_reader :path
33
+
34
+ # The tileability of the image
35
+ attr_reader :tileable
36
+
37
+ end
5
38
  end
data/lib/metro/game.rb CHANGED
@@ -27,7 +27,7 @@ module Metro
27
27
  end
28
28
 
29
29
  def center
30
- Point.at width / 2 , height / 2
30
+ Units::Point.at width / 2 , height / 2
31
31
  end
32
32
 
33
33
  def fullscreen?
@@ -14,6 +14,7 @@ module Metro
14
14
  # @see Models::Generic
15
15
  #
16
16
  class Model
17
+ include Units
17
18
 
18
19
  #
19
20
  # This is called every update interval while the actor is in the scene
@@ -208,40 +209,13 @@ module Metro
208
209
  # with the contents of the view.
209
210
  #
210
211
  def _load(options = {})
211
- options = {} unless options
212
212
 
213
- options.each do |raw_key,value|
214
- key = raw_key.to_s.dup
215
- key = key.gsub(/-/,'_').underscore
216
-
217
-
218
- unless respond_to? key
219
- log.warn "Unknown Property #{key}"
220
- self.class.send(:define_method,key) do
221
- properties[key]
222
- end
223
- #raise "Do not know (#{key}) property"
224
- end
225
-
226
- unless respond_to? "#{key}="
227
- log.warn "Unknown Property #{key}="
228
- self.class.send(:define_method,"#{key}=") do |value|
229
- properties[key] = value
230
- end
231
-
232
- # raise "Do not know (#{key}=) property"
233
- end
234
-
235
-
236
-
237
- _loaded_options.push key
238
- send "#{key}=", value
213
+ # Clean up and symbolize all the keys then merge that with the existing properties
214
+ options.keys.each do |key|
215
+ options[key.to_s.underscore.to_sym] = options.delete(key)
239
216
  end
240
217
 
241
- end
242
-
243
- def _loaded_options
244
- @_loaded_options ||= []
218
+ properties.merge! options
245
219
  end
246
220
 
247
221
  #
@@ -252,29 +226,14 @@ module Metro
252
226
  # to another model.
253
227
  #
254
228
  def _save
255
- data_export = _loaded_options.map {|option| [ option, send(option) ] }.flatten
256
- Hash[*data_export]
229
+ properties
257
230
  end
258
231
 
259
232
  #
260
- # Generate a hash representation of the model. Currently this is ugly
233
+ # Generate a hash representation of the model.
261
234
  #
262
235
  def to_hash
263
- export = _loaded_options.map {|option| [ option, send(option) ] }
264
- export_with_name = export.reject {|item| item.first == "name" }
265
-
266
- hash = export_with_name.inject({}) {|hash,elem| hash[elem.first] = elem.last ; hash }
267
-
268
- # TODO:: color is a class that cannot be yamlized as it is and needs to be turned into a string.
269
- # TODO: Hack to save the Gosu::Color class as a string value (this is
270
- # what I hoped that the properties would solve)
271
- hash.each do |subkey,subvalue|
272
- if subvalue.is_a? Gosu::Color
273
- hash[subkey] = subvalue.to_s
274
- end
275
- end
276
-
277
- { name => hash }
236
+ { name => properties.except(:name) }
278
237
  end
279
238
 
280
239
  #
@@ -1,7 +1,7 @@
1
1
  module Metro
2
2
  class ModelFactory
3
3
 
4
- attr_reader :name, :options
4
+ attr_reader :name
5
5
 
6
6
  def initialize(name,options)
7
7
  @name = name.to_s.downcase
@@ -16,7 +16,11 @@ module Metro
16
16
  end
17
17
 
18
18
  def load_from_previous_scene?
19
- options[:from] == :previous_scene
19
+ @options[:from] == :previous_scene
20
+ end
21
+
22
+ def options
23
+ @options.except(:from)
20
24
  end
21
25
 
22
26
  def model_name
@@ -34,14 +34,14 @@ module Metro
34
34
  end
35
35
 
36
36
  def draw_vertical_lines
37
- xs = (width / spacing + 1).times.map {|segment| segment * spacing }
37
+ xs = (width / spacing + 1).to_i.times.map {|segment| segment * spacing }
38
38
  xs.each do |x|
39
39
  window.draw_line(x, 1, color, x, height, color, 0, :additive)
40
40
  end
41
41
  end
42
42
 
43
43
  def draw_horizontal_lines
44
- ys = (height / spacing + 1).times.map {|segment| segment * spacing }
44
+ ys = (height / spacing + 1).to_i.times.map {|segment| segment * spacing }
45
45
  ys.each do |y|
46
46
  window.draw_line(1, y, color, width, y, color, 0, :additive)
47
47
  end
@@ -19,6 +19,11 @@ module Metro
19
19
  property :unselected_color, type: :color, default: "rgba(119,119,119,1.0)"
20
20
  property :selected_color, type: :color, default: "rgba(255,255,255,1.0)"
21
21
 
22
+ # This is a temporary method as there is no options propery yet defined
23
+ def options
24
+ properties[:options]
25
+ end
26
+
22
27
  def alpha
23
28
  self.unselected_color_alpha
24
29
  end
@@ -1,5 +1,3 @@
1
- require_relative '../../animation/animation'
2
-
3
1
  module Metro
4
2
  class Model
5
3
 
@@ -25,10 +23,10 @@ module Metro
25
23
  # end
26
24
  # end
27
25
  #
28
- # @example Defining an animation default.
26
+ # @example Defining an animation with a path.
29
27
  #
30
28
  # class Hero < Metro::Model
31
- # property :animation, default: { path: "star.png",
29
+ # property :animation, path: "star.png", dimensions: Dimensions.of(25,25)
32
30
  # dimensions: Metro::Dimensions.of(25,25) }
33
31
  #
34
32
  # def draw
@@ -39,8 +37,8 @@ module Metro
39
37
  # @example Using an animation property with a different property name
40
38
  #
41
39
  # class Hero < Metro::Model
42
- # property :walking, type: :animation, default: { path: "star.png",
43
- # dimensions: Metro::Dimensions.of(25,25) }
40
+ # property :walking, type: :animation, path: "star.png",
41
+ # dimensions: Metro::Dimensions.of(25,25)
44
42
  #
45
43
  # def draw
46
44
  # walking.image.draw text, x, y, z_order, x_factor, y_factor, color
@@ -85,19 +83,11 @@ module Metro
85
83
  end
86
84
 
87
85
  def default_image_path
88
- if options[:default] and options[:default][:path]
89
- asset_path(options[:default][:path])
90
- else
91
- metro_asset_path("missing_animation.png")
92
- end
86
+ options[:path] ? options[:path] : metro_asset_path("missing_animation.png")
93
87
  end
94
88
 
95
89
  def default_dimensions
96
- if options[:default] and options[:default][:dimensions]
97
- options[:default][:dimensions]
98
- else
99
- Dimensions.of 16.0, 16.0
100
- end
90
+ options[:dimensions] ? options[:dimensions] : Dimensions.of(16.0,16.0)
101
91
  end
102
92
 
103
93
  #
@@ -120,7 +110,7 @@ module Metro
120
110
 
121
111
  animation_images = images[path]
122
112
  unless animation_images
123
- animation_images = create_image(window,absolute_path,width,height,tileable)
113
+ animation_images = create_images(window,absolute_path,width,height,tileable)
124
114
  images[path] = animation_images
125
115
  end
126
116
 
@@ -133,7 +123,7 @@ module Metro
133
123
 
134
124
  private
135
125
 
136
- def self.create_image(window,path,width,height,tileable)
126
+ def self.create_images(window,path,width,height,tileable)
137
127
  Gosu::Image.load_tiles(window,path,width,height,tileable)
138
128
  end
139
129
 
@@ -23,16 +23,16 @@ module Metro
23
23
  #
24
24
  # end
25
25
  #
26
- # @example Defining an image property providing a default
26
+ # @example Defining an image property providing a path
27
27
  #
28
28
  # class Player < Metro::Model
29
- # property :image, default: "player.png"
29
+ # property :image, path: "player.png"
30
30
  # end
31
31
  #
32
32
  # @example Using an image property with a different property name
33
33
  #
34
34
  # class Player < Metro::Model
35
- # property :disconnected_image, type: :image, default: "disconnected_player.png"
35
+ # property :disconnected_image, type: :image, path: "disconnected_player.png"
36
36
  #
37
37
  # def draw
38
38
  # disconnected_image.draw x, y, z_order, x_factor, y_factor, color, :add)
@@ -41,10 +41,18 @@ module Metro
41
41
  #
42
42
  class ImageProperty < Property
43
43
 
44
+ get do
45
+ default_image
46
+ end
47
+
44
48
  # Return the image at the specified path.
45
49
  # @note The path should be the relative path within the game.
46
50
  get String do |path|
47
- self.class.image_for_path path: path, window: model.window
51
+ self.class.image_for path: path, window: model.window
52
+ end
53
+
54
+ set do
55
+ default_image.path
48
56
  end
49
57
 
50
58
  # Set the image with the specified path.
@@ -59,6 +67,15 @@ module Metro
59
67
  image.path
60
68
  end
61
69
 
70
+ def default_image
71
+ self.class.image_for path: default_image_path, window: model.window
72
+ end
73
+
74
+ def default_image_path
75
+ options[:path] || metro_asset_path("missing.png")
76
+ end
77
+
78
+
62
79
  #
63
80
  # Return an image for the specified path. On first request it will be loaded from
64
81
  # the file-system. On subsequent requests it will be pulled from the cache.
@@ -66,18 +83,22 @@ module Metro
66
83
  # @param [Hash] options the relative `path` to the image and the window for which it
67
84
  # will be displayed.
68
85
  #
69
- def self.image_for_path(options)
86
+ def self.image_for(options)
70
87
  options.symbolize_keys!
71
- path = options[:path]
88
+
89
+ absolute_path = path = options[:path]
90
+ absolute_path = asset_path(absolute_path) unless absolute_path.start_with? "/"
91
+
92
+ tileable = !!options[:tileable]
72
93
  window = options[:window]
73
94
 
74
- image = images[path]
75
- unless image
76
- image = create_image(window,path,false)
77
- images[path] = image
95
+ gosu_image = images[path]
96
+ unless gosu_image
97
+ gosu_image = create_image(window,absolute_path,tileable)
98
+ images[path] = gosu_image
78
99
  end
79
100
 
80
- image
101
+ Image.new gosu_image, path, tileable
81
102
  end
82
103
 
83
104
  def self.images
@@ -86,13 +107,8 @@ module Metro
86
107
 
87
108
  private
88
109
 
89
- # @TODO The Gosu::Image creation should automatically perform this operation of saving the path
90
- # to the image. This should be monkey-patched onto the image so that images created outside
91
- # of this process will also have a specified path.
92
110
  def self.create_image(window,path,tileable)
93
- image = Gosu::Image.new(window,asset_path(path),tileable)
94
- image.path = path
95
- image
111
+ Gosu::Image.new(window,path,tileable)
96
112
  end
97
113
 
98
114
  end
@@ -2,6 +2,8 @@ module Metro
2
2
  class Model
3
3
 
4
4
  class Property
5
+ include Units
6
+
5
7
  attr_reader :model, :options
6
8
 
7
9
  def initialize(model,options={})
@@ -22,7 +22,7 @@ module Metro
22
22
  # @example Defining with a default and text that will be instance evaluated.
23
23
  #
24
24
  # class ScoreBoard < Metro::Model
25
- # property :font, default: 'Score is #{player.score}'
25
+ # property :text, default: 'Score is #{player.score}'
26
26
  # end
27
27
  #
28
28
  # @example Using a text property with a different property name
@@ -31,7 +31,7 @@ module Metro
31
31
  # property :description, type: :text
32
32
  #
33
33
  # def draw
34
- # description_font.draw text, x, y, z_order, x_factor, y_factor, color
34
+ # description_font.draw description, x, y, z_order, x_factor, y_factor, color
35
35
  # end
36
36
  # end
37
37
  #
@@ -57,7 +57,7 @@ module Metro
57
57
  end
58
58
 
59
59
  def default_text
60
- options[:default] || 'Text for #{model} not specified!'
60
+ options[:default] || 'TEXT NOT SPECIFIED!'
61
61
  end
62
62
 
63
63
  end
data/lib/metro/scene.rb CHANGED
@@ -27,6 +27,7 @@ module Metro
27
27
  # so that every subclass does not have to constantly call `super`.
28
28
  #
29
29
  class Scene
30
+ include Units
30
31
 
31
32
  #
32
33
  # As Scene does a lot of work for you with regarding to setting up content, it is
@@ -0,0 +1,23 @@
1
+ module Metro
2
+ module Units
3
+ class Dimensions < Struct.new(:width,:height)
4
+
5
+ def self.none
6
+ new 0.0, 0.0
7
+ end
8
+
9
+ def self.of(width,height)
10
+ new width.to_f, height.to_f
11
+ end
12
+
13
+ def self.parse(string)
14
+ to *string.split(",",2).map(&:to_f)
15
+ end
16
+
17
+ def to_s
18
+ "#{width},#{height}"
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ module Metro
2
+ module Units
3
+ class Point < Struct.new(:x,:y,:z)
4
+ def self.zero
5
+ new 0.0, 0.0, 0.0
6
+ end
7
+
8
+ def self.at(x,y,z=0.0)
9
+ new x.to_f, y.to_f, z.to_f
10
+ end
11
+
12
+ def self.parse(string)
13
+ at *string.split(",",3).map(&:to_f)
14
+ end
15
+
16
+ alias_method :z_order, :z
17
+ alias_method :z_order=, :z=
18
+
19
+ def to_s
20
+ "#{x},#{y},#{z}"
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ module Metro
2
+ module Units
3
+ class Scale < Struct.new(:x_factor,:y_factor)
4
+
5
+ def self.one
6
+ new 1.0, 1.0
7
+ end
8
+
9
+ def self.to(x,y)
10
+ new x.to_f, y.to_f
11
+ end
12
+
13
+ def self.parse(string)
14
+ to *string.split(",",2).map(&:to_f)
15
+ end
16
+
17
+ def to_s
18
+ "#{x_factor},#{y_factor}"
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ require_relative 'point'
2
+ require_relative 'dimensions'
3
+ require_relative 'scale'
data/lib/metro/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Metro
2
- VERSION = "0.1.6"
2
+ VERSION = "0.2.0"
3
3
  WEBSITE = "https://github.com/burtlo/metro"
4
4
  CONTACT_EMAILS = ["franklin.webber@gmail.com"]
5
5
 
data/lib/metro.rb CHANGED
@@ -1,7 +1,8 @@
1
+ require 'delegate'
2
+ require 'logger'
3
+ require 'erb'
4
+
1
5
  require 'gosu'
2
- require 'gosu_ext/color'
3
- require 'gosu_ext/image'
4
- require 'gosu_ext/gosu_constants'
5
6
  require 'i18n'
6
7
  require 'active_support'
7
8
  require 'active_support/dependencies'
@@ -9,15 +10,16 @@ require 'active_support/inflector'
9
10
  require 'active_support/core_ext/hash'
10
11
  require 'active_support/hash_with_indifferent_access'
11
12
 
13
+ require 'gosu_ext/color'
14
+ require 'gosu_ext/image'
15
+ require 'gosu_ext/animation'
16
+ require 'gosu_ext/gosu_constants'
12
17
  require 'core_ext/numeric'
13
- require 'logger'
14
- require 'erb'
15
18
 
16
19
  require 'locale/locale'
20
+
17
21
  require 'metro/asset_path'
18
- require 'metro/models/point'
19
- require 'metro/models/scale'
20
- require 'metro/models/dimensions'
22
+ require 'metro/units/units'
21
23
  require 'metro/logging'
22
24
  require 'metro/version'
23
25
  require 'metro/template_message'
@@ -12,8 +12,19 @@ class GameScene < Metro::Scene
12
12
  event :on_up, KbR do |event|
13
13
  if event.control?
14
14
  Metro.reload!
15
- transition_to self.class.scene_name
15
+ transition_to scene_name
16
16
  end
17
17
  end
18
18
 
19
+ #
20
+ # @example Setting up the ability for all subclassed scenes
21
+ # to be edited with the 'Ctrl+E' event
22
+ #
23
+ event :on_up, KbR do |event|
24
+ if event.control?
25
+ transition_to scene_name, with: edit
26
+ end
27
+ end
28
+
29
+
19
30
  end
@@ -1,21 +1,59 @@
1
1
  class <%= model_name %> < GameModel
2
2
 
3
3
  #
4
- # Example Event Handling Definitions
4
+ # Properties
5
5
  #
6
- # @example Registering the keyboard down event to execute a block of code
6
+ # Models commonly have properties that you want to be able to get, set, and save.
7
+ # Usually within ruby you would write attr_accessor methods and initialize them.
8
+ # Metro provides some shorthand class helper methods that allow you to quickly
9
+ # define these properties with the added benefit that they will be persisted when
10
+ # the model is saved within the view and the type will be maintained.
7
11
  #
8
- # event :on_down, Gosu::GpLeft, Gosu::GpUp, do
12
+ # # @example of adding a `position` property to your model
13
+ # # Property defines a `position` accessor as well as `x`, `y`, and `z` (or `z_order`)
14
+ # # accessors.
15
+ # property :position
16
+ #
17
+ # # @example of adding an `image` property to your model
18
+ # # An image property can be set up with an image path or that can be set later
19
+ # # through the `image` accessor that is added.
20
+ #
21
+ # property :image, path: "player.png"
22
+ #
23
+ # # @example of adding an `numeric` property to your model
24
+ # # A lot of times you want to track some numeric value like score. Here we
25
+ # # create a `score` accessor and assign a default value.
26
+ # property :score, type: numeric, default: 0
27
+ #
28
+ # # @example of adding an `text` property to your model
29
+ # # A lot of times you want to track some numeric value like score. Here we
30
+ # # create a `text` accessor and assign a default value.
31
+ # property :description, type: text, default: 'Greetings Earthling!'
32
+ #
33
+ # For more information see the other defined properties.
34
+ #
35
+ # @see Metro::Model::AnimationProperty
36
+ # @see Metro::Model::ImageProperty
37
+ # @see Metro::Model::NumericProperty
38
+ # @see Metro::Model::ScaleProperty
39
+ # @see Metro::Model::TextProperty
40
+ # @see Metro::Model::PositionProperty
41
+ # @see Metro::Model::FontProperty
42
+ #
43
+
44
+ #
45
+ # Events
46
+ #
47
+ # # @example Registering the keyboard down event to execute a block of code
48
+ # event :on_down, GpLeft, GpUp, do
9
49
  # turn_left
10
50
  # end
11
51
  #
12
- # @example Registering the keyboard up key to execute the method `jump`
13
- #
52
+ # # @example Registering the keyboard up key to execute the method `jump`
14
53
  # event :on_up, KbEscape, do: :jump
15
54
  #
16
- # @example Registering for button held events that would build the model's acceleration
17
- #
18
- # event :on_hold, KbRight, Gosu::GpRight do
55
+ # # @example Registering for button held events that would build the model's acceleration
56
+ # event :on_hold, KbRight, GpRight do
19
57
  # acceleration += 1
20
58
  # end
21
59
  #
@@ -26,8 +64,8 @@ class <%= model_name %> < GameModel
26
64
  # @see https://github.com/jlnr/gosu/blob/master/Gosu/ButtonsWin.hpp
27
65
  #
28
66
  #
29
- # @example Registering for an event called 'save_complete' event that anyone
30
- # can generate and this scene block will execute this code.
67
+ # # @example Registering for an event called 'save_complete' event that anyone
68
+ # # can generate and this scene block will execute this code.
31
69
  #
32
70
  # event :notification, :game_over do
33
71
  # puts "Game is Over!"
@@ -37,10 +75,11 @@ class <%= model_name %> < GameModel
37
75
  # to generate the notification
38
76
  #
39
77
  # def update_score
40
- # score = score + 1
78
+ # @score = score + 1
41
79
  # if score >= winning_score
42
80
  # notification :game_over
43
81
  # end
82
+ # end
44
83
  #
45
84
 
46
85
  #
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.6
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -110,6 +110,7 @@ files:
110
110
  - Rakefile
111
111
  - bin/metro
112
112
  - changelog.md
113
+ - lib/assets/missing.png
113
114
  - lib/assets/missing_animation.png
114
115
  - lib/commands/generate_game.rb
115
116
  - lib/commands/generate_model.rb
@@ -117,6 +118,7 @@ files:
117
118
  - lib/commands/generate_view.rb
118
119
  - lib/commands/thor.rb
119
120
  - lib/core_ext/numeric.rb
121
+ - lib/gosu_ext/animation.rb
120
122
  - lib/gosu_ext/color.rb
121
123
  - lib/gosu_ext/gosu_constants.rb
122
124
  - lib/gosu_ext/image.rb
@@ -124,7 +126,6 @@ files:
124
126
  - lib/locale/locale.rb
125
127
  - lib/metro.rb
126
128
  - lib/metro/animation/after_interval_factory.rb
127
- - lib/metro/animation/animation.rb
128
129
  - lib/metro/animation/animation_factory.rb
129
130
  - lib/metro/animation/easing.rb
130
131
  - lib/metro/animation/has_animations.rb
@@ -145,7 +146,6 @@ files:
145
146
  - lib/metro/game/dsl.rb
146
147
  - lib/metro/logging.rb
147
148
  - lib/metro/missing_scene.rb
148
- - lib/metro/models/dimensions.rb
149
149
  - lib/metro/models/draws.rb
150
150
  - lib/metro/models/key_value_coding.rb
151
151
  - lib/metro/models/model.rb
@@ -156,7 +156,6 @@ 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/point.rb
160
159
  - lib/metro/models/properties/angle.rb
161
160
  - lib/metro/models/properties/animation.rb
162
161
  - lib/metro/models/properties/color.rb
@@ -170,7 +169,6 @@ files:
170
169
  - lib/metro/models/properties/text.rb
171
170
  - lib/metro/models/properties/velocity.rb
172
171
  - lib/metro/models/rectangle_bounds.rb
173
- - lib/metro/models/scale.rb
174
172
  - lib/metro/scene.rb
175
173
  - lib/metro/scenes.rb
176
174
  - lib/metro/template_message.rb
@@ -178,6 +176,10 @@ files:
178
176
  - lib/metro/transitions/fade_transition_scene.rb
179
177
  - lib/metro/transitions/scene_transitions.rb
180
178
  - lib/metro/transitions/transition_scene.rb
179
+ - lib/metro/units/dimensions.rb
180
+ - lib/metro/units/point.rb
181
+ - lib/metro/units/scale.rb
182
+ - lib/metro/units/units.rb
181
183
  - lib/metro/version.rb
182
184
  - lib/metro/views/json_view.rb
183
185
  - lib/metro/views/no_view.rb
@@ -223,12 +225,13 @@ licenses: []
223
225
  post_install_message: ! " ______ ___ _____\n ___ |/ /_____ __ /_______________\n
224
226
  \ __ /|_/ / _ _ \\_ __/__ ___/_ __ \\\n _ / / / / __// /_ _ / /
225
227
  /_/ /\n /_/ /_/ \\___/ \\__/ /_/ \\____/\n\n Thank you for installing
226
- metro 0.1.6 / 2012-11-07.\n ---------------------------------------------------------------------\n
227
- \ Changes:\n \n * Events are shared from superclasses to subclases.\n * Templates
228
- updated to use GameScene and GameModel for each game.\n * Models are automatically
229
- added to the update loop\n * Model properties now make it easier to store/retrieve
230
- various\n common numeric, position font, image, and animation properties.\n \n\n
231
- \ ---------------------------------------------------------------------\n"
228
+ metro 0.2.0 / 2012-11-07.\n ---------------------------------------------------------------------\n
229
+ \ Changes:\n \n * Views now use position instead of `x`, `y`, and `z-order`\n
230
+ \ * Point, Scale, and Dimensions is available in model and scenes.\n * Events are
231
+ shared from superclasses to subclases.\n * Templates updated to use GameScene and
232
+ GameModel for each game.\n * Models are automatically added to the update loop\n
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"
232
235
  rdoc_options: []
233
236
  require_paths:
234
237
  - lib
@@ -1,21 +0,0 @@
1
- module Metro
2
- class Dimensions < Struct.new(:width,:height)
3
-
4
- def self.none
5
- new 0.0, 0.0
6
- end
7
-
8
- def self.of(width,height)
9
- new width.to_f, height.to_f
10
- end
11
-
12
- def self.parse(string)
13
- to *string.split(",",2).map(&:to_f)
14
- end
15
-
16
- def to_s
17
- "#{width},#{height}"
18
- end
19
-
20
- end
21
- end
@@ -1,23 +0,0 @@
1
- module Metro
2
- class Point < Struct.new(:x,:y,:z)
3
- def self.zero
4
- new 0.0, 0.0, 0.0
5
- end
6
-
7
- def self.at(x,y,z=0.0)
8
- new x.to_f, y.to_f, z.to_f
9
- end
10
-
11
- def self.parse(string)
12
- at *string.split(",",3).map(&:to_f)
13
- end
14
-
15
- alias_method :z_order, :z
16
- alias_method :z_order=, :z=
17
-
18
- def to_s
19
- "#{x},#{y},#{z}"
20
- end
21
-
22
- end
23
- end
@@ -1,21 +0,0 @@
1
- module Metro
2
- class Scale < Struct.new(:x_factor,:y_factor)
3
-
4
- def self.one
5
- new 1.0, 1.0
6
- end
7
-
8
- def self.to(x,y)
9
- new x.to_f, y.to_f
10
- end
11
-
12
- def self.parse(string)
13
- to *string.split(",",2).map(&:to_f)
14
- end
15
-
16
- def to_s
17
- "#{x_factor},#{y_factor}"
18
- end
19
-
20
- end
21
- end