metro 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/changelog.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Metro
2
2
 
3
+ ## 0.2.3 / 2012-11-11
4
+
5
+ * FIX metro generators and templates generating out-of-date formats
6
+ * FIX YAML views wil now return an empty hash instead of false on empty files
7
+ * Added first scene and model to template.
8
+ * FIX better error message when a directory is specified
9
+ * Added the `g` generator shortcut: `metro g scene NAME`
10
+
3
11
  ## 0.2.2 / 2012-11-10
4
12
 
5
13
  * Song support added (scene methods and model properties)
Binary file
data/lib/commands/thor.rb CHANGED
@@ -48,19 +48,25 @@ module Metro
48
48
 
49
49
  end
50
50
 
51
- desc "new [GAMENAME]",
52
- "Create a new game within the directory using with the [GAMENAME] given."
51
+ desc "new GAMENAME",
52
+ "Create a new game within the directory using with the GAMENAME given."
53
53
  def new(game_name)
54
54
  Metro::GenerateGame.start [ game_name ]
55
55
  end
56
56
 
57
- desc "generate",
58
- "Create a new game model, view, or scene"
57
+ desc "generate TYPE NAME",
58
+ "Create a new type: model, view, or scene."
59
59
  def generate(type,name)
60
60
  gen = generator(type)
61
61
  gen.start [ name ]
62
62
  end
63
-
63
+
64
+ desc "g TYPE NAME",
65
+ "Create a new type: model, view, or scene."
66
+ def g(type,name)
67
+ generate(type,name)
68
+ end
69
+
64
70
  desc "help", "This commoand"
65
71
  def help
66
72
  say banner
data/lib/locale/en.yml CHANGED
@@ -8,6 +8,14 @@ en:
8
8
  actions:
9
9
  - "Ensure you have specified the correct file"
10
10
  - "Ensure that the file exists at that location"
11
+ - "Did you mean to generate a new game, scene, or model? Try: `metro help`"
12
+ specified_directory:
13
+ title: "Path specified is a directory"
14
+ message: "The specified path is a `%{directory}` and not a valid Metro game file."
15
+ actions:
16
+ - "Ensure you have specified the correct file"
17
+ - "Specify the path to the metro game file with the directory included."
18
+ - "Did you mean to generate a new game, scene, or model? Try: `metro help`"
11
19
  reserved_control_name:
12
20
  title: "Unable to define control: %{name}"
13
21
  message: "The specified control name `%{name}` is RESERVED or ALREADY DEFINED."
data/lib/metro.rb CHANGED
@@ -159,9 +159,8 @@ module Metro
159
159
 
160
160
 
161
161
  def game_file_exists?(file)
162
- unless File.exists? file
163
- error! "error.missing_metro_file", file: file
164
- end
162
+ error!("error.missing_metro_file",file: file) unless File.exists?(file)
163
+ error!("error.specified_directory",directory: file) if File.directory?(file)
165
164
  end
166
165
 
167
166
  end
@@ -7,15 +7,15 @@ module Metro
7
7
  end
8
8
 
9
9
  draw :title, text: "Missing Scene!",
10
- x: 20, y: 20, z_order: 1,
11
- x_factor: 3, y_factor: 3,
12
- color: 0xffffffff,
10
+ position: "20,20,1",
11
+ color: "rgb(255,0,0)",
12
+ font: {size: 80},
13
13
  model: "metro::models::label"
14
-
14
+
15
15
  draw :message, text: 'The scene `#{self.class.missing_scene}` was requested, but is missing!',
16
- x: 20, y: 100, z_order: 1,
17
- color: 0xffffffff,
16
+ position: "20,100,1",
17
+ color: "rgb(255,255,255)",
18
18
  model: "metro::models::label"
19
19
 
20
20
  end
21
- end
21
+ end
@@ -69,7 +69,7 @@ module Metro
69
69
  # a default value the the default song is the missing song found in Metro.
70
70
  #
71
71
  def default_song_name
72
- options[:path] || metro_asset_path('missing.mp3')
72
+ options[:path] || metro_asset_path('missing.ogg')
73
73
  end
74
74
 
75
75
  #
data/lib/metro/scenes.rb CHANGED
@@ -114,18 +114,6 @@ module Metro
114
114
  @scenes_hash ||= hash_with_missing_scene_default
115
115
  end
116
116
 
117
- #
118
- # Generate a map from the scene or scenes to include all the sub-classes of
119
- # these scenes.
120
- #
121
- # @param [Scene,Array<Scene>] scenes a scene or scene subclass or an array of
122
- # scene subclasses.
123
- #
124
- # @see #scenes_hash
125
- #
126
- def build_map_of_scenes(scenes)
127
- end
128
-
129
117
  #
