metro-ld25 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. data/.gitignore +17 -0
  2. data/.rspec +2 -0
  3. data/.rvmrc +1 -0
  4. data/.travis.yml +6 -0
  5. data/Gemfile +12 -0
  6. data/Guardfile +4 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +189 -0
  9. data/Rakefile +18 -0
  10. data/bin/metro +16 -0
  11. data/changelog.md +157 -0
  12. data/lib/assets/menu-movement.wav +0 -0
  13. data/lib/assets/menu-selection.wav +0 -0
  14. data/lib/assets/missing.ogg +0 -0
  15. data/lib/assets/missing.png +0 -0
  16. data/lib/assets/missing.wav +0 -0
  17. data/lib/assets/missing_animation.png +0 -0
  18. data/lib/commands/generate_game.rb +13 -0
  19. data/lib/commands/generate_model.rb +25 -0
  20. data/lib/commands/generate_scene.rb +36 -0
  21. data/lib/commands/generate_view.rb +21 -0
  22. data/lib/commands/thor.rb +83 -0
  23. data/lib/core_ext/class.rb +14 -0
  24. data/lib/core_ext/numeric.rb +59 -0
  25. data/lib/gosu_ext/color.rb +62 -0
  26. data/lib/gosu_ext/gosu_constants.rb +53 -0
  27. data/lib/locale/en.yml +35 -0
  28. data/lib/locale/locale.rb +1 -0
  29. data/lib/metro.rb +140 -0
  30. data/lib/metro/animation.rb +135 -0
  31. data/lib/metro/animation/after_interval_factory.rb +12 -0
  32. data/lib/metro/animation/animation_factory.rb +15 -0
  33. data/lib/metro/animation/easing/ease_in.rb +15 -0
  34. data/lib/metro/animation/easing/easing.rb +51 -0
  35. data/lib/metro/animation/easing/linear.rb +15 -0
  36. data/lib/metro/animation/has_animations.rb +70 -0
  37. data/lib/metro/animation/implicit_animation.rb +100 -0
  38. data/lib/metro/animation/on_update_operation.rb +96 -0
  39. data/lib/metro/animation/scene_animation.rb +16 -0
  40. data/lib/metro/asset_path.rb +97 -0
  41. data/lib/metro/events/control_definition.rb +11 -0
  42. data/lib/metro/events/controls.rb +42 -0
  43. data/lib/metro/events/event_data.rb +60 -0
  44. data/lib/metro/events/event_dictionary.rb +52 -0
  45. data/lib/metro/events/event_factory.rb +17 -0
  46. data/lib/metro/events/event_relay.rb +300 -0
  47. data/lib/metro/events/event_state_manager.rb +63 -0
  48. data/lib/metro/events/events.rb +3 -0
  49. data/lib/metro/events/has_events.rb +108 -0
  50. data/lib/metro/events/hit_list.rb +75 -0
  51. data/lib/metro/events/unknown_sender.rb +5 -0
  52. data/lib/metro/font.rb +69 -0
  53. data/lib/metro/game.rb +102 -0
  54. data/lib/metro/game/dsl.rb +68 -0
  55. data/lib/metro/image.rb +68 -0
  56. data/lib/metro/logging.rb +33 -0
  57. data/lib/metro/missing_scene.rb +21 -0
  58. data/lib/metro/models/audio/song.rb +33 -0
  59. data/lib/metro/models/draws.rb +86 -0
  60. data/lib/metro/models/key_value_coding.rb +38 -0
  61. data/lib/metro/models/model.rb +236 -0
  62. data/lib/metro/models/model_factory.rb +32 -0
  63. data/lib/metro/models/models.rb +62 -0
  64. data/lib/metro/models/properties/animation_property.rb +115 -0
  65. data/lib/metro/models/properties/array_property.rb +24 -0
  66. data/lib/metro/models/properties/boolean_property.rb +27 -0
  67. data/lib/metro/models/properties/color_property.rb +116 -0
  68. data/lib/metro/models/properties/dimensions_property.rb +84 -0
  69. data/lib/metro/models/properties/font_property.rb +130 -0
  70. data/lib/metro/models/properties/image_property.rb +96 -0
  71. data/lib/metro/models/properties/model_property.rb +84 -0
  72. data/lib/metro/models/properties/numeric_property.rb +29 -0
  73. data/lib/metro/models/properties/options_property/no_option.rb +29 -0
  74. data/lib/metro/models/properties/options_property/options.rb +94 -0
  75. data/lib/metro/models/properties/options_property/options_property.rb +125 -0
  76. data/lib/metro/models/properties/position_property.rb +90 -0
  77. data/lib/metro/models/properties/property.rb +221 -0
  78. data/lib/metro/models/properties/property_owner.rb +137 -0
  79. data/lib/metro/models/properties/sample_property.rb +84 -0
  80. data/lib/metro/models/properties/scale_property.rb +80 -0
  81. data/lib/metro/models/properties/song_property.rb +89 -0
  82. data/lib/metro/models/properties/text_property.rb +75 -0
  83. data/lib/metro/models/ui/animated_sprite.rb +85 -0
  84. data/lib/metro/models/ui/border.rb +95 -0
  85. data/lib/metro/models/ui/fps.rb +54 -0
  86. data/lib/metro/models/ui/generic.rb +66 -0
  87. data/lib/metro/models/ui/grid_drawer.rb +74 -0
  88. data/lib/metro/models/ui/image.rb +87 -0
  89. data/lib/metro/models/ui/label.rb +175 -0
  90. data/lib/metro/models/ui/menu.rb +214 -0
  91. data/lib/metro/models/ui/model_label.rb +65 -0
  92. data/lib/metro/models/ui/model_labeler.rb +79 -0
  93. data/lib/metro/models/ui/rectangle.rb +59 -0
  94. data/lib/metro/models/ui/sprite.rb +79 -0
  95. data/lib/metro/models/ui/tile_map.rb +162 -0
  96. data/lib/metro/models/ui/ui.rb +13 -0
  97. data/lib/metro/parameters/command_line_args_parser.rb +68 -0
  98. data/lib/metro/parameters/options.rb +25 -0
  99. data/lib/metro/parameters/parameters.rb +2 -0
  100. data/lib/metro/sample.rb +40 -0
  101. data/lib/metro/scene.rb +477 -0
  102. data/lib/metro/scenes.rb +154 -0
  103. data/lib/metro/song.rb +56 -0
  104. data/lib/metro/template_message.rb +60 -0
  105. data/lib/metro/transitions/edit_transition_scene.rb +100 -0
  106. data/lib/metro/transitions/fade_transition_scene.rb +66 -0
  107. data/lib/metro/transitions/scene_transitions.rb +44 -0
  108. data/lib/metro/transitions/transition_scene.rb +19 -0
  109. data/lib/metro/units/bounds.rb +8 -0
  110. data/lib/metro/units/calculation_validations.rb +74 -0
  111. data/lib/metro/units/dimensions.rb +60 -0
  112. data/lib/metro/units/point.rb +51 -0
  113. data/lib/metro/units/rectangle_bounds.rb +85 -0
  114. data/lib/metro/units/scale.rb +46 -0
  115. data/lib/metro/units/units.rb +6 -0
  116. data/lib/metro/version.rb +32 -0
  117. data/lib/metro/views/json_view.rb +60 -0
  118. data/lib/metro/views/no_view.rb +34 -0
  119. data/lib/metro/views/parsers.rb +42 -0
  120. data/lib/metro/views/scene_view.rb +107 -0
  121. data/lib/metro/views/view.rb +133 -0
  122. data/lib/metro/views/writers.rb +43 -0
  123. data/lib/metro/views/yaml_view.rb +94 -0
  124. data/lib/metro/window.rb +94 -0
  125. data/lib/setup_handlers/exit_if_dry_run.rb +26 -0
  126. data/lib/setup_handlers/game_execution.rb +65 -0
  127. data/lib/setup_handlers/load_game_configuration.rb +65 -0
  128. data/lib/setup_handlers/load_game_files.rb +101 -0
  129. data/lib/setup_handlers/move_to_game_directory.rb +25 -0
  130. data/lib/setup_handlers/reload_game_on_game_file_changes.rb +79 -0
  131. data/lib/templates/game/README.md.tt +52 -0
  132. data/lib/templates/game/assets/brand.jpg +0 -0
  133. data/lib/templates/game/assets/hero.png +0 -0
  134. data/lib/templates/game/lib/custom_easing.rb +32 -0
  135. data/lib/templates/game/metro.tt +63 -0
  136. data/lib/templates/game/models/hero.rb +62 -0
  137. data/lib/templates/game/scenes/brand_scene.rb +19 -0
  138. data/lib/templates/game/scenes/brand_to_title_scene.rb +13 -0
  139. data/lib/templates/game/scenes/first_scene.rb +28 -0
  140. data/lib/templates/game/scenes/game_scene.rb +43 -0
  141. data/lib/templates/game/scenes/title_scene.rb +15 -0
  142. data/lib/templates/game/views/brand.yaml +4 -0
  143. data/lib/templates/game/views/brand_to_title.yaml +8 -0
  144. data/lib/templates/game/views/first.yaml +26 -0
  145. data/lib/templates/game/views/title.yaml +11 -0
  146. data/lib/templates/message.erb +23 -0
  147. data/lib/templates/model.rb.tt +111 -0
  148. data/lib/templates/scene.rb.tt +140 -0
  149. data/lib/templates/view.yaml.tt +11 -0
  150. data/lib/tmxed_ext/tile_set.rb +34 -0
  151. data/metro.gemspec +56 -0
  152. data/spec/core_ext/numeric_spec.rb +78 -0
  153. data/spec/core_ext/string_spec.rb +33 -0
  154. data/spec/gosu_ext/color_spec.rb +80 -0
  155. data/spec/metro/events/event_state_manager_spec.rb +5 -0
  156. data/spec/metro/models/key_value_coding_spec.rb +61 -0
  157. data/spec/metro/models/properties/array_property_spec.rb +60 -0
  158. data/spec/metro/models/properties/color_property_spec.rb +85 -0
  159. data/spec/metro/models/properties/dimensions_spec.rb +29 -0
  160. data/spec/metro/models/properties/font_property_spec.rb +127 -0
  161. data/spec/metro/models/properties/numeric_property_spec.rb +46 -0
  162. data/spec/metro/models/properties/options_property/no_option_spec.rb +25 -0
  163. data/spec/metro/models/properties/options_property/options_property_spec.rb +133 -0
  164. data/spec/metro/models/properties/options_property/options_spec.rb +125 -0
  165. data/spec/metro/models/properties/position_property_spec.rb +90 -0
  166. data/spec/metro/models/ui/label_spec.rb +259 -0
  167. data/spec/metro/parameters/command_line_args_parser_spec.rb +42 -0
  168. data/spec/metro/scene_spec.rb +15 -0
  169. data/spec/metro/scene_views/json_view_spec.rb +27 -0
  170. data/spec/metro/scene_views/yaml_view_spec.rb +38 -0
  171. data/spec/metro/scenes_spec.rb +77 -0
  172. data/spec/metro/units/point_spec.rb +132 -0
  173. data/spec/metro/views/view_spec.rb +53 -0
  174. data/spec/setup_handlers/exit_if_dry_run_spec.rb +27 -0
  175. data/spec/setup_handlers/reload_game_on_game_file_changes_spec.rb +68 -0
  176. data/spec/spec_helper.rb +20 -0
  177. metadata +374 -0
