rubygame 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/CREDITS +50 -0
  2. data/Changelog +162 -0
  3. data/LICENSE +504 -0
  4. data/README +122 -0
  5. data/Rakefile +380 -0
  6. data/TODO +45 -0
  7. data/doc/extended_readme.rdoc +49 -0
  8. data/doc/getting_started.rdoc +47 -0
  9. data/doc/macosx_install.rdoc +74 -0
  10. data/doc/windows_install.rdoc +124 -0
  11. data/ext/rubygame/MANIFEST +25 -0
  12. data/ext/rubygame/rubygame_event.c +644 -0
  13. data/ext/rubygame/rubygame_event.h +48 -0
  14. data/ext/rubygame/rubygame_gfx.c +951 -0
  15. data/ext/rubygame/rubygame_gfx.h +102 -0
  16. data/ext/rubygame/rubygame_gl.c +154 -0
  17. data/ext/rubygame/rubygame_gl.h +32 -0
  18. data/ext/rubygame/rubygame_image.c +108 -0
  19. data/ext/rubygame/rubygame_image.h +41 -0
  20. data/ext/rubygame/rubygame_joystick.c +247 -0
  21. data/ext/rubygame/rubygame_joystick.h +41 -0
  22. data/ext/rubygame/rubygame_main.c +155 -0
  23. data/ext/rubygame/rubygame_main.h +33 -0
  24. data/ext/rubygame/rubygame_mixer.c +764 -0
  25. data/ext/rubygame/rubygame_mixer.h +62 -0
  26. data/ext/rubygame/rubygame_screen.c +420 -0
  27. data/ext/rubygame/rubygame_screen.h +41 -0
  28. data/ext/rubygame/rubygame_shared.c +152 -0
  29. data/ext/rubygame/rubygame_shared.h +54 -0
  30. data/ext/rubygame/rubygame_surface.c +1107 -0
  31. data/ext/rubygame/rubygame_surface.h +62 -0
  32. data/ext/rubygame/rubygame_time.c +183 -0
  33. data/ext/rubygame/rubygame_time.h +32 -0
  34. data/ext/rubygame/rubygame_ttf.c +600 -0
  35. data/ext/rubygame/rubygame_ttf.h +69 -0
  36. data/lib/rubygame.rb +40 -0
  37. data/lib/rubygame/MANIFEST +12 -0
  38. data/lib/rubygame/clock.rb +128 -0
  39. data/lib/rubygame/constants.rb +238 -0
  40. data/lib/rubygame/event.rb +313 -0
  41. data/lib/rubygame/ftor.rb +370 -0
  42. data/lib/rubygame/hotspot.rb +265 -0
  43. data/lib/rubygame/keyconstants.rb +237 -0
  44. data/lib/rubygame/mediabag.rb +94 -0
  45. data/lib/rubygame/queue.rb +288 -0
  46. data/lib/rubygame/rect.rb +614 -0
  47. data/lib/rubygame/sfont.rb +223 -0
  48. data/lib/rubygame/sprite.rb +477 -0
  49. data/samples/FreeSans.ttf +0 -0
  50. data/samples/GPL.txt +340 -0
  51. data/samples/README +40 -0
  52. data/samples/chimp.bmp +0 -0
  53. data/samples/chimp.rb +313 -0
  54. data/samples/demo_gl.rb +151 -0
  55. data/samples/demo_gl_tex.rb +197 -0
  56. data/samples/demo_music.rb +75 -0
  57. data/samples/demo_rubygame.rb +279 -0
  58. data/samples/demo_sfont.rb +52 -0
  59. data/samples/demo_ttf.rb +193 -0
  60. data/samples/demo_utf8.rb +53 -0
  61. data/samples/fist.bmp +0 -0
  62. data/samples/load_and_blit.rb +22 -0
  63. data/samples/panda.png +0 -0
  64. data/samples/punch.wav +0 -0
  65. data/samples/ruby.png +0 -0
  66. data/samples/term16.png +0 -0
  67. data/samples/whiff.wav +0 -0
  68. metadata +123 -0
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This program is PUBLIC DOMAIN.
4
+ # It is distributed in the hope that it will be useful,
5
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
6
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
+
8
+ require "rubygame"
9
+ require "rubygame/sfont"
10
+ include Rubygame
11
+
12
+ def main(*args)
13
+ font_name = ""
14
+
15
+ if args.length < 1
16
+ font_name = "term16.png"
17
+ puts <<EOF
18
+ You can pass the filename of a SFont-compatible font as the
19
+ first argument to try it, e.g.: ./demo_sfont.rb my_font.png
20
+
21
+ There are many sample fonts available online:
22
+ http://user.cs.tu-berlin.de/~karlb/sfont/fonts.html
23
+ EOF
24
+ else
25
+ font_name = args[0]
26
+ end
27
+
28
+ screen = Screen.set_mode([700,400])
29
+ queue = EventQueue.new()
30
+ queue.ignore = [ActiveEvent,MouseMotionEvent,MouseUpEvent,MouseDownEvent]
31
+
32
+
33
+ screen.title = "SFont Test (%s)"%font_name
34
+ font = SFont.new(font_name)
35
+ renders = []
36
+ renders << font.render("This font is: %s"%font_name)
37
+ renders << font.render("I say, \"I love pie!\"")
38
+ renders << font.render("I could eat #{Math::PI} pies.")
39
+ renders << font.render("0 1 2 3 4 5 6 7 8 9")
40
+ renders << font.render("!@\#$%^&*()[]{}<>;:/\\+=-_'`\"")
41
+ renders << font.render("abcdefghijklmnopqrstuvwxyz")
42
+ renders << font.render("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
43
+
44
+ (renders.length).times do |i|
45
+ renders[i].blit(screen,[10,10+font.height*i])
46
+ end
47
+ screen.update()
48
+
49
+ queue.wait()
50
+ end
51
+
52
+ main(*ARGV)
@@ -0,0 +1,193 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This program is PUBLIC DOMAIN.
4
+ # It is distributed in the hope that it will be useful,
5
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
6
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
+
8
+ require "rubygame"
9
+ include Rubygame
10
+ Rubygame.init()
11
+
12
+ def test_noaa_nobg(font,screen,y)
13
+ puts "No antialiasing, no background..."
14
+ text = font.render("No AA, no BG",false,[200,200,200])
15
+ text.blit(screen,[0,y])
16
+ end
17
+
18
+ def test_noaa_bg(font,screen,y)
19
+ puts "No antialiasing, background..."
20
+ text = font.render("No AA, BG",false,[200,200,200],[0,0,255])
21
+ text.blit(screen,[0,y])
22
+ end
23
+
24
+ def test_aa_nobg(font,screen,y)
25
+ puts "Antialiasing, no background..."
26
+ text = font.render("AA, no BG",true,[200,200,200])
27
+ text.blit(screen,[0,y])
28
+ end
29
+
30
+ def test_aa_bg(font,screen,y)
31
+ puts "Antialiasing, background..."
32
+ text = font.render("AA, BG",true,[200,200,200],[0,0,255])
33
+ text.blit(screen,[0,y])
34
+ end
35
+
36
+ def test_bold_noaa(font,screen,y)
37
+ puts "Bold, no antialiasing..."
38
+ font.bold = true
39
+ text = font.render("Bold, no AA",false,[200,200,200])
40
+ text.blit(screen,[0,y])
41
+ font.bold = false
42
+ end
43
+
44
+ def test_bold_aa(font,screen,y)
45
+ puts "Bold, antialiasing..."
46
+ font.bold = true
47
+ text = font.render("Bold, AA",true,[200,200,200])
48
+ text.blit(screen,[0,y])
49
+ font.bold = false
50
+ end
51
+
52
+ def test_italic_noaa(font,screen,y)
53
+ puts "Italic, no antialiasing..."
54
+ font.italic = true
55
+ text = font.render("Italic, no AA",false,[200,200,200])
56
+ text.blit(screen,[0,y])
57
+ font.italic = false
58
+ end
59
+
60
+ def test_italic_aa(font,screen,y)
61
+ puts "Italic, antialiasing..."
62
+ font.italic = true
63
+ text = font.render("Italic, AA",true,[200,200,200])
64
+ text.blit(screen,[0,y])
65
+ font.italic = false
66
+ end
67
+
68
+ def test_underline_noaa(font,screen,y)
69
+ puts "Underline, no antialiasing..."
70
+ font.underline = true
71
+ text = font.render("Underline, no AA",false,[200,200,200])
72
+ text.blit(screen,[0,y])
73
+ font.underline = false
74
+ end
75
+
76
+ def test_underline_aa(font,screen,y)
77
+ puts "Underline, antialiasing..."
78
+ font.underline = true
79
+ text = font.render("Underline, AA",true,[200,200,200])
80
+ text.blit(screen,[0,y])
81
+ font.underline = false
82
+ end
83
+
84
+ def test_bi_noaa(font,screen,y)
85
+ puts "Bold, Italic, no antialiasing..."
86
+ font.bold = true
87
+ font.italic = true
88
+ text = font.render("B, I, no AA",false,[200,200,200])
89
+ text.blit(screen,[0,y])
90
+ font.bold = false
91
+ font.italic = false
92
+ end
93
+
94
+ def test_bu_noaa(font,screen,y)
95
+ puts "Bold, Underline, no antialiasing..."
96
+ font.bold = true
97
+ font.underline = true
98
+ text = font.render("B, U, no AA",false,[200,200,200])
99
+ text.blit(screen,[0,y])
100
+ font.bold = false
101
+ font.underline = false
102
+ end
103
+
104
+ def test_iu_noaa(font,screen,y)
105
+ puts "Italic, Underline, no antialiasing..."
106
+ font.italic = true
107
+ font.underline = true
108
+ text = font.render("I, U, no AA",false,[200,200,200])
109
+ text.blit(screen,[0,y])
110
+ font.italic = false
111
+ font.underline = false
112
+ end
113
+
114
+ def test_bi_aa(font,screen,y)
115
+ puts "Bold, Italic, antialiasing..."
116
+ font.bold = true
117
+ font.italic = true
118
+ text = font.render("B, I, AA",true,[200,200,200])
119
+ text.blit(screen,[0,y])
120
+ font.bold = false
121
+ font.italic = false
122
+ end
123
+
124
+ def test_bu_aa(font,screen,y)
125
+ puts "Bold, Underline, antialiasing..."
126
+ font.bold = true
127
+ font.underline = true
128
+ text = font.render("B, U, AA",true,[200,200,200])
129
+ text.blit(screen,[0,y])
130
+ font.bold = false
131
+ font.underline = false
132
+ end
133
+
134
+ def test_iu_aa(font,screen,y)
135
+ puts "Italic, Underline, antialiasing..."
136
+ font.italic = true
137
+ font.underline = true
138
+ text = font.render("I, U, AA",true,[200,200,200])
139
+ text.blit(screen,[0,y])
140
+ font.italic = false
141
+ font.underline = false
142
+ end
143
+
144
+ def main
145
+ screen = Screen.set_mode([300,300])
146
+ queue = EventQueue.new()
147
+ queue.ignore = SDL_EVENTS - [QuitEvent, KeyDownEvent]
148
+
149
+
150
+ unless VERSIONS[:sdl_ttf]
151
+ raise "TTF is not usable. Bailing out."
152
+ end
153
+ TTF.setup()
154
+ font = TTF.new("FreeSans.ttf",30)
155
+
156
+ skip = font.line_skip()
157
+
158
+ screen.fill([30,70,30])
159
+ y = -skip
160
+ test_noaa_nobg(font,screen,y+=skip)
161
+ test_noaa_bg(font,screen,y+=skip)
162
+ test_aa_nobg(font,screen,y+=skip)
163
+ test_aa_bg(font,screen,y+=skip)
164
+ screen.update()
165
+
166
+ queue.wait()
167
+
168
+ screen.fill([30,70,30])
169
+ y = -skip
170
+ test_bold_noaa(font,screen,y+=skip)
171
+ test_bold_aa(font,screen,y+=skip)
172
+ test_italic_noaa(font,screen,y+=skip)
173
+ test_italic_aa(font,screen,y+=skip)
174
+ test_underline_noaa(font,screen,y+=skip)
175
+ test_underline_aa(font,screen,y+=skip)
176
+ screen.update()
177
+
178
+ queue.wait()
179
+
180
+ screen.fill([30,70,30])
181
+ y = -skip
182
+ test_bi_noaa(font,screen,y+=skip)
183
+ test_bi_aa(font,screen,y+=skip)
184
+ test_bu_noaa(font,screen,y+=skip)
185
+ test_bu_aa(font,screen,y+=skip)
186
+ test_iu_noaa(font,screen,y+=skip)
187
+ test_iu_aa(font,screen,y+=skip)
188
+ screen.update()
189
+
190
+ queue.wait()
191
+ end
192
+
193
+ main()
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Original script was contributed by ageldama (Yun, Jonghyouk)
4
+
5
+ require 'encoding/character/utf-8'
6
+ require 'rubygame'
7
+
8
+ # Initialize Rubygame
9
+ Rubygame.init
10
+ screen = Rubygame::Screen.set_mode([320,200])
11
+ queue = Rubygame::EventQueue.new
12
+
13
+ # Initialize fonts
14
+
15
+ fontname = 'FreeSans.ttf'
16
+ str = u'abc123하이~'
17
+ if ARGV[0]
18
+ if File.exist?(File.expand_path(ARGV[0]))
19
+ fontname = File.expand_path(ARGV[0])
20
+ str = ARGV[1..-1].join(" ")
21
+ else
22
+ str = ARGV[0..-1].join(" ")
23
+ end
24
+ else
25
+ puts <<EOF
26
+ This script demonstrates UTF8 (8-bit Unicode Transformation Format) text
27
+ rendered with TTF fonts. This allows you to display international symbols
28
+ in your games.
29
+
30
+ If you like, you can give some arguments to this script to try it out:
31
+ 1) A path to a different TTF font to use. (optional)
32
+ *) A custom string to display.
33
+ EOF
34
+ end
35
+
36
+ Rubygame::TTF.setup
37
+ fnt = Rubygame::TTF.new(fontname, 20)
38
+
39
+ loop do
40
+ queue.each do |event|
41
+ case event
42
+ when Rubygame::KeyDownEvent
43
+ Rubygame::TTF.quit
44
+ Rubygame.quit
45
+ exit
46
+ end
47
+ end
48
+
49
+ screen.fill([0, 0, 0])
50
+ surf_str = fnt.render_utf8(str, true, [0xff, 0xff, 0xff])
51
+ surf_str.blit(screen, [10, 10])
52
+ screen.update
53
+ end
data/samples/fist.bmp ADDED
Binary file
@@ -0,0 +1,22 @@
1
+ #/usr/bin/env ruby
2
+
3
+ # A very basic sample application.
4
+
5
+ require "rubygame"
6
+ include Rubygame
7
+
8
+ Rubygame.init
9
+
10
+ screen = Screen.set_mode([320,240])
11
+
12
+ queue = EventQueue.new() {
13
+ |q| q.ignore = [MouseMotionEvent, ActiveEvent]
14
+ }
15
+
16
+ image = Surface.load_image("panda.png")
17
+ puts "Size is: [%s,%s]"%image.size
18
+ image.blit(screen,[0,0])
19
+
20
+ queue.wait() { screen.update() }
21
+
22
+ Rubygame.quit
data/samples/panda.png ADDED
Binary file
data/samples/punch.wav ADDED
Binary file
data/samples/ruby.png ADDED
Binary file
Binary file
data/samples/whiff.wav ADDED
Binary file
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: rubygame
5
+ version: !ruby/object:Gem::Version
6
+ version: 2.1.0
7
+ date: 2007-11-19 00:00:00 -06:00
8
+ summary: Clean and powerful library for game programming
9
+ require_paths:
10
+ - lib
11
+ - lib/rubygame/
12
+ - ext/rubygame/
13
+ email: jacius@users.sourceforge.net
14
+ homepage: http://rubygame.sourceforge.net/
15
+ rubyforge_project:
16
+ description:
17
+ autorequire: rubygame.rb
18
+ default_executable:
19
+ bindir: bin
20
+ has_rdoc: true
21
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
22
+ requirements:
23
+ - - ">"
24
+ - !ruby/object:Gem::Version
25
+ version: 0.0.0
26
+ version:
27
+ platform: ruby
28
+ signing_key:
29
+ cert_chain:
30
+ post_install_message:
31
+ authors:
32
+ - John Croisant
33
+ files:
34
+ - lib/rubygame.rb
35
+ - lib/rubygame
36
+ - lib/rubygame/MANIFEST
37
+ - lib/rubygame/ftor.rb
38
+ - lib/rubygame/clock.rb
39
+ - lib/rubygame/constants.rb
40
+ - lib/rubygame/event.rb
41
+ - lib/rubygame/rect.rb
42
+ - lib/rubygame/mediabag.rb
43
+ - lib/rubygame/sprite.rb
44
+ - lib/rubygame/keyconstants.rb
45
+ - lib/rubygame/hotspot.rb
46
+ - lib/rubygame/sfont.rb
47
+ - lib/rubygame/queue.rb
48
+ - ext/rubygame
49
+ - ext/rubygame/rubygame_event.h
50
+ - ext/rubygame/rubygame_mixer.c
51
+ - ext/rubygame/rubygame_ttf.h
52
+ - ext/rubygame/rubygame_main.c
53
+ - ext/rubygame/rubygame_joystick.h
54
+ - ext/rubygame/MANIFEST
55
+ - ext/rubygame/rubygame_gfx.h
56
+ - ext/rubygame/rubygame_shared.c
57
+ - ext/rubygame/rubygame_gl.h
58
+ - ext/rubygame/rubygame_screen.c
59
+ - ext/rubygame/rubygame_shared.h
60
+ - ext/rubygame/rubygame_time.c
61
+ - ext/rubygame/rubygame_image.h
62
+ - ext/rubygame/rubygame_surface.h
63
+ - ext/rubygame/rubygame_screen.h
64
+ - ext/rubygame/rubygame_time.h
65
+ - ext/rubygame/rubygame_joystick.c
66
+ - ext/rubygame/rubygame_surface.c
67
+ - ext/rubygame/rubygame_main.h
68
+ - ext/rubygame/rubygame_gfx.c
69
+ - ext/rubygame/rubygame_event.c
70
+ - ext/rubygame/rubygame_ttf.c
71
+ - ext/rubygame/rubygame_gl.c
72
+ - ext/rubygame/rubygame_mixer.h
73
+ - ext/rubygame/rubygame_image.c
74
+ - samples/demo_utf8.rb
75
+ - samples/README
76
+ - samples/GPL.txt
77
+ - samples/demo_music.rb
78
+ - samples/whiff.wav
79
+ - samples/demo_rubygame.rb
80
+ - samples/demo_gl.rb
81
+ - samples/chimp.bmp
82
+ - samples/term16.png
83
+ - samples/chimp.rb
84
+ - samples/demo_ttf.rb
85
+ - samples/panda.png
86
+ - samples/punch.wav
87
+ - samples/FreeSans.ttf
88
+ - samples/demo_sfont.rb
89
+ - samples/demo_gl_tex.rb
90
+ - samples/ruby.png
91
+ - samples/load_and_blit.rb
92
+ - samples/fist.bmp
93
+ - doc/windows_install.rdoc
94
+ - doc/macosx_install.rdoc
95
+ - doc/getting_started.rdoc
96
+ - doc/extended_readme.rdoc
97
+ - README
98
+ - LICENSE
99
+ - CREDITS
100
+ - TODO
101
+ - Changelog
102
+ test_files: []
103
+
104
+ rdoc_options: []
105
+
106
+ extra_rdoc_files:
107
+ - doc/windows_install.rdoc
108
+ - doc/macosx_install.rdoc
109
+ - doc/getting_started.rdoc
110
+ - doc/extended_readme.rdoc
111
+ - README
112
+ - LICENSE
113
+ - CREDITS
114
+ - TODO
115
+ - Changelog
116
+ executables: []
117
+
118
+ extensions:
119
+ - Rakefile
120
+ requirements: []
121
+
122
+ dependencies: []
123
+