ippa-movie_maker 0.3.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.
Files changed (63) hide show
  1. data/History.txt +27 -0
  2. data/README.rdoc +154 -0
  3. data/Rakefile +19 -0
  4. data/examples/axe.rb +24 -0
  5. data/examples/balls.rb +20 -0
  6. data/examples/echoes.rb +30 -0
  7. data/examples/gosu_base.rb +40 -0
  8. data/examples/gosu_rain.rb +34 -0
  9. data/examples/gosu_river_of_stars.rb +35 -0
  10. data/examples/gosu_triangles.rb +34 -0
  11. data/examples/gosu_wish_upon_a_star.rb +48 -0
  12. data/examples/ippagaming_intro.rb +23 -0
  13. data/examples/media/23700__hazure__chop.wav +0 -0
  14. data/examples/media/Establo.ttf +0 -0
  15. data/examples/media/FeaturedItem.ttf +0 -0
  16. data/examples/media/FreeSans.ttf +0 -0
  17. data/examples/media/Hursheys.ttf +0 -0
  18. data/examples/media/axe.png +0 -0
  19. data/examples/media/axe.svg +136 -0
  20. data/examples/media/ball.png +0 -0
  21. data/examples/media/ball.svg +182 -0
  22. data/examples/media/black.bmp +0 -0
  23. data/examples/media/blue_triangle.png +0 -0
  24. data/examples/media/blue_triangle.svg +81 -0
  25. data/examples/media/chop.wav +0 -0
  26. data/examples/media/cloth_background.png +0 -0
  27. data/examples/media/drawing.svg +86 -0
  28. data/examples/media/drip.wav +0 -0
  29. data/examples/media/green_triangle.png +0 -0
  30. data/examples/media/green_triangle.svg +104 -0
  31. data/examples/media/hit.wav +0 -0
  32. data/examples/media/ippa_gaming.png +0 -0
  33. data/examples/media/ippa_gaming.svg +463 -0
  34. data/examples/media/oil_drip.wav +0 -0
  35. data/examples/media/outdoor_scene.bmp +0 -0
  36. data/examples/media/outdoor_scene.png +0 -0
  37. data/examples/media/outdoor_scene.svg +316 -0
  38. data/examples/media/rain-bak1.wav +0 -0
  39. data/examples/media/rain.wav +0 -0
  40. data/examples/media/rain2.wav +0 -0
  41. data/examples/media/raindrop.png +0 -0
  42. data/examples/media/raindrop.svg +87 -0
  43. data/examples/media/raindrop_small.bmp +0 -0
  44. data/examples/media/raindrop_small.png +0 -0
  45. data/examples/media/red_triangle.png +0 -0
  46. data/examples/media/red_triangle.svg +81 -0
  47. data/examples/media/spaceship_noalpha.png +0 -0
  48. data/examples/media/star_5.png +0 -0
  49. data/examples/media/star_5.svg +83 -0
  50. data/examples/media/star_6.png +0 -0
  51. data/examples/media/star_6.svg +86 -0
  52. data/examples/rain.rb +26 -0
  53. data/examples/rain_advanced.rb +26 -0
  54. data/examples/rubygame_river_of_stars.rb +28 -0
  55. data/examples/zoom.rb +27 -0
  56. data/lib/movie_maker.rb +411 -0
  57. data/lib/movie_maker/action.rb +389 -0
  58. data/lib/movie_maker/core_extensions.rb +17 -0
  59. data/lib/movie_maker/gosu_autoload.rb +38 -0
  60. data/lib/movie_maker/gosu_clock.rb +139 -0
  61. data/lib/movie_maker/named_resource.rb +254 -0
  62. data/lib/movie_maker/sprite.rb +157 -0
  63. metadata +126 -0