@@ -0,0 +1,52 @@
1
+ # <%= name %>
2
+
3
+ ## Details
4
+
5
+ Additional information or backstory about the game that you
6
+ are creating. This file's intention is to allow a user to
7
+ refer to this for more information related to the game or
8
+ possibly any notes or caveats about the game.
9
+
10
+ ## Contact
11
+
12
+
13
+ ### Programming
14
+
15
+ * [YAML for Ruby](http://www.yaml.org/YAML_for_ruby.html) reference which can help you define views in the game.
16
+ * [JSONLint](http://jsonlint.com/) is a JSON Validator
17
+
18
+ ### Art
19
+
20
+ * [Lost Garden](http://www.lostgarden.com/2007/05/dancs-miraculously-flexible-game.html)
21
+ * [Text to ASCII Art Generator](http://patorjk.com/software/taag)
22
+ * [Icons](http://css-tricks.com/flat-icons-icon-fonts/)
23
+ * [Subtle Patterns](http://subtlepatterns.com/) various backgrounds and textures.
24
+
25
+ ### Drawing
26
+
27
+ * [Tiled Map Editor](http://www.mapeditor.org/) generates tile maps.
28
+ * [Pixen](http://pixenapp.com/) generates sprites and animations.
29
+ * [Zwoptex](http://www.zwopple.com/zwoptex/) generates sprite sheets.
30
+
31
+ ### Animation
32
+
33
+ * [TimelieFX](http://www.rigzsoft.co.uk/) particle editor allows you to export animations.
34
+
35
+ ### Sound
36
+
37
+ * [as3sfxr](http://www.superflashbros.net/as3sfxr/) generates unique sounds.
38
+ * [bfxr](http://www.bfxr.net/) generates unique sounds.
39
+ * [Audacity](http://audacity.sourceforge.net/) for recording and editing.
40
+ * [Ableton](https://www.ableton.com/en/) music generation tool.
41
+
42
+ ### Books
43
+
44
+ * [Rules of Play](http://www.amazon.com/dp/0262240459)
45
+ * [Game Programming Gems 8](http://www.amazon.com/dp/1584507020)
46
+ * [Game Feel](http://www.amazon.com/dp/0123743281)
47
+ * [Game Coding Complete](http://www.amazon.com/dp/1584506806)
48
+ * [Game Design Workshop](http://www.amazon.com/dp/0240809742)
49
+ * [Challenges For Game Designers](http://www.amazon.com/dp/158450580X)
50
+ * [The Art of Game Design: A book of lenses](http://www.amazon.com/dp/0123694965)
51
+ * [A Theory of Fun](http://www.theoryoffun.com)
52
+ * [Andrew Rollings and Ernest Adams on Game Design](http://www.amazon.com/dp/1592730019)
@@ -0,0 +1,32 @@
1
+ #
2
+ # The lib folder is a great place for you to define:
3
+ #
4
+ # * New Units
5
+ # * Monkey Patches for Metro
6
+ # * New model properties
7
+ # * Custom Easings
8
+ # * Custom View Parers/Writers
9
+ # * Anything that isn't quite a model, scene, or view
10
+ #
11
+
12
+ #
13
+ # This custom easing is an exact copy of the 'Ease In' easing defined in Metro.
14
+ # It is present here as an example.
15
+ #
16
+ class CustomEasing < Metro::Easing
17
+
18
+ #
19
+ # @param [Float] moment the point in time within the interval. For example for
20
+ # a 60 tick interval, this would be the values 0, 1, 2, 3, 4, 5, 6, ... 59.
21
+ # @param [Float] start the starting value of the property
22
+ # @param [Float] change the final value for the property
23
+ # @param [Float] interval the total length of the interval
24
+ #
25
+ # @return [Float] the value at the particular moment of the interval
26
+ def self.calculation(moment,start,change,interval)
27
+ # @note this is the exact same as the already defined Ease In
28
+ change * (moment = moment / interval) * moment + start
29
+ end
30
+ end
31
+
32
+ Metro::Easing.register :custom, CustomEasing
@@ -0,0 +1,63 @@
1
+ #
2
+ # This is the main game file which contains information
3
+ # about your game.
4
+ #
5
+ # Remember, this is really a ruby file, so anything
6
+ # that can be done with Ruby can be written here.
7
+ #
8
+ # "With great power comes great responsibility" ~ Uncle Ben
9
+
10
+ #
11
+ # This is the name of your game...
12
+ name "<%= name %>"
13
+
14
+ #
15
+ # The author of the game. This method can be executed
16
+ # twice if more people are working on this game.
17
+ #
18
+ author "Your Name"
19
+
20
+ #
21
+ # The website where the person playing this game
22
+ # could learn more about this game, other games, the
23
+ # authors, or perhaps ask for help or support.
24
+ #
25
+ website "www.idsoftware.com"
26
+
27
+ #
28
+ # The contact email address where a person that is
29
+ # playing the game might want to contact to thank
30
+ # or reach out for help.
31
+ #
32
+ contact "person@personemail.com"
33
+
34
+ #
35
+ # This sets the resolution for the game
36
+ #
37
+ resolution 640, 480
38
+
39
+ #
40
+ # The scene that will be shown first when the game
41
+ # starts.
42
+ #
43
+ first_scene :brand
44
+
45
+ #
46
+ # Defines controls which are meta events. They can be used group button
47
+ # events together under a single name so that you can use it throughout
48
+ # the game and also will allow for players of your game to redefine the
49
+ # keys.
50
+ #
51
+ controls do
52
+ # NAME_OF_EVENT, is: EVENT TYPE, with: [ ALL_EVENTS ]
53
+ confirmation is: :button_up, with: [ KbReturn, KbEnter, KbSpace, GpButton0 ]
54
+ cancel is: :button_up, with: [ KbEscape, KbDelete ]
55
+ end
56
+
57
+ #
58
+ # Enable debug mode for the game. Which could
59
+ # allow different logic. When this is set the
60
+ # Game.debug? method will return a true
61
+ # value.
62
+ #
63
+ debug true
@@ -0,0 +1,62 @@
1
+ class Hero < Metro::UI::Sprite
2
+
3
+ # A Metro::UI::Sprite predefines a number of commmon properties:
4
+ #
5
+ # * position
6
+ # * dimensions
7
+ # * color
8
+ # * angle
9
+ # * scale
10
+ #
11
+ # These properties add getter and setter methods of the following:
12
+ #
13
+ # * position, x, y, z and z_order (both z and z_order are the same)
14
+ # * dimensions, width, and height
15
+ # * color, red, green, blue, alpha
16
+ # * angle
17
+ # * scale, x_factor, y_factor
18
+
19
+ property :image, path: "hero.png"
20
+
21
+ property :move_amount, default: 1.5
22
+ property :turn_amount, default: 90.0
23
+
24
+ event :on_hold, KbLeft, GpLeft do
25
+ self.x -= move_amount
26
+ end
27
+
28
+ event :on_hold, KbRight, GpRight do
29
+ self.x += move_amount
30
+ end
31
+
32
+ event :on_hold, KbUp, GpUp do
33
+ self.y -= move_amount
34
+ end
35
+
36
+ event :on_hold, KbDown, GpDown do
37
+ self.y += move_amount
38
+ end
39
+
40
+ event :on_up, KbSpace do
41
+ self.angle += turn_amount
42
+ end
43
+
44
+ # By default a Metro::UI::Sprite defines a #draw method which will
45
+ # draw the associated image with the position, rotation, and scale.
46
+ #
47
+ # If you would like to maintain the current draw functionality but augment
48
+ # it, you can define a draw method which calls to super.
49
+ #
50
+ # def draw
51
+ # super
52
+ # # custom drawing alongside the image
53
+ # end
54
+ #
55
+ # You may find it necessary to replace the existing draw functionality.
56
+ # Here you could define your own draw that overrides the original.
57
+ #
58
+ # def draw
59
+ # # custom drawing without the original image draw
60
+ # end
61
+
62
+ end
@@ -0,0 +1,19 @@
1
+ class BrandScene < GameScene
2
+
3
+ draws :brand
4
+
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
12
+
13
+ def transition_to_brand_to_title
14
+ animate :brand, to: { alpha: 0 }, interval: 1.second do
15
+ transition_to :brand_to_title
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,13 @@
1
+ class BrandToTitleScene < GameScene
2
+
3
+ draws :title
4
+
5
+ animate :title, to: { alpha: 255 }, interval: 2.seconds do
6
+ transition_to :title
7
+ end
8
+
9
+ event :cancel do
10
+ transition_to :title
11
+ end
12
+
13
+ end
@@ -0,0 +1,28 @@
1
+ class FirstScene < GameScene
2
+
3
+ if Game.debug?
4
+ draw :fps, model: "metro::ui::fps", placement: 'bottom_right'
5
+ end
6
+
7
+ draw :hero, position: Game.center
8
+
9
+ draws :first_instruction, :second_instruction, :third_instruction,
10
+ :fourth_instruction, :fifth_instruction
11
+
12
+ after 1.second do
13
+ fade_in_and_out :first_instruction do
14
+ fade_in_and_out :second_instruction do
15
+ fade_in_and_out :third_instruction do
16
+ fade_in_and_out :fourth_instruction do
17
+ fade_in_and_out :fifth_instruction
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ def update
25
+ hero.position = Point.new (hero.x % Game.width), (hero.y % Game.height)
26
+ end
27
+
28
+ end
@@ -0,0 +1,43 @@
1
+ class GameScene < Metro::Scene
2
+
3
+ #
4
+ # The game scene is a place where you can define actors and
5
+ # events here that will be present within all the subclassed
6
+ # scenes.
7
+
8
+ #
9
+ # @example Setting up the ability for all subclassed scenes
10
+ # to be reloaded with the 'Ctrl+R' event
11
+ #
12
+ event :on_up, KbR do |event|
13
+ if event.control?
14
+ if Metro.game_has_valid_code?
15
+ after(1.tick) { Metro.reload! ; transition_to(scene_name) }
16
+ end
17
+ end
18
+ end
19
+
20
+ #
21
+ # @example Setting up the ability for all subclassed scenes
22
+ # to be edited with the 'Ctrl+E' event
23
+ #
24
+ event :on_up, KbE do |event|
25
+ if event.control?
26
+ transition_to scene_name, with: :edit
27
+ end
28
+ end
29
+
30
+ #
31
+ # This animation helper will fade in and fade out information.
32
+ #
33
+ def fade_in_and_out(name)
34
+ animate name, to: { alpha: 255 }, interval: 2.seconds do
35
+ after 1.second do
36
+ animate name, to: { alpha: 0 }, interval: 1.second do
37
+ yield if block_given?
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,15 @@
1
+ class TitleScene < GameScene
2
+
3
+ draw :title
4
+
5
+ draw :menu, options: [ 'Start Game', 'Exit' ]
6
+
7
+ event :on_up, KbEscape do
8
+ exit
9
+ end
10
+
11
+ def start_game
12
+ transition_to :first
13
+ end
14
+
15
+ end
@@ -0,0 +1,4 @@
1
+ brand:
2
+ model: metro::ui::image
3
+ image: brand.jpg
4
+ position: "320,240,1"
@@ -0,0 +1,8 @@
1
+ title:
2
+ model: metro::ui::label
3
+ text: "#{Game.name}"
4
+ font:
5
+ size: 40
6
+ position: "320,100,1"
7
+ align: center
8
+ color: rgba(255,255,255,0.0)
@@ -0,0 +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
+ ---
4
+ instruction: &instruction
5
+ model: metro::ui::label
6
+ font:
7
+ name: Arial
8
+ size: 40
9
+ color: "rgba(255,255,0,0.0)"
10
+ align: center
11
+ position: "320,300,1"
12
+ first_instruction:
13
+ <<: *instruction
14
+ text: "Hold <- to move left"
15
+ second_instruction:
16
+ <<: *instruction
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"
@@ -0,0 +1,11 @@
1
+ title:
2
+ model: metro::ui::label
3
+ text: "#{Game.name}"
4
+ font:
5
+ size: 40
6
+ position: "320,100,1"
7
+ align: center
8
+ color: rgba(255,255,255,1.0)
9
+ menu:
10
+ model: metro::ui::menu
11
+ position: "260,200,1"
@@ -0,0 +1,23 @@
1
+ ********************************************************************************
2
+ ______ ___ _____
3
+ ___ |/ /_____ __ /_______________
4
+ __ /|_/ / _ _ \_ __/__ ___/_ __ \
5
+ _ / / / / __// /_ _ / / /_/ /
6
+ /_/ /_/ \___/ \__/ /_/ \____/
7
+
8
+ --------------------------------------------------------------------------------
9
+ <% messages.each do |message| %>
10
+ ## <%= message.title %>
11
+
12
+ <%= message.message %>
13
+
14
+ <% unless message.actions.empty? %>## Details
15
+
16
+ <%= message.actions %><% end %><% end %>
17
+ <% if website.present? || email.present? %>
18
+ ## Contact
19
+
20
+ <%= website %>
21
+ <%= email %>
22
+ <% end %>
23
+ ********************************************************************************
@@ -0,0 +1,111 @@
1
+ class <%= model_name %> < GameModel
2
+
3
+ #
4
+ # Properties
5
+ #
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.
11
+ #
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::SongProperty
38
+ # @see Metro::Model::SampleProperty
39
+ # @see Metro::Model::NumericProperty
40
+ # @see Metro::Model::ScaleProperty
41
+ # @see Metro::Model::TextProperty
42
+ # @see Metro::Model::PositionProperty
43
+ # @see Metro::Model::FontProperty
44
+ #
45
+
46
+ #
47
+ # Events
48
+ #
49
+ # # @example Registering the keyboard down event to execute a block of code
50
+ # event :on_down, GpLeft, GpUp, do
51
+ # turn_left
52
+ # end
53
+ #
54
+ # # @example Registering the keyboard up key to execute the method `jump`
55
+ # event :on_up, KbEscape, do: :jump
56
+ #
57
+ # # @example Registering for button held events that would build the model's acceleration
58
+ # event :on_hold, KbRight, GpRight do
59
+ # acceleration += 1
60
+ # end
61
+ #
62
+ # Keystroke and Game Event Reference
63
+ #
64
+ # @see https://github.com/jlnr/gosu/blob/master/Gosu/ButtonsMac.hpp
65
+ # @see https://github.com/jlnr/gosu/blob/master/Gosu/ButtonsX.hpp
66
+ # @see https://github.com/jlnr/gosu/blob/master/Gosu/ButtonsWin.hpp
67
+ #
68
+ #
69
+ # # @example Registering for an event called 'save_complete' event that anyone
70
+ # # can generate and this scene block will execute this code.
71
+ #
72
+ # event :notification, :game_over do
73
+ # puts "Game is Over!"
74
+ # end
75
+ #
76
+ # Within the models you could use the method `notification`
77
+ # to generate the notification
78
+ #
79
+ # def update_score
80
+ # @score = score + 1
81
+ # if score >= winning_score
82
+ # notification :game_over
83
+ # end
84
+ # end
85
+ #
86
+
87
+ #
88
+ # As model does a lot of work for you with regarding to setting up content, it is
89
+ # best not to override #initialize and instead define an #after_initialize method
90
+ # within the subclasses of Scene.
91
+ #
92
+ def after_initialize ; end
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
+
105
+ #
106
+ # This is called after every #update and when the OS wants the window to
107
+ # repaint itself.
108
+ #
109
+ def draw ; end
110
+
111
+ end