rubygame 2.2.0-i586-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/CREDITS +60 -0
  2. data/LICENSE +504 -0
  3. data/NEWS +201 -0
  4. data/README +139 -0
  5. data/ROADMAP +43 -0
  6. data/Rakefile +409 -0
  7. data/doc/extended_readme.rdoc +49 -0
  8. data/doc/getting_started.rdoc +47 -0
  9. data/doc/macosx_install.rdoc +70 -0
  10. data/doc/windows_install.rdoc +123 -0
  11. data/ext/rubygame/MANIFEST +25 -0
  12. data/ext/rubygame/rubygame_core.so +0 -0
  13. data/ext/rubygame/rubygame_event.c +644 -0
  14. data/ext/rubygame/rubygame_event.h +48 -0
  15. data/ext/rubygame/rubygame_event.o +0 -0
  16. data/ext/rubygame/rubygame_gfx.c +942 -0
  17. data/ext/rubygame/rubygame_gfx.h +101 -0
  18. data/ext/rubygame/rubygame_gfx.o +0 -0
  19. data/ext/rubygame/rubygame_gfx.so +0 -0
  20. data/ext/rubygame/rubygame_gl.c +154 -0
  21. data/ext/rubygame/rubygame_gl.h +32 -0
  22. data/ext/rubygame/rubygame_gl.o +0 -0
  23. data/ext/rubygame/rubygame_image.c +108 -0
  24. data/ext/rubygame/rubygame_image.h +41 -0
  25. data/ext/rubygame/rubygame_image.o +0 -0
  26. data/ext/rubygame/rubygame_image.so +0 -0
  27. data/ext/rubygame/rubygame_joystick.c +247 -0
  28. data/ext/rubygame/rubygame_joystick.h +41 -0
  29. data/ext/rubygame/rubygame_joystick.o +0 -0
  30. data/ext/rubygame/rubygame_main.c +155 -0
  31. data/ext/rubygame/rubygame_main.h +33 -0
  32. data/ext/rubygame/rubygame_main.o +0 -0
  33. data/ext/rubygame/rubygame_mixer.c +764 -0
  34. data/ext/rubygame/rubygame_mixer.h +62 -0
  35. data/ext/rubygame/rubygame_mixer.o +0 -0
  36. data/ext/rubygame/rubygame_mixer.so +0 -0
  37. data/ext/rubygame/rubygame_screen.c +448 -0
  38. data/ext/rubygame/rubygame_screen.h +43 -0
  39. data/ext/rubygame/rubygame_screen.o +0 -0
  40. data/ext/rubygame/rubygame_shared.c +209 -0
  41. data/ext/rubygame/rubygame_shared.h +60 -0
  42. data/ext/rubygame/rubygame_shared.o +0 -0
  43. data/ext/rubygame/rubygame_surface.c +1147 -0
  44. data/ext/rubygame/rubygame_surface.h +62 -0
  45. data/ext/rubygame/rubygame_surface.o +0 -0
  46. data/ext/rubygame/rubygame_time.c +183 -0
  47. data/ext/rubygame/rubygame_time.h +32 -0
  48. data/ext/rubygame/rubygame_time.o +0 -0
  49. data/ext/rubygame/rubygame_ttf.c +599 -0
  50. data/ext/rubygame/rubygame_ttf.h +69 -0
  51. data/ext/rubygame/rubygame_ttf.o +0 -0
  52. data/ext/rubygame/rubygame_ttf.so +0 -0
  53. data/lib/rubygame/MANIFEST +12 -0
  54. data/lib/rubygame/clock.rb +128 -0
  55. data/lib/rubygame/color/models/base.rb +106 -0
  56. data/lib/rubygame/color/models/hsl.rb +153 -0
  57. data/lib/rubygame/color/models/hsv.rb +149 -0
  58. data/lib/rubygame/color/models/rgb.rb +78 -0
  59. data/lib/rubygame/color/palettes/css.rb +49 -0
  60. data/lib/rubygame/color/palettes/palette.rb +100 -0
  61. data/lib/rubygame/color/palettes/x11.rb +177 -0
  62. data/lib/rubygame/color.rb +79 -0
  63. data/lib/rubygame/constants.rb +238 -0
  64. data/lib/rubygame/event.rb +313 -0
  65. data/lib/rubygame/ftor.rb +370 -0
  66. data/lib/rubygame/hotspot.rb +265 -0
  67. data/lib/rubygame/keyconstants.rb +237 -0
  68. data/lib/rubygame/mediabag.rb +94 -0
  69. data/lib/rubygame/queue.rb +288 -0
  70. data/lib/rubygame/rect.rb +612 -0
  71. data/lib/rubygame/sfont.rb +223 -0
  72. data/lib/rubygame/sprite.rb +511 -0
  73. data/lib/rubygame.rb +41 -0
  74. data/samples/FreeSans.ttf +0 -0
  75. data/samples/GPL.txt +340 -0
  76. data/samples/README +40 -0
  77. data/samples/chimp.bmp +0 -0
  78. data/samples/chimp.rb +313 -0
  79. data/samples/demo_gl.rb +151 -0
  80. data/samples/demo_gl_tex.rb +197 -0
  81. data/samples/demo_music.rb +75 -0
  82. data/samples/demo_rubygame.rb +284 -0
  83. data/samples/demo_sfont.rb +52 -0
  84. data/samples/demo_ttf.rb +193 -0
  85. data/samples/demo_utf8.rb +53 -0
  86. data/samples/fist.bmp +0 -0
  87. data/samples/load_and_blit.rb +22 -0
  88. data/samples/panda.png +0 -0
  89. data/samples/punch.wav +0 -0
  90. data/samples/ruby.png +0 -0
  91. data/samples/song.ogg +0 -0
  92. data/samples/term16.png +0 -0
  93. data/samples/whiff.wav +0 -0
  94. metadata +152 -0
