metro 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
data/changelog.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Metro
2
2
 
3
+ ## 0.2.7 / 2012/11-20
4
+
5
+ * FIX to the new game template
6
+ * Updated the game template to give more movement to the hero in the first scene
7
+ * Added the fade-in, fade-out helper to show all the instructions
8
+
3
9
  ## 0.2.6 / 2012/11-20
4
10
 
5
11
  * Menus now support vertical and horizontal layout
@@ -22,12 +28,12 @@
22
28
 
23
29
  * All retrieved models from properties are now cached for better performance
24
30
  * Animations were re-vamped to accept more parameters
25
- * Metro models names in code are now refered to as "metro::models::*" to "metro::ui::*"
31
+ * Metro models names in code are now referred to as "metro::models::*" to "metro::ui::*"
26
32
 
27
33
  ## 0.2.3 / 2012-11-11
28
34
 
29
35
  * FIX metro generators and templates generating out-of-date formats
30
- * FIX YAML views wil now return an empty hash instead of false on empty files
36
+ * FIX YAML views will now return an empty hash instead of false on empty files
31
37
  * Added first scene and model to template.
32
38
  * FIX better error message when a directory is specified
33
39
  * Added the `g` generator shortcut: `metro g scene NAME`
@@ -54,7 +60,7 @@
54
60
 
55
61
  * Views now use position instead of `x`, `y`, and `z-order`
56
62
  * Point, Scale, and Dimensions is available in model and scenes.
57
- * Events are shared from superclasses to subclases.
63
+ * Events are shared from superclasses to subclasses.
58
64
  * Templates updated to use GameScene and GameModel for each game.
59
65
  * Models are automatically added to the update loop
60
66
  * Model properties now make it easier to store/retrieve various
@@ -63,7 +69,7 @@
63
69
 
64
70
  ## 0.1.6 / 2012-11-07
65
71
 
66
- * Events are shared from superclasses to subclases.
72
+ * Events are shared from superclasses to subclasses.
67
73
  * Templates updated to use GameScene and GameModel for each game.
68
74
  * Models are automatically added to the update loop
69
75
  * Model properties now make it easier to store/retrieve various
@@ -27,7 +27,7 @@ module Metro
27
27
  #
28
28
  # class Hero < Metro::Model
29
29
  # property :animation, path: "star.png", dimensions: Dimensions.of(25,25)
30
- # dimensions: Metro::Dimensions.of(25,25) }
30
+ # dimensions: Dimensions.of(25,25) }
31
31
  #
32
32
  # def draw
33
33
  # animation.image.draw text, x, y, z_order, x_factor, y_factor, color
@@ -38,7 +38,7 @@ module Metro
38
38
  #
39
39
  # class Hero < Metro::Model
40
40
  # property :walking, type: :animation, path: "star.png",
41
- # dimensions: Metro::Dimensions.of(25,25)
41
+ # dimensions: Dimensions.of(25,25)
42
42
  #
43
43
  # def draw
44
44
  # walking.image.draw text, x, y, z_order, x_factor, y_factor, color
@@ -15,7 +15,7 @@ module Metro
15
15
  #
16
16
  class GridDrawer < Model
17
17
 
18
- property :position, default: Point.at(20,20,100)
18
+ property :position, default: Point.at(0,0,100)
19
19
  property :color, default: "rgba(255,255,255,0.1)"
20
20
  property :spacing, type: :numeric, default: 10
21
21
 
data/lib/metro/scene.rb CHANGED
@@ -263,14 +263,14 @@ module Metro
263
263
  #
264
264
  # @example Retrieving the default scene name
265
265
  #
266
- # class ExampleScene
266
+ # class ExampleScene < GameScene
267
267
  # end
268
268
  #
269
269
  # ExampleScene.scene_name # => "example"
270
270
  #
271
271
  # @example Setting a custom name for the Scene
272
272
  #
273
- # class RollingCreditsScene
273
+ # class RollingCreditsScene < GameScene
274
274
  # scene_name "credits"
275
275
  # end
276
276
  #
data/lib/metro/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Metro
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  WEBSITE = "https://github.com/burtlo/metro"
4
4
  CONTACT_EMAILS = ["franklin.webber@gmail.com"]
5
5
 
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # This is the main game file which contains information
3
- # about your game. T
3
+ # about your game.
4
4
  #
5
5
  # Remember, this is really a ruby file, so anything
6
6
  # that can be done with Ruby can be written here.
@@ -5,13 +5,26 @@ class Hero < Metro::Model
5
5
  property :position
6
6
  property :angle
7
7
  property :move_amount, default: 1.5
8
+ property :turn_amount, default: 90.0
8
9
 
9
10
  event :on_hold, KbLeft, GpLeft do
10
- self.position -= move_amount
11
+ self.x -= move_amount
11
12
  end
12
13
 
13
14
  event :on_hold, KbRight, GpRight do