130
118
  # Create a hash that will return a setup missing scene by default.
131
119
  #
data/lib/metro/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Metro
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  WEBSITE = "https://github.com/burtlo/metro"
4
4
  CONTACT_EMAILS = ["franklin.webber@gmail.com"]
5
5
 
@@ -22,7 +22,7 @@ module Metro
22
22
  # @return a Hash that contains the contents of the view.
23
23
  #
24
24
  def self.parse(view_path)
25
- YAML.load File.read yaml_view_path(view_path)
25
+ YAML.load(File.read(yaml_view_path(view_path))) or { }
26
26
  end
27
27
 
28
28
  #
Binary file
@@ -0,0 +1,20 @@
1
+ class Hero < Metro::Model
2
+
3
+ property :image, path: "hero.png"
4
+
5
+ property :position
6
+ property :angle
7
+ property :move_amount, default: 1.5
8
+
9
+ event :on_hold, KbLeft, GpLeft do
10
+ self.position -= move_amount
11
+ end
12
+
13
+ event :on_hold, KbRight, GpRight do
14
+ self.angle += move_amount
15
+ end
16
+
17
+ def draw
18
+ image.draw_rot(x,y,z_order,angle.to_f)
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ class FirstScene < GameScene
2
+
3
+ draw :hero, position: Game.center
4
+
5
+ draws :first_instruction, :second_instruction
6
+
7
+ def update
8
+ hero.position = Point.new (hero.x % Game.width), (hero.y % Game.height)
9
+ end
10
+
11
+ end
@@ -20,11 +20,11 @@ class GameScene < Metro::Scene
20
20
  # @example Setting up the ability for all subclassed scenes
21
21
  # to be edited with the 'Ctrl+E' event
22
22
  #
23
- event :on_up, KbR do |event|
23
+ event :on_up, KbE do |event|
24
24
  if event.control?
25
- transition_to scene_name, with: edit
25
+ transition_to scene_name, with: :edit
26
26
  end
27
27
  end
28
28
 
29
29
 
30
- end
30
+ end
@@ -1,5 +1,4 @@
1
1
  brand:
2
2
  model: metro::models::image
3
- path: brand.jpg
4
- x: 320
5
- y: 240
3
+ image: brand.jpg
4
+ position: "320,240,1"
@@ -1,7 +1,7 @@
1
1
  title:
2
2
  model: metro::models::label
3
3
  text: "#{Game.name}"
4
- font_size: 40
5
- y: 100
4
+ font:
5
+ size: 40
6
+ position: "320,100,1"
6
7
  color: rgba(255,255,255,0.0)
7
-
@@ -0,0 +1,14 @@
1
+ instruction: &instruction
2
+ model: metro::models::label
3
+ font:
4
+ name: Arial
5
+ size: 40
6
+ color: "rgba(255,255,0)"
7
+ first_instruction:
8
+ <<: *instruction
9
+ text: "<- to move left |"
10
+ position: "60,300,1"
11
+ second_instruction:
12
+ <<: *instruction
13
+ text: "| to move right ->"
14
+ position: "320,300,1"
@@ -1,12 +1,10 @@
1
1
  title:
2
2
  model: metro::models::label
3
3
  text: "#{Game.name}"
4
- font_size: 40
5
- y: 100
4
+ font:
5
+ size: 40
6
+ position: "320,100,1"
6
7
  color: rgba(255,255,255,1.0)
7
8
  menu:
8
9
  model: metro::models::menu
9
- x: 260
10
- y: 200
11
- color: rgb(127,127,127)
12
- highlight-color: rgb(255,255,255)
10
+ position: "260,200,1"
@@ -34,6 +34,8 @@ class <%= model_name %> < GameModel
34
34
  #
35
35
  # @see Metro::Model::AnimationProperty
36
36
  # @see Metro::Model::ImageProperty
37
+ # @see Metro::Model::SongProperty
38
+ # @see Metro::Model::SampleProperty
37
39
  # @see Metro::Model::NumericProperty
38
40
  # @see Metro::Model::ScaleProperty
39
41
  # @see Metro::Model::TextProperty
@@ -89,6 +91,17 @@ class <%= model_name %> < GameModel
89
91
  #
90
92
  def after_initialize ; end
91
93
 
94
+ #
95
+ # This method is called right after the model has been added to the scene and added
96
+ # to the window.
97
+ #
98
+ def show ; end
99
+
100
+ #
101
+ # This is called every update interval while the window is being shown.
102
+ #
103
+ def update ; end
104
+
92
105
  #
93
106
  # This is called after every {#update} and when the OS wants the window to
94
107
  # repaint itself.
@@ -3,16 +3,18 @@ class <%= scene_class_name %> < GameScene
3
3
  # but that can be overriden with the scene_name class method