data/Rakefile ADDED
@@ -0,0 +1,409 @@
1
+ require 'rubygems'
2
+ Gem::manage_gems
3
+
4
+ require 'rake'
5
+ require 'rake/gempackagetask'
6
+ require 'rake/rdoctask'
7
+
8
+ require "rbconfig"
9
+ include Config
10
+
11
+ require 'English'
12
+
13
+ class ShellCommandError < RuntimeError
14
+ end
15
+
16
+ # Execute the block (which is supposed to perform a shell command),
17
+ # then raise ShellCommandError if the command failed.
18
+ def try_shell( &block )
19
+ result = yield
20
+
21
+ unless $CHILD_STATUS.exitstatus == 0
22
+ raise ShellCommandError, "Command failed. Aborting."
23
+ end
24
+
25
+ return result
26
+ end
27
+
28
+ def try_sdl_config( flag )
29
+ begin
30
+ if $options[:"sdl-config"]
31
+ return try_shell { `sdl-config #{flag}`.chomp }
32
+ else
33
+ return String.new
34
+ end
35
+ rescue ShellCommandError
36
+ warn "WARNING: 'sdl-config' failed."
37
+ warn "Continuing anyway, but compile may fail."
38
+ return String.new
39
+ end
40
+ end
41
+
42
+ # Get a variable from ENV or CONFIG, with ENV having precedence.
43
+ # Returns "" if the variable didn't exist at all.
44
+ def from_env_or_config(string)
45
+ ([ENV[string], CONFIG[string]] - ["", nil])[0] or ""
46
+ end
47
+
48
+ OBJEXT = from_env_or_config("OBJEXT")
49
+ DLEXT = from_env_or_config("DLEXT")
50
+
51
+ RUBYGAME_VERSION = "2.2.0"
52
+
53
+ spec = Gem::Specification.new do |s|
54
+ s.name = "rubygame"
55
+ s.version = RUBYGAME_VERSION
56
+ s.author = "John Croisant"
57
+ s.email = "jacius@users.sourceforge.net"
58
+ s.homepage = "http://rubygame.sourceforge.net/"
59
+ s.summary = "Clean and powerful library for game programming"
60
+ s.has_rdoc = true
61
+
62
+ s.files = FileList.new do |fl|
63
+ fl.include("{lib,ext,samples,doc}/**/*")
64
+ fl.exclude(/svn/)
65
+ #fl.exclude(/\.#{OBJEXT}/)
66
+ end
67
+
68
+ s.require_paths = ["lib", "lib/rubygame/", "ext/rubygame/"]
69
+ s.autorequire = "rubygame.rb"
70
+ s.extensions = ["Rakefile"]
71
+
72
+ s.extra_rdoc_files = FileList.new do |fl|
73
+ fl.include "doc/*.rdoc"
74
+ fl.include "README", "LICENSE", "CREDITS", "ROADMAP", "NEWS"
75
+ end
76
+ end
77
+
78
+ task :linux do
79
+ spec.platform = Gem::Platform::LINUX_586
80
+ end
81
+
82
+ task :macosx do
83
+ spec.platform = Gem::Platform::DARWIN
84
+ end
85
+
86
+ task :win32 do
87
+ spec.platform = Gem::Platform::WIN32
88
+ end
89
+
90
+ Rake::GemPackageTask.new(spec) do |pkg|
91
+ pkg.need_tar_bz2 = true
92
+ end
93
+
94
+ Rake::RDocTask.new do |rd|
95
+ rd.main = "README"
96
+ rd.title = "Rubygame #{RUBYGAME_VERSION} Docs"
97
+ rd.rdoc_files.include("ext/rubygame/*.c",
98
+ "lib/rubygame/**/*.rb",
99
+ "doc/*.rdoc",
100
+ "README",
101
+ "LICENSE",
102
+ "CREDITS",
103
+ "ROADMAP",
104
+ "NEWS")
105
+ end
106
+
107
+ task :default => [:build]
108
+ desc "Compile all of the extensions"
109
+ task :build
110
+
111
+ require 'rake/clean'
112
+ task(:clean) { puts "Cleaning out temporary generated files" }
113
+ task(:clobber) { puts "Cleaning out final generated files" }
114
+
115
+ ##############################
116
+ ## BUILD OPTIONS ##
117
+ ##############################
118
+
119
+ $options = {
120
+ :"sdl-gfx" => true,
121
+ :"sdl-image" => true,
122
+ :"sdl-ttf" => true,
123
+ :"sdl-mixer" => true,
124
+ :opengl => true,
125
+ :"sdl-config" => true,
126
+ :debug => false,
127
+ :verbose => false,
128
+ :sitearchdir => CONFIG["sitearchdir"],
129
+ :sitelibdir => CONFIG["sitelibdir"]
130
+ }
131
+
132
+ # Default behavior for win32 is to skip sdl_config,
133
+ # since it's usually not available. It can still be
134
+ # enabled through the options, though.
135
+ if PLATFORM =~ /win32/
136
+ $options[:"sdl-config"] = false
137
+ end
138
+
139
+ # Define tasks to enable and disable bool options.
140
+ #
141
+ # rake option
142
+ # rake no-option
143
+ #
144
+ # task_name:: the task name to use
145
+ # option_name:: the option name (if different from
146
+ # the task name)
147
+ # desc:: a longer description, to fill
148
+ # "Enable ________.", if different
149
+ # from the task name.
150
+ #
151
+ def bool_option( task_name, option_name=nil, desc=nil )
152
+ option_name = task_name unless option_name
153
+ option_name = option_name.intern if option_name.kind_of? String
154
+
155
+ desc = task_name.to_s unless desc
156
+
157
+ notask_name = "no-#{task_name.to_s}".intern
158
+
159
+ is_true = $options[option_name]
160
+
161
+ desc "Enable #{desc} #{'(default)' if is_true}"
162
+ task(task_name) { $options[option_name] = true }
163
+
164
+ desc "Disable #{desc} #{'(default)' unless is_true}"
165
+ task(notask_name) { $options[option_name] = false }
166
+ end
167
+
168
+ # Gather a string option from an environment variable:
169
+ #
170
+ # rake option="the value of the option"
171
+ #
172
+ # task_name:: the task name to use
173
+ # option_name:: the option name (if different from
174
+ # the task name)
175
+ #
176
+ def string_option( task_name, option_name=nil )
177
+ option_name = task_name unless option_name
178
+ option_name = option_name.intern if option_name.kind_of? String
179
+
180
+ $options[option_name] = ENV["#{task_name}"] if ENV["#{task_name}"]
181
+ end
182
+
183
+ bool_option :"sdl-gfx", nil, "SDL_gfx support"
184
+ bool_option :"sdl-image", nil, "SDL_image support"
185
+ bool_option :"sdl-mixer", nil, "SDL_mixer support"
186
+ bool_option :"sdl-ttf", nil, "SDL_ttf support"
187
+ bool_option :"sdl-config", nil, "guess compiler flags for SDL"
188
+ bool_option :opengl, nil, "OpenGL support"
189
+ bool_option :debug, nil, "compil with debug symbols"
190
+ bool_option :verbose, nil, "show compiler commands"
191
+
192
+ string_option "RUBYARCHDIR", :sitearchdir
193
+ string_option :sitearchdir
194
+
195
+ string_option "RUBYLIBDIR", :sitelibdir
196
+ string_option :sitelibdir
197
+
198
+
199
+ CFLAGS = [from_env_or_config("CFLAGS"),
200
+ try_sdl_config("--cflags"),
201
+ "-I. -I#{CONFIG['topdir']}",
202
+ ("-g" if $options[:debug]) ].join(" ")
203
+
204
+ LINK_FLAGS = [from_env_or_config("LIBRUBYARG_SHARED"),
205
+ from_env_or_config("LDFLAGS"),
206
+ try_sdl_config("--libs")].join(" ")
207
+
208
+ DEFAULT_EXTDIR = File.join('ext','rubygame','')
209
+
210
+ class ExtensionModule
211
+ @@libflag = " -l%s " # compiler flag for giving linked libraries
212
+ attr_accessor :dynlib, :objs, :libs, :cflags, :lflags, :directory
213
+ def initialize(&block)
214
+ @directory = DEFAULT_EXTDIR
215
+ @dynlib = ""
216
+ @objs = []
217
+ @libs = []
218
+ @lflags = ""
219
+ yield self if block_given?
220
+ end
221
+
222
+ def add_lib( lib )
223
+ @lflags << @@libflag%lib
224
+ end
225
+
226
+ def add_header( header )
227
+ #CFLAGS << " -DHAVE_#{header.upcase.gsub('.','_')} "
228
+ end
229
+
230
+ def create_all_tasks()
231
+ create_obj_task
232
+ create_dl_task
233
+ CLEAN.include("#{@directory}/*.#{OBJEXT}")
234
+ CLOBBER.include("#{@directory}/*.#{DLEXT}")
235
+ end
236
+
237
+ # Create a file task for each dynamic library (.so) we want to generate.
238
+ #
239
+ # The file task invokes another task which does the actual compiling, and
240
+ # has the true prerequisites.
241
+ #
242
+ # This is done so that the prerequisites don't have to be compiled when
243
+ # the final product already exists (such as in the precompiled win32 gem).
244
+ #
245
+ def create_dl_task
246
+ dynlib_full = File.join( @directory, "#{dynlib}.#{DLEXT}" )
247
+ objs_full = @objs.collect { |obj|
248
+ File.join( @directory, "#{obj}.#{OBJEXT}" )
249
+ }
250
+
251
+ desc "Compile the #{@dynlib} extension"
252
+ file dynlib_full => objs_full do |task|
253
+ link_command = "#{from_env_or_config('LDSHARED')} #{LINK_FLAGS} #{@lflags} -o #{dynlib_full} #{task.prerequisites.join(' ')}"
254
+ if( $options[:verbose] )
255
+ try_shell { sh link_command }
256
+ else
257
+ puts "Linking compiled files to create #{File.basename(@directory)}/#{File.basename(dynlib_full)}"
258
+ try_shell { `#{link_command}` }
259
+ end
260
+ end
261
+
262
+ task :build => [dynlib_full] # Add this as a prereq of the build
263
+ task :install_ext => [dynlib_full] # ...and install_ext tasks
264
+ end
265
+
266
+ def create_obj_task
267
+ # A rule for object files (".o" on linux).
268
+ # This won't work for rake < 0.7.2, because the proc returns an Array.
269
+ # If it raises an exception, we'll try a more compatible way.
270
+ rule(/#{@directory}.+\.#{OBJEXT}$/ =>
271
+ [
272
+ # Generate dependencies for this .o file
273
+ proc do |objfile|
274
+ source = objfile.sub(".#{OBJEXT}", ".c") # the .c file
275
+ [source] + depends_headers( source ) # Array of .c + .h dependencies
276
+ end
277
+ ])\
278
+ do |t|
279
+ compile_command = "#{from_env_or_config('CC')} -c #{CFLAGS} #{t.source} -o #{t.name}"
280
+ if( $options[:verbose] )
281
+ try_shell { sh compile_command }
282
+ else
283
+ puts "Compiling #{File.basename(@directory)}/#{File.basename(t.source)}"
284
+ try_shell { `#{compile_command}` }
285
+ end
286
+ end
287
+ rescue
288
+ # Generate a .o rule for each .c file in the directory.
289
+ FileList.new("#{@directory}*.c").each do |source|
290
+ object = source.sub(".c", ".#{OBJEXT}")
291
+ file object => ([source] + depends_headers( source )) do |t|
292
+ compile_command = "#{CONFIG['CC']} -c #{CFLAGS} #{source} -o #{t.name}"
293
+ if( $options[:verbose] )
294
+ try_shell { sh compile_command }
295
+ else
296
+ puts "Compiling #{File.basename(@directory)}/#{File.basename(source)}"
297
+ try_shell { `#{compile_command}` }
298
+ end
299
+ end
300
+ end
301
+ end
302
+
303
+ # Extracts the names of all the headers that the C file depends on.
304
+ def depends_headers( filename )
305
+ return [] # workaround for a bug
306
+ depends = []
307
+ File.open(filename, "r") do |file|
308
+ file.each_line do |line|
309
+ if /#include\s+"(\w+\.h)"/ =~ line
310
+ depends << @directory+$1
311
+ end
312
+ end
313
+ end
314
+ return depends
315
+ end
316
+ end
317
+
318
+ rubygame_core = ExtensionModule.new do |core|
319
+ core.dynlib = 'rubygame_core'
320
+ core.objs = ['rubygame_main',
321
+ 'rubygame_shared',
322
+ 'rubygame_event',
323
+ 'rubygame_gl',
324
+ 'rubygame_joystick',
325
+ 'rubygame_screen',
326
+ 'rubygame_surface',
327
+ 'rubygame_time',
328
+ ]
329
+ core.create_all_tasks()
330
+ end
331
+
332
+ # TODO: We should check if the libraries exist?
333
+
334
+ rubygame_gfx = ExtensionModule.new do |gfx|
335
+ gfx.dynlib = 'rubygame_gfx'
336
+ gfx.objs = ['rubygame_shared', 'rubygame_gfx']
337
+ gfx.add_lib( 'SDL_gfx' )
338
+ gfx.add_header( 'SDL_gfxPrimitives.h')
339
+ gfx.add_header( 'SDL_rotozoom.h' )
340
+ gfx.create_all_tasks() if $options[:"sdl-gfx"]
341
+ end
342
+
343
+ rubygame_image = ExtensionModule.new do |image|
344
+ image.dynlib = 'rubygame_image'
345
+ image.objs = ['rubygame_shared', 'rubygame_image']
346
+ image.add_lib('SDL_image')
347
+ image.add_header('SDL_image.h')
348
+ image.create_all_tasks() if $options[:"sdl-image"]
349
+ end
350
+
351
+ rubygame_mixer = ExtensionModule.new do |mixer|
352
+ mixer.dynlib = 'rubygame_mixer'
353
+ mixer.objs = ['rubygame_shared', 'rubygame_mixer']
354
+ mixer.add_lib('SDL_mixer')
355
+ mixer.add_header('SDL_mixer.h')
356
+ mixer.create_all_tasks() if $options[:"sdl-mixer"]
357
+ end
358
+
359
+ rubygame_ttf = ExtensionModule.new do |ttf|
360
+ ttf.dynlib = 'rubygame_ttf'
361
+ ttf.add_lib('SDL_ttf')
362
+ ttf.objs = ['rubygame_shared', 'rubygame_ttf']
363
+ ttf.add_header('SDL_ttf.h')
364
+ ttf.create_all_tasks() if $options[:"sdl-ttf"]
365
+ end
366
+
367
+ if $options[:opengl]
368
+ CFLAGS << " -DHAVE_OPENGL "
369
+ end
370
+
371
+ desc "(Called when installing via Rubygems)"
372
+ task :extension => [:fix_filenames, :build]
373
+
374
+ task :fix_filenames do
375
+ unless DLEXT == 'so'
376
+ Rake::Task[:install_ext].prerequisites.each do |prereq|
377
+ prereq = prereq.ext('so')
378
+ if File.exist? prereq
379
+ mv prereq, prereq.ext(DLEXT)
380
+ end
381
+ end
382
+ end
383
+ end
384
+
385
+ desc "Install just the extensions"
386
+ task :install_ext do |task|
387
+ puts "Installing extensions to #{$options[:sitearchdir]}"
388
+ mkdir_p $options[:sitearchdir]
389
+ cp task.prerequisites.to_a, $options[:sitearchdir]
390
+ end
391
+
392
+ desc "Install just the library"
393
+ task :install_lib do |task|
394
+ puts "Installing library to #{$options[:sitelibdir]}"
395
+
396
+ files = FileList.new do |fl|
397
+ fl.include("lib/**/*.rb")
398
+ fl.exclude(/svn/)
399
+ end
400
+
401
+ files.each do |f|
402
+ dir = File.join($options[:sitelibdir], File.dirname(f).sub('lib',''), "")
403
+ mkdir_p dir
404
+ cp f, dir
405
+ end
406
+ end
407
+
408
+ desc "Install both the extensions and the library"
409
+ task :install => [:install_ext, :install_lib]
@@ -0,0 +1,49 @@
1
+ = Extended README
2
+
3
+ (Stuff that didn't make it into the main README file.)
4
+
5
+ == Internal structure of Rubygame
6
+
7
+ Rubygame's core is a low-level extension written in C; it
8
+ provides a basic interface to SDL and its companion libraries.
9
+ Building upon that is a ruby library which implements high-level
10
+ concepts like game objects, event management, etc.
11
+
12
+ Rubygame is modular, meaning you can pick and choose which parts to use.
13
+ For example, if you don't need TrueType font support, SDL_ttf is not
14
+ required to compile Rubygame. It is possible for a game to detect at
15
+ run-time which features are present, and behave accordingly (for example,
16
+ the game might disable certain optional features).
17
+
18
+ Rubygame is multi-tiered, meaning you can access Rubygame's functionality
19
+ on a number of levels, each level being built on the level below it.
20
+ Each higher level is closer to a complete game, but is also less flexible.
21
+ The idea here is that developers will use the higher levels most of the
22
+ time, but be free to hack lower levels when they need to do something
23
+ special.
24
+
25
+ == About the version number
26
+
27
+ The version number of Rubygame has a strict meaning, to help you decide
28
+ whether the new version might break your application. The version number has
29
+ 3 parts: the major version number, the minor version number, and the patch
30
+ number. For the example of Rubygame 2.0.0:
31
+
32
+ 2 . 0 . 0
33
+ MAJOR . MINOR . PATCH
34
+
35
+ When a new release of Rubygame is made, one of the version numbers will
36
+ go up, and the numbers that come after it will be reset to 0. Which number
37
+ will go up depends on how much the Rubygame API changed:
38
+
39
+ - *MAJOR*: API has changed, and old apps must be updated.
40
+ An example of this is when a class has been significantly changed, or a
41
+ method has renamed/moved to another module and the old name is removed.
42
+
43
+ - *MINOR*: API has changed, but old apps will still work.
44
+ An example of this is when a new feature has been added, or a
45
+ method has been renamed but the old name is still supported.
46
+
47
+ - *PATCH*: API has not changed at all.
48
+ An example of this is when a bug has been fixed, or existing code has
49
+ been improved beneath the surface.
@@ -0,0 +1,47 @@
1
+ = Getting Started with Rubygame
2
+
3
+ == About Rubygame
4
+
5
+ Rubygame is a combination extension and library for the Ruby language,
6
+ designed for creating computer games (and having fun doing it!).
7
+ As an extension, it provides an interface to the Simple DirectMedia Library
8
+ (SDL) and its companion libraries SDL_gfx, SDL_image, SDL_ttf, and SDL_mixer.
9
+ As a Ruby library, it provides classes/modules which implement some useful
10
+ concepts such as Sprites, Event Queues, and rasterized fonts (SFont).
11
+
12
+ == Suggested Order
13
+
14
+ To get acquainted with Rubygame, we recommend exploring the available classes
15
+ and modules in this order.
16
+
17
+ First, take a look at the most fundamental classes:
18
+ - Rubygame::Screen (the display window, what the user sees)
19
+ - Rubygame::Surface (stores image data which can be copied to the Screen)
20
+ - Rubygame::Rect (stores a rectangular area, like part of the Screen)
21
+
22
+ As a next step, read about the event Queue and the hardware events, which
23
+ allow you to take keyboard and mouse input, among other things.
24
+ - Rubygame::EventQueue (stores events for processing)
25
+ - Rubygame::KeyDownEvent (keyboard button is pressed)
26
+ - Rubygame::KeyUpEvent (keyboard button is released)
27
+ - Rubygame::MouseDownEvent (mouse button is clicked)
28
+ - Rubygame::MouseUpEvent (mouse button is released)
29
+ - Rubygame::MouseMotionEvent (mouse cursor is moved)
30
+ - Rubygame::QuitEvent (user tries to close the window)
31
+ - Rubygame::JoyDownEvent (joystick button is pressed)
32
+ - Rubygame::JoyUpEvent (joystick button is released)
33
+ - Rubygame::JoyAxisEvent (joystick axis is moved)
34
+ - Rubygame::JoyBallEvent (joystick trackball is moved)
35
+ - Rubygame::JoyHatEvent (joystick 8-directional hat switch is moved)
36
+ - Rubygame::ActiveEvent (the Screen gets keyboard and/or mouse focus)
37
+ - Rubygame::ResizeEvent (the Screen is resized)
38
+ - Rubygame::ExposeEvent (the Screen is redrawn, mostly for OpenGL)
39
+
40
+ Finally, familiarize yourself with:
41
+ - Rubygame::Clock for monitoring and controlling framerate to save resources
42
+ - Rubygame::Sprites for an easy-to-use yet flexible on-screen object framework
43
+ - Rubygame::TTF and Rubygame::SFont for rendering text
44
+ - Rubygame::GL for hardware-accelerated 3D graphics with OpenGL
45
+
46
+ There are several sample applications in the rubygame/samples/ directory
47
+ packaged with Rubygame which can also help you get started.
@@ -0,0 +1,70 @@
1
+ = How to install Rubygame on Mac OS X
2
+
3
+ This is an outline of the steps to compile and use Rubygame on Mac OS X!
4
+
5
+ == Installing dependencies...
6
+
7
+ You have two options for installing the software libraries that Rubygame
8
+ depends on: Darwinports or Fink. Which option you choose is just a matter of
9
+ preference.
10
+
11
+ === ...with Darwinports[http://darwinports.opendarwin.org/]
12
+
13
+
14
+ 1. {Install darwinports}[http://darwinports.opendarwin.org/getdp/]
15
+ 2. Open a new terminal (can be found in /Applications/Utilities).
16
+ 3. Install SDL:
17
+
18
+ sudo port install libsdl
19
+
20
+ 4. (Optional, but *highly* recommended:) Install the SDL companion
21
+ libraries:
22
+
23
+ sudo port install libsdl_gfx libsdl_image libsdl_mixer libsdl_ttf
24
+
25
+ === ...with Fink[http://www.finkproject.org/]
26
+
27
+ 1. {Install Fink}[http://www.finkproject.org/download/index.php?phpLang=en]
28
+ and update to the latest version.
29
+ 2. Open a new terminal (can be found in /Applications/Utilities).
30
+ 3. Install SDL:
31
+
32
+ sudo apt-get install sdl
33
+
34
+ 4. (Optional, but *highly* recommended:) Install the SDL companion
35
+ libraries:
36
+
37
+ sudo apt-get install sdl-gfx13 sdl-image sdl-mixer sdl-ttf
38
+
39
+ == Installing rsdl
40
+
41
+ In order to use Rubygame applications on Mac OS X, you must use a special wrapper for the ruby interpreter, called rsdl.
42
+
43
+ 1. {Download and unpack rsdl}[http://www.kumaryu.net/?c=plugin;plugin=attach_download;p=%28Ruby%29+Ruby%2FSDL%CD%D1ruby;file_name=rsdl.tar.gz].
44
+ 2. From within the rsdl directory:
45
+
46
+ make
47
+ sudo cp rsdl /usr/local/bin/
48
+
49
+
50
+ == Installing Rubygame
51
+ 1. {Download and unpack Rubygame}[https://sourceforge.net/project/showfiles.php?group_id=172781].
52
+ 2. From within the rubygame directory:
53
+
54
+ sudo rake install
55
+
56
+ 3. Please refer to the README file for options that you can pass to setup.rb
57
+ or rake (depending on your version of Rubygame)
58
+
59
+ == Running an application
60
+
61
+ If all went well, you can now run Rubygame applications like so:
62
+ <code>rsdl a_rubygame_app.rb</code>
63
+
64
+ If something bad happened along the way, you can {submit a support request}[https://sourceforge.net/tracker/?func=add&group_id=172781&atid=862995]
65
+ and we'll try to help! Be sure to include plenty of details and paste any error
66
+ messages that occur (plus a good bit of the text right before the error
67
+ messages).
68
+
69
+ (Many thanks to Raffael Mancini (sepisultrum) and Matt Crinklaw for
70
+ instructions to install dependencies with darwinports and fink, respectively.)
@@ -0,0 +1,123 @@
1
+ = Compiling Rubygame on Windows
2
+
3
+ (For the most up-to-date version of this document, see the Rubygame wiki:
4
+ http://rubygame.wiki.sourceforge.net/win32_compile)
5
+
6
+ This document gives some helpful guidelines to for compiling and installing
7
+ Rubygame on Microsoft Windows. However, these instructions are not perfect,
8
+ so they might not work for you. If you use this guide, we'd love to hear about
9
+ what worked and what didn't; just send a message to the {rubygame-users mailing
10
+ list}[https://sourceforge.net/mail/?group_id=172781]!
11
+
12
+ The usual caveats apply: follow these instructions at your own risk and so
13
+ forth. Please direct comments or questions to the {Rubygame user's mailing
14
+ list}[http://sourceforge.net/mail/?group_id=172781].
15
+
16
+ == Step 1: Gather Dependencies
17
+
18
+ - You'll need a build environment for Windows. In this guide, we'll use
19
+ {MinGW}[http://www.mingw.org/MinGWiki/index.php/GettingStarted].
20
+ - Grab MinGW-NNN.exe (e.g. MinGW-5.12.exe) from the {downloads page}[http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=82721]
21
+ and install it. (Note: you might need to expand the "MinGW" section to see
22
+ the MinGW-NNN.exe files.)
23
+ - Optional, but recommended: install MSYS-NNNN.exe (e.g. MSYS-1.0.10.exe)
24
+ from the same page as above. (You might have to expand the MSYS section.)
25
+ - Add the full path to the compiler executible to your system PATH if it
26
+ isn't there already. You should be able to type <code>gcc -v</code> at a
27
+ command line and see a version number.
28
+
29
+ - {Download Ruby}[http://www.ruby-lang.org/en/downloads/], the language itself.
30
+ The easiest option here is the one-click installer. This will install
31
+ Ruby and a number of useful libraries without any hassle.
32
+
33
+ - {SDL}[http://www.libsdl.org/download-1.2.php]. In the <b>Development
34
+ Libraries</b> section (near the bottom of the page), grab the
35
+ SDL-devel-1.2.??-VC6.zip file. (The VC6 package is just fine, even though
36
+ we're using with MinGW to compile.)
37
+
38
+ The rest are optional dependencies, but highly recommended. If you don't have
39
+ them, you won't be able to use certain features of Rubygame.
40
+
41
+ - {SDL_image}[http://www.libsdl.org/projects/SDL_image/]. Grab the Win32
42
+ binary package with 'devel' in the name.
43
+ - {SDL_mixer}[http://www.libsdl.org/projects/SDL_mixer/]. Just like before,
44
+ grab the Win32 binary package with 'devel' in the name.
45
+ - {SDL_ttf}[http://www.libsdl.org/projects/SDL_ttf/]. Again, get the
46
+ Win32 binary package with 'devel' in the name
47
+ - {SDL_gfx}[http://www.ferzkopp.net/joomla/content/view/19/14/]. This is
48
+ the trickiest dependency, because there is currently no official package for
49
+ a precompiled version of SDL_gfx. If you are able to compile this yourself,
50
+ great! Otherwise, some nice features of Rubygame have to be disabled;
51
+ make sure you add the --no-gfx flag when you get to the "Set up environment
52
+ variables" section, below.
53
+
54
+ Once you have downloaded everything, extract each archive into a convenient
55
+ location on your hard drive. You'll thank yourself later if you use a short
56
+ path with no spaces in it. For this example, we'll unzip everything under
57
+ <code>C:\\src\\</code>.
58
+
59
+ Next, copy the *.dll file from each library's folder into
60
+ <code>C:\\windows\\system32\\</code>.
61
+ This will allow the libraries to be detected properly later on.
62
+
63
+ == Step 2: Get Rubygame
64
+
65
+ If you haven't already, download the latest Rubygame source from the
66
+ {download page}[http://sourceforge.net/project/showfiles.php?group_id=172781].
67
+ If you're feeling adventurous, you could try the in-development code from
68
+ the {Subversion repository}[http://sourceforge.net/svn/?group_id=172781].
69
+ You can decompress the .tar.bz2 file with either MSYS' <code>tar</code>
70
+ (<code>tar xvjf rubygame-2.0.0.tar.bz2</code>) or a program like
71
+ {7zip}[http://www.7-zip.org].
72
+
73
+ Extract the source into another folder of your choice, such as
74
+ <code>C:\\src\\rubygame</code>.
75
+
76
+ == Step 3: Set up environment variables
77
+
78
+ Environment variables are used to configure the build process for your
79
+ system; it helps the compiler to locate the headers and libraries it needs to
80
+ compile Rubygame.
81
+
82
+ Create a text file in your Rubygame directory called "envsetup.bat".
83
+ In it, use code based on the following to set your variables.
84
+ Be sure to replace '\src\' (lines 3-7) with the path to where you unpacked
85
+ the libraries.
86
+
87
+ set CC=gcc
88
+ set CFLAGS=-DHAVE_ISINF -D_MSC_VER=1200
89
+ set CFLAGS=%CFLAGS% -I \src\SDL-1.2.11\include
90
+ set CFLAGS=%CFLAGS% -I \src\SDL_gfx-2.0.15
91
+ set CFLAGS=%CFLAGS% -I \src\SDL_image-1.2.5\include
92
+ set CFLAGS=%CFLAGS% -I \src\SDL_mixer-1.2.7\include
93
+ set CFLAGS=%CFLAGS% -I \src\SDL_ttf-2.0.8\include
94
+
95
+ set LDSHARED=gcc -shared
96
+ set LINK_FLAGS=-L \windows\system32 -lSDL
97
+ set LIBRUBYARG_SHARED=-L \ruby\bin -lmsvcrt-ruby18
98
+
99
+ The -L parameter for LIBRUBYARG_SHARED may be different if you installed
100
+ Ruby to a path other than C:/ruby.
101
+
102
+ == Step 4: Compile and install Rubygame
103
+
104
+ Open a command prompt and navigate to the root of your Rubygame source
105
+ directory. Type:
106
+
107
+ envsetup.bat
108
+ rake install
109
+
110
+ IMPORTANT: If you are missing an optional library (such as SDL_gfx), you must
111
+ disable optional features by passing a "no-???" command to rake before the word
112
+ "install". For example, to disable features that depend on SDL_gfx, you would
113
+ type this instead of the above:
114
+
115
+ envsetup.bat
116
+ rake no-gfx install
117
+
118
+ If all goes well, you have built and installed Rubygame.
119
+ Try to execute <code>require 'rubygame'</code> in an irb session and run
120
+ the provided samples to ensure that everything is acceptable.
121
+
122
+ (Thanks to Ash Wilson (smashwilson) for contributing the original version of
123
+ these instructions.)