14
- self.angle += move_amount
15
+ self.x += move_amount
16
+ end
17
+
18
+ event :on_hold, KbUp, GpUp do
19
+ self.y -= move_amount
20
+ end
21
+
22
+ event :on_hold, KbDown, GpDown do
23
+ self.y += move_amount
24
+ end
25
+
26
+ event :on_up, KbSpace do
27
+ self.angle += turn_amount
15
28
  end
16
29
 
17
30
  def draw
@@ -2,7 +2,20 @@ class FirstScene < GameScene
2
2
 
3
3
  draw :hero, position: Game.center
4
4
 
5
- draws :first_instruction, :second_instruction
5
+ draws :first_instruction, :second_instruction, :third_instruction,
6
+ :fourth_instruction, :fifth_instruction
7
+
8
+ after 1.second do
9
+ fade_in_and_out :first_instruction do
10
+ fade_in_and_out :second_instruction do
11
+ fade_in_and_out :third_instruction do
12
+ fade_in_and_out :fourth_instruction do
13
+ fade_in_and_out :fifth_instruction
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
6
19
 
7
20
  def update
8
21
  hero.position = Point.new (hero.x % Game.width), (hero.y % Game.height)
@@ -26,5 +26,17 @@ class GameScene < Metro::Scene
26
26
  end
27
27
  end
28
28
 
29
+ #
30
+ # This animation helper will fade in and fade out information.
31
+ #
32
+ def fade_in_and_out(name)
33
+ animate name, to: { alpha: 255 }, interval: 2.seconds do
34
+ after 1.second do
35
+ animate name, to: { alpha: 0 }, interval: 1.second do
36
+ yield if block_given?
37
+ end
38
+ end
39
+ end
40
+ end
29
41
 
30
42
  end
@@ -4,4 +4,5 @@ title:
4
4
  font:
5
5
  size: 40
6
6
  position: "320,100,1"
7
+ align: center
7
8
  color: rgba(255,255,255,0.0)
@@ -1,14 +1,26 @@
1
+ # Using the power of YAML to define anchors and references it makes it easy
2
+ # to generate a common view item and then add to it or manipulate it as needed.
3
+ ---
1
4
  instruction: &instruction
2
5
  model: metro::ui::label
3
6
  font:
4
7
  name: Arial
5
8
  size: 40
6
- color: "rgba(255,255,0)"
9
+ color: "rgba(255,255,0,0.0)"
10
+ align: center
11
+ position: "320,300,1"
7
12
  first_instruction:
8
13
  <<: *instruction
9
- text: "<- to move left |"
10
- position: "60,300,1"
14
+ text: "Hold <- to move left"
11
15
  second_instruction:
12
16
  <<: *instruction
13
- text: "| to move right ->"
14
- position: "320,300,1"
17
+ text: "Hold -> to move right"
18
+ third_instruction:
19
+ <<: *instruction
20
+ text: "Hold ^ (up arrow) to move up"
21
+ fourth_instruction:
22
+ <<: *instruction
23
+ text: "Hold V (down arrow) to move down"
24
+ fifth_instruction:
25
+ <<: *instruction
26
+ text: "Press <SPACE> to rotate yourself"
@@ -4,6 +4,7 @@ title:
4
4
  font:
5
5
  size: 40
6
6
  position: "320,100,1"
7
+ align: center
7
8
  color: rgba(255,255,255,1.0)
8
9
  menu:
9
10
  model: metro::ui::menu
@@ -103,7 +103,7 @@ class <%= model_name %> < GameModel
103
103
  def update ; end
104
104
 
105
105
  #
106
- # This is called after every {#update} and when the OS wants the window to
106
+ # This is called after every #update and when the OS wants the window to
107
107
  # repaint itself.
108
108
  #
109
109
  def draw ; end
@@ -1,6 +1,6 @@
1
1
  class <%= scene_class_name %> < GameScene
2
2
  # By default the Scene Name is based on the class name
3
- # but that can be overriden with the scene_name class method
3
+ # but that can be overridden with the scene_name class method
4
4
  # scene_name "credits"
5
5
 
6
6
  draw :title
@@ -10,13 +10,16 @@ class <%= scene_class_name %> < GameScene
10
10
  #
11
11
  # @example Explicitly drawing a text label in the scene
12
12
  #
13
- # draw :title, text: 'Title Screen',
13
+ # draw :title, model: 'metro::ui::label',
14
+ # text: 'Title Screen',
14
15
  # position: '20,20,0',
15
16
  # font: { size: 60 },
16
- # color: 'rgb(255,255,255)',
17
- # model: 'metro::ui::label'
17
+ # color: 'rgba(255,255,255,1.0)',
18
+ # align: 'center',
19
+ # vertical_align: 'center'
18
20
  #
19
- # The draw method can be simplier for models that have content defined
21
+ #
22
+ # The draw method can be simpler for models that have content defined
20
23
  # for them in the view or the models themselves define the appropriate
21
24
  # fields.
22
25
  #
@@ -31,10 +34,26 @@ class <%= scene_class_name %> < GameScene
31
34
  #
32
35
  # @example of the title being moved to a new y position and the alpha level
33
36
  #