@@ -0,0 +1,254 @@
1
+ #--
2
+ # Rubygame -- Ruby code and bindings to SDL to facilitate game creation
3
+ # Copyright (C) 2004-2008 John Croisant
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ #++
19
+
20
+
21
+ module Rubygame
22
+
23
+ # NamedResource is a mix-in module to implement a globally-available
24
+ # resource table, a @name variable and accessors, and a system for
25
+ # automatically loading resources when they are first needed.
26
+ #
27
+ # This module is used for Rubygame::Music, Rubygame::Sound, and
28
+ # Rubygame::Surface. You can use it in your own classes this way:
29
+ #
30
+ # 1. Do 'include Rubygame::NamedResource' in your class definition.
31
+ #
32
+ # 2. Set MyClass.autoload_dirs to an Array of directories to look
33
+ # for files when autoloading. Tip: use File.join to create
34
+ # paths that work on any operating system.
35
+ #
36
+ # 3. Define #autoload to implement the behavior for your class,
37
+ # or leave it as the default if you don't need autoloading.
38
+ # See the docs for #autoload for more information.
39
+ #
40
+ # Here's an example of how you could use this for a class which
41
+ # loads maps from a file:
42
+ #
43
+ # class Map
44
+ # include Rubygame::NamedResource
45
+ #
46
+ # Map.autoload_dirs = [ File.join("maps","world_1"),
47
+ # File.join("maps","custom") ]
48
+ #
49
+ # def autoload( name )
50
+ # # Searches autoload_dirs for the file
51
+ # path = find_file( name )
52
+ #
53
+ # if( path )
54
+ # return load_map( path )
55
+ # else
56
+ # return nil
57
+ # end
58
+ # end
59
+ #
60
+ # def load_map( path )
61
+ # # Your code to do the real loading, then return
62
+ # # the created instance of Map class.
63
+ # # ...
64
+ # return map_instance
65
+ # end
66
+ # end
67
+ #
68
+ # Here's an example of how you could then use the Map class:
69
+ #
70
+ # map = Map["level_1.map"]
71
+ #
72
+ # if( map )
73
+ # start_playing( map )
74
+ # else
75
+ # raise "Oops! The map file for Level 1 doesn't exist!"
76
+ # end
77
+ #
78
+ module NamedResource
79
+
80
+
81
+ # Adds class methods when the NamedResource module is included
82
+ # in a class. (Here, we are assuming that the NamedResource
83
+ # module was included in a class called MyClass.)
84
+ module NamedResourceClassMethods
85
+
86
+ # An Array of paths to check for files. See #find_file.
87
+ attr_accessor :autoload_dirs
88
+
89
+
90
+ # call-seq:
91
+ # MyClass[ name ] -> instance or nil
92
+ #
93
+ # Retrieves an instance of the class from a per-class resource
94
+ # table (Hash).
95
+ #
96
+ # If no object has been saved under the given name, invoke
97
+ # #autoload to try to load a new instance, store it in the
98
+ # Hash table under this name, and sets the instance's @name
99
+ # to this name.
100
+ #
101
+ def []( name )
102
+ result = @resources[name]
103
+
104
+ if result.nil?
105
+ result = autoload(name)
106
+ if result
107
+ self[name] = result
108
+ result.name = name
109
+ end
110
+ end
111
+
112
+ return result
113
+ end
114
+
115
+
116
+ # call-seq:
117
+ # MyClass[ name ] = instance
118
+ #
119
+ # Stores an instance of the class in a per-class resource table
120
+ # (Hash) for future access. If another object is already stored
121
+ # with this name, the old record is lost.
122
+ #
123
+ # May raise: TypeError, if you try to store anything
124
+ # that is not kind of this class.
125
+ #
126
+ def []=( name, value )
127
+ ##if( value.kind_of? self )
128
+ @resources[name] = value
129
+ ##else
130
+ ## raise TypeError, "#{self}#[]= can only store instances of #{self}"
131
+ ##end
132
+ end
133
+
134
+ # call-seq:
135
+ # MyClass.autoload( name ) -> instance or nil
136
+ #
137
+ # This method is invoked when a non-existing resource is
138
+ # accessed with #[]. By default, this method simply returns
139
+ # nil, effectively disabling autoloading.
140
+ #
141
+ # You should override this method in your class to provide
142
+ # class-specific loading behavior, or leave it as the default if
143
+ # you don't need autoloading. Your method should return either
144
+ # an instance of the class, or nil.
145
+ #
146
+ # NOTE: The #find_file method is useful for getting the full
147
+ # path to a file which matches the name. That's what it's there
148
+ # for, so you should use it!
149
+ #
150
+ def autoload( name )
151
+ nil
152
+ end
153
+
154
+
155
+ # call-seq:
156
+ # MyClass.basename( path ) -> filename
157
+ #
158
+ # Returns the basename for the path (i.e. the
159
+ # filename without the directory). Same as
160
+ # File.basename
161
+ #
162
+ def basename( path )
163
+ File.basename( path )
164
+ end
165
+
166
+
167
+ # call-seq:
168
+ # MyClass.exist?( path ) -> true or false
169
+ #
170
+ # True if the given path points to a file
171
+ # that exists, otherwise false. Same as
172
+ # File.exist?
173
+ #
174
+ def exist?( path )
175
+ File.exist?(path)
176
+ end
177
+
178
+
179
+ # call-seq:
180
+ # MyClass.find_file( filename ) -> path or nil
181
+ #
182
+ # Checks every directory in @autoload_dirs for
183
+ # a file with the given name, and returns the
184
+ # path (directory and name) for the first match.
185
+ #
186
+ # If no directories have a file with that name,
187
+ # return nil.
188
+ #
189
+ def find_file( filename )
190
+ dir = @autoload_dirs.find { |dir|
191
+ exist?( File.join(dir,filename) )
192
+ }
193
+
194
+ if dir
195
+ return File.join(dir,filename)
196
+ else
197
+ return nil
198
+ end
199
+ end
200
+
201
+ end
202
+
203
+
204
+ # Sets up the class when this module is included.
205
+ # Adds the class methods and defines class instance
206
+ # variables.
207
+ def self.included( object ) # :nodoc:
208
+
209
+ class << object
210
+ include NamedResourceClassMethods
211
+ end
212
+
213
+ object.instance_eval do
214
+ @resources = Hash.new
215
+ @autoload_dirs = []
216
+ end
217
+
218
+ end
219
+
220
+
221
+ # Returns the instance's @name. See also #name=.
222
+ def name
223
+ @name
224
+ end
225
+
226
+ #
227
+ # Sets the instance's @name to the given String, or nil to
228
+ # unset the name. See also #name.
229
+ #
230
+ # NOTE: This does not automatically store the instance in the
231
+ # class resource table by name. Use the #[]= class method to do
232
+ # that.
233
+ #
234
+ # The string is dup'ed and frozen before being stored.
235
+ #
236
+ # May raise: TypeError, if new_name is not a String or nil.
237
+ #
238
+ def name=( new_name )
239
+ if new_name.nil?
240
+ return @name = nil
241
+ end
242
+
243
+ unless new_name.kind_of? String
244
+ raise TypeError, "name must be a String (got #{new_name.class})"
245
+ end
246
+
247
+ @name = new_name.dup
248
+ @name.freeze
249
+ end
250
+
251
+
252
+ end
253
+
254
+ end
@@ -0,0 +1,157 @@
1
+ module MovieMaker
2
+ module Rubygame
3
+
4
+ #
5
+ # A basic spriteclass using rubygames Sprites::Sprite
6
+ # Autoloads a surface and initializes @rect
7
+ #
8
+ class Sprite
9
+ include ::Rubygame::Sprites::Sprite
10
+
11
+ attr_reader :image, :file
12
+ attr_accessor :rect, :angle, :width_scaling, :height_scaling
13
+ def initialize(file, x=0, y=0)
14
+ super()
15
+ @file = file
16
+ @image = Surface.autoload(file)
17
+ @rect = Rect.new(x,y,*@image.size)
18
+ @image.set_colorkey(@image.get_at(0,0))
19
+ @angle = 0.0
20
+ @width_scaling = 1.0
21
+ @height_scaling = 1.0
22
+ end
23
+
24
+ #
25
+ # Rubygame X/Y setters/getters
26
+ #
27
+ def x=(value); @rect.centerx = value; end
28
+ def x; @rect.centerx; end
29
+ def y=(value); @rect.centery = value; end
30
+ def y; @rect.centery; end
31
+
32
+ def realign_center
33
+ old_center = @rect.center
34
+ @rect.size = @image.size
35
+ @rect.center = old_center
36
+ end
37
+
38
+ end
39
+
40
+ #
41
+ # TTRSprite creates a rubygame sprite from a string/font
42
+ # Use this if you wanna move,rotate and zoom texts/letters
43
+ #
44
+ class TTFSprite
45
+ include ::Rubygame::Sprites::Sprite
46
+
47
+ attr_reader :image
48
+ attr_accessor :rect, :angle, :width_scaling, :height_scaling
49
+ def initialize(string, options={})
50
+ super()
51
+ @string = string
52
+ @color = options[:color] || Color[:black]
53
+ @size = options[:size] || 15
54
+ @position = options[:position] || [0,0]
55
+ @fontname = options[:fontname] || "FreeSans.ttf"
56
+ @font = options[:font] || nil
57
+
58
+ if @font.nil?
59
+ @font = TTF.new(File.join("fonts", @fontname), @size)
60
+ end
61
+
62
+ @rect = Rect.new(@position[0], @position[1], *@font.size_text(string))
63
+ @image = Surface.new(@rect.size, 0, [SRCCOLORKEY])
64
+ @font.render(@string, true, @color).blit(@image,[0,0])
65
+ @image.set_colorkey(@image.get_at(0,0))
66
+
67
+ @angle = 0.0
68
+ @width_scaling = 1.0
69
+ @height_scaling = 1.0
70
+ end
71
+
72
+ #
73
+ # Rubygame X/Y setters/getters
74
+ #
75
+ def x=(value); @rect.centerx = value; end
76
+ def x; @rect.centerx; end
77
+ def y=(value); @rect.centery = value; end
78
+ def y; @rect.centery; end
79
+
80
+ def realign_center
81
+ old_center = @rect.center
82
+ @rect.size = @image.size
83
+ @rect.center = old_center
84
+ end
85
+
86
+ end
87
+ end
88
+
89
+ module Gosu
90
+
91
+ #
92
+ # A basic spriteclass using rubygames Sprites::Sprite
93
+ # Autoloads a surface and initializes @rect
94
+ #
95
+ class Sprite
96
+ attr_reader :image, :file
97
+ attr_accessor :x, :y, :angle, :width_scaling, :height_scaling, :color, :draw_mode
98
+ def initialize(file, options = {})
99
+ @x = options[:x] || 0
100
+ @y = options[:y] || 0
101
+ @draw_mode = options[:draw_mode] || :additive
102
+
103
+ @file = file
104
+ @image = Surface.autoload(@file)
105
+ @angle = 0.0
106
+ @width_scaling = 1.0
107
+ @height_scaling = 1.0
108
+ @color = ::Gosu::Color.new(0xffffffff)
109
+ end
110
+
111
+ # Only relevant with rubygame
112
+ def realign_center
113
+ nil
114
+ end
115
+
116
+ end
117
+
118
+ #
119
+ # Use this if you wanna move,rotate and zoom texts/letters
120
+ #
121
+ class TTFSprite
122
+ attr_reader :image
123
+ attr_accessor :x, :y, :angle, :width_scaling, :height_scaling, :color, :draw_mode
124
+ def initialize(string, options={})
125
+ @string = string
126
+ @color = options[:color] || Color[:black]
127
+ @size = options[:size] || 15
128
+ @position = options[:position] || [0,0]
129
+ @fontname = options[:fontname] || "FreeSans.ttf"
130
+ @font = options[:font] || nil
131
+
132
+ @x = options[:x] || @position[0]
133
+ @y = options[:y] || @position[1]
134
+ @draw_mode = options[:draw_mode] || :additive
135
+
136
+ if @font.nil?
137
+ @font = TTF.new(File.join("fonts", @fontname), @size)
138
+ end
139
+
140
+ @angle = 0.0
141
+ @width_scaling = 1.0
142
+ @height_scaling = 1.0
143
+ @color = ::Gosu::Color.new(0xffffffff)
144
+ #@rect = Rect.new(@position[0], @position[1], *@font.size_text(string))
145
+ #@image = Surface.new(@rect.size, 0, [SRCCOLORKEY])
146
+ #@font.render(@string, true, @color).blit(@image,[0,0])
147
+ end
148
+
149
+ # Only relevant with rubygame
150
+ def realign_center
151
+ nil
152
+ end
153
+
154
+ end
155
+ end
156
+
157
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ippa-movie_maker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - ippa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-17 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.3.3
24
+ version:
25
+ description: Automate image movements/effects and sounds over a period of time, useful for games.
26
+ email:
27
+ - ippa@rubylicio.us
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - History.txt
34
+ files:
35
+ - History.txt
36
+ - README.rdoc
37
+ - Rakefile
38
+ - examples/axe.rb
39
+ - examples/balls.rb
40
+ - examples/echoes.rb
41
+ - examples/gosu_base.rb
42
+ - examples/gosu_rain.rb
43
+ - examples/gosu_river_of_stars.rb
44
+ - examples/gosu_triangles.rb
45
+ - examples/gosu_wish_upon_a_star.rb
46
+ - examples/ippagaming_intro.rb
47
+ - examples/media/23700__hazure__chop.wav
48
+ - examples/media/Establo.ttf
49
+ - examples/media/FeaturedItem.ttf
50
+ - examples/media/FreeSans.ttf
51
+ - examples/media/Hursheys.ttf
52
+ - examples/media/axe.png
53
+ - examples/media/axe.svg
54
+ - examples/media/ball.png
55
+ - examples/media/ball.svg
56
+ - examples/media/black.bmp
57
+ - examples/media/blue_triangle.png
58
+ - examples/media/blue_triangle.svg
59
+ - examples/media/chop.wav
60
+ - examples/media/cloth_background.png
61
+ - examples/media/drawing.svg
62
+ - examples/media/drip.wav
63
+ - examples/media/green_triangle.png
64
+ - examples/media/green_triangle.svg
65
+ - examples/media/hit.wav
66
+ - examples/media/ippa_gaming.png
67
+ - examples/media/ippa_gaming.svg
68
+ - examples/media/oil_drip.wav
69
+ - examples/media/outdoor_scene.bmp
70
+ - examples/media/outdoor_scene.png
71
+ - examples/media/outdoor_scene.svg
72
+ - examples/media/rain-bak1.wav
73
+ - examples/media/rain.wav
74
+ - examples/media/rain2.wav
75
+ - examples/media/raindrop.png
76
+ - examples/media/raindrop.svg
77
+ - examples/media/raindrop_small.bmp
78
+ - examples/media/raindrop_small.png
79
+ - examples/media/red_triangle.png
80
+ - examples/media/red_triangle.svg
81
+ - examples/media/spaceship_noalpha.png
82
+ - examples/media/star_5.png
83
+ - examples/media/star_5.svg
84
+ - examples/media/star_6.png
85
+ - examples/media/star_6.svg
86
+ - examples/rain.rb
87
+ - examples/rain_advanced.rb
88
+ - examples/rubygame_river_of_stars.rb
89
+ - examples/zoom.rb
90
+ - lib/movie_maker.rb
91
+ - lib/movie_maker/action.rb
92
+ - lib/movie_maker/core_extensions.rb
93
+ - lib/movie_maker/gosu_autoload.rb
94
+ - lib/movie_maker/gosu_clock.rb
95
+ - lib/movie_maker/named_resource.rb
96
+ - lib/movie_maker/sprite.rb
97
+ has_rdoc: true
98
+ homepage: http://github.com/ippa/movie_maker/tree/master
99
+ licenses:
100
+ post_install_message:
101
+ rdoc_options:
102
+ - --main
103
+ - README.rdoc
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: "0"
111
+ version:
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: "0"
117
+ version:
118
+ requirements: []
119
+
120
+ rubyforge_project: movie_maker
121
+ rubygems_version: 1.3.5
122
+ signing_key:
123
+ specification_version: 2
124
+ summary: Automate image movements/effects and sounds over a period of time, useful for games.
125
+ test_files: []
126
+