4
4
  # scene_name "credits"
5
5
 
6
+ draw :title
7
+
6
8
  #
7
9
  # DRAWING and ACTORS
8
10
  #
9
11
  # @example Explicitly drawing a text label in the scene
10
12
  #
11
- # draw :title, 'text' => 'Title Screen',
12
- # 'x' => 20, 'y' => 20, 'z-order' => 0,
13
- # 'size' => 40,
14
- # 'color' => 'rgb(255,255,255)',
15
- # 'model' => 'metro::models::label'
13
+ # draw :title, text: 'Title Screen',
14
+ # position: '20,20,0',
15
+ # font: { size: 60 },
16
+ # color: 'rgb(255,255,255)',
17
+ # model: 'metro::models::label'
16
18
  #
17
19
  # The draw method can be simplier for models that have content defined
18
20
  # for them in the view or the models themselves define the appropriate
@@ -21,7 +23,7 @@ class <%= scene_class_name %> < GameScene
21
23
  # @example defining multiple things to draw; their visual data would be
22
24
  # stored within the respective view file
23
25
  #
24
- # draws :menu, :hero, :enemy
26
+ # draws :title, :hero, :enemy
25
27
  #
26
28
 
27
29
  #
@@ -114,4 +116,4 @@ class <%= scene_class_name %> < GameScene
114
116
  def prepare_transition_from(old_scene) ; end
115
117
 
116
118
 
117
- end
119
+ end
@@ -1,6 +1,9 @@
1
- # title:
2
- # model: metro::models::label
3
- # x: 30
4
- # y: 50
5
- # z-order: 4
6
- # color: "rgba(255,255,0,0.0)"
1
+ # http://www.yaml.org/YAML_for_ruby.html
2
+ ---
3
+ title:
4
+ model: "metro::models::label"
5
+ text: "Your Scene"
6
+ position: "190,200,4"
7
+ font:
8
+ size: 60
9
+ color: "rgba(255,255,0,1.0)"
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.2
4
+ version: 0.2.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-11-10 00:00:00.000000000 Z
12
+ date: 2012-11-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gosu
@@ -110,7 +110,7 @@ files:
110
110
  - Rakefile
111
111
  - bin/metro
112
112
  - changelog.md
113
- - lib/assets/missing.mp3
113
+ - lib/assets/missing.ogg
114
114
  - lib/assets/missing.png
115
115
  - lib/assets/missing.wav
116
116
  - lib/assets/missing_animation.png
@@ -199,14 +199,17 @@ files:
199
199
  - lib/metro/window.rb
200
200
  - lib/templates/game/README.md.tt
201
201
  - lib/templates/game/assets/brand.jpg
202
+ - lib/templates/game/assets/hero.png
202
203
  - lib/templates/game/metro.tt
203
- - lib/templates/game/models/game_model.rb
204
+ - lib/templates/game/models/hero.rb
204
205
  - lib/templates/game/scenes/brand_scene.rb
205
206
  - lib/templates/game/scenes/brand_to_title_scene.rb
207
+ - lib/templates/game/scenes/first_scene.rb
206
208
  - lib/templates/game/scenes/game_scene.rb
207
209
  - lib/templates/game/scenes/title_scene.rb
208
210
  - lib/templates/game/views/brand.yaml
209
211
  - lib/templates/game/views/brand_to_title.yaml
212
+ - lib/templates/game/views/first.yaml
210
213
  - lib/templates/game/views/title.yaml
211
214
  - lib/templates/message.erb
212
215
  - lib/templates/model.rb.tt
@@ -234,12 +237,12 @@ licenses: []
234
237
  post_install_message: ! " ______ ___ _____\n ___ |/ /_____ __ /_______________\n
235
238
  \ __ /|_/ / _ _ \\_ __/__ ___/_ __ \\\n _ / / / / __// /_ _ / /
236
239
  /_/ /\n /_/ /_/ \\___/ \\__/ /_/ \\____/\n\n Thank you for installing
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"
240
+ metro 0.2.3 / 2012-11-11.\n ---------------------------------------------------------------------\n
241
+ \ Changes:\n \n * FIX metro generators and templates generating out-of-date
242
+ formats\n * FIX YAML views wil now return an empty hash instead of false on empty
243
+ files\n * Added first scene and model to template.\n * FIX better error message
244
+ when a directory is specified\n * Added the `g` generator shortcut: `metro g scene
245
+ NAME`\n \n\n ---------------------------------------------------------------------\n"
243
246
  rdoc_options: []
244
247
  require_paths:
245
248
  - lib
Binary file
@@ -1,3 +0,0 @@
1
- class GameModel < Metro::Model
2
-
3
- end