34
- # animate :title, to: { y: 80, alpha: 50 }, interval: 120 do
37
+ # animate :title, to: { y: 80, alpha: 50 }, interval: 120.ticks do
35
38
  # puts "Done Animating!"
36
39
  # end
37
40
  #
41
+ # @example of using nested animations and after blocks to generate a fade in
42
+ # and fade out effect.
43
+ #
44
+ # after 2.seconds do
45
+ # animate :title, to: { alpha: 255 }, interval: 1.second do
46
+ # after 1.second do
47
+ # animate :title, to: { alpha: 0 }, interval: 1.second
48
+ # end
49
+ # end
50
+ # end
51
+ #
52
+ # @note the interval can be specified in game ticks ( 1.tick, 23.ticks ) or
53
+ # in seconds ( 1.second, 23.seconds ). 60 game times are roughly equivalent
54
+ # to 1 second, however you should not use Metro for monitoring a nuclear
55
+ # reactor.
56
+ #
38
57
 
39
58
  #
40
59
  # Example Event Handling Definitions
@@ -72,8 +91,8 @@ class <%= scene_class_name %> < GameScene
72
91
  # to generate the notification
73
92
  #
74
93
  # def update
75
- # if game_save.complete?
76
- # notification :save_complete
94
+ # if player.x > 600 and player.y > 440
95
+ # notification :player_wins
77
96
  # end
78
97
  # end
79
98
  #
@@ -86,34 +105,36 @@ class <%= scene_class_name %> < GameScene
86
105
  def after_initialize ; end
87
106
 
88
107
  #
89
- # This method is called right after the scene has been adopted by the window
108
+ # This method is called right after the scene has been adopted by the window.
109
+ # This is a great place to make changes to the scene before the update methods
110
+ # or draw methods have ever been called.
90
111
  #
91
112
  def show ; end
92
113
 
93
114
  #
94
- # This is called every update interval while the window is being shown.
115
+ # This is called every update interval while the scene is being shown in the
116
+ # window.
95
117
  #
96
118
  def update ; end
97
119
 
98
120
  #
99
- # This is called after every {#update} and when the OS wants the window to
121
+ # This is called after every #update and when the OS wants the window to
100
122
  # repaint itself.
101
123
  #
102
124
  def draw ; end
103
125
 
104
126
  #
105
- # Before a scene is transisitioned away from to a new scene, this method is called
106
- # to allow for the scene to complete any taskss, stop any actions, or pass any
127
+ # Before a scene is transitioned away from to a new scene, this method is called
128
+ # to allow for the scene to complete any tasks, stop any actions, or pass any
107
129
  # information from the existing scene to the scene that is about to replace it.
108
130
  #
109
131
  def prepare_transition_to(new_scene) ; end
110
132
 
111
133
  #
112
- # Before a scene is transisitioned to it is called with the previous scene. This
113
- # allows for the new scene to rerieve any data from the previous scene to assist
134
+ # Before a scene is transitioned to it is called with the previous scene. This
135
+ # allows for the new scene to retrieve any data from the previous scene to assist
114
136
  # with the layout of the current scene.
115
137
  #
116
138
  def prepare_transition_from(old_scene) ; end
117
139
 
118
-
119
140
  end
@@ -3,6 +3,8 @@
3
3
  title:
4
4
  model: "metro::ui::label"
5
5
  text: "Your Scene"
6
+ align: center
7
+ vertical_align: center
6
8
  position: "190,200,4"
7
9
  font:
8
10
  size: 60
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.6
4
+ version: 0.2.7
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-20 00:00:00.000000000 Z
12
+ date: 2012-11-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gosu
@@ -250,13 +250,10 @@ licenses: []
250
250
  post_install_message: ! " ______ ___ _____\n ___ |/ /_____ __ /_______________\n
251
251
  \ __ /|_/ / _ _ \\_ __/__ ___/_ __ \\\n _ / / / / __// /_ _ / /
252
252
  /_/ /\n /_/ /_/ \\___/ \\__/ /_/ \\____/\n\n Thank you for installing
253
- metro 0.2.6 / 2012/11-20.\n ---------------------------------------------------------------------\n
254
- \ Changes:\n \n * Menus now support vertical and horizontal layout\n * Menus
255
- now support movement and selection noises\n * Menus can now have a default selection\n
256
- \ * Menus can be enabled/disabled\n * Added Array Property, Boolean Property, and
257
- Menu Options Property\n * FIX label horizontal center and right alignments\n *
258
- Generic Models will now show a warning instead of raising an exception\n * Removed
259
- event chain debug messaging\n \n\n ---------------------------------------------------------------------\n"
253
+ metro 0.2.7 / 2012/11-20.\n ---------------------------------------------------------------------\n
254
+ \ Changes:\n \n * FIX to the new game template\n * Updated the game template
255
+ to give more movement to the hero in the first scene\n * Added the fade-in, fade-out
256
+ helper to show all the instructions\n \n\n ---------------------------------------------------------------------\n"
260
257
  rdoc_options: []
261
258
  require_paths:
262
259
  - lib