rubygame 2.3.0-x86-linux
Sign up to get free protection for your applications and to get access to all the features.
- data/CREDITS +60 -0
- data/LICENSE +504 -0
- data/NEWS +252 -0
- data/README +123 -0
- data/ROADMAP +109 -0
- data/Rakefile +438 -0
- data/doc/extended_readme.rdoc +49 -0
- data/doc/getting_started.rdoc +47 -0
- data/doc/macosx_install.rdoc +70 -0
- data/doc/windows_install.rdoc +123 -0
- data/ext/rubygame/rubygame_core.so +0 -0
- data/ext/rubygame/rubygame_event.c +644 -0
- data/ext/rubygame/rubygame_event.h +48 -0
- data/ext/rubygame/rubygame_event.o +0 -0
- data/ext/rubygame/rubygame_gfx.c +942 -0
- data/ext/rubygame/rubygame_gfx.h +101 -0
- data/ext/rubygame/rubygame_gfx.o +0 -0
- data/ext/rubygame/rubygame_gfx.so +0 -0
- data/ext/rubygame/rubygame_gl.c +154 -0
- data/ext/rubygame/rubygame_gl.h +32 -0
- data/ext/rubygame/rubygame_gl.o +0 -0
- data/ext/rubygame/rubygame_image.c +252 -0
- data/ext/rubygame/rubygame_image.h +41 -0
- data/ext/rubygame/rubygame_image.o +0 -0
- data/ext/rubygame/rubygame_image.so +0 -0
- data/ext/rubygame/rubygame_joystick.c +247 -0
- data/ext/rubygame/rubygame_joystick.h +41 -0
- data/ext/rubygame/rubygame_joystick.o +0 -0
- data/ext/rubygame/rubygame_main.c +155 -0
- data/ext/rubygame/rubygame_main.h +36 -0
- data/ext/rubygame/rubygame_main.o +0 -0
- data/ext/rubygame/rubygame_mixer.c +1024 -0
- data/ext/rubygame/rubygame_mixer.h +36 -0
- data/ext/rubygame/rubygame_mixer.o +0 -0
- data/ext/rubygame/rubygame_mixer.so +0 -0
- data/ext/rubygame/rubygame_music.c +1017 -0
- data/ext/rubygame/rubygame_music.h +29 -0
- data/ext/rubygame/rubygame_music.o +0 -0
- data/ext/rubygame/rubygame_screen.c +448 -0
- data/ext/rubygame/rubygame_screen.h +43 -0
- data/ext/rubygame/rubygame_screen.o +0 -0
- data/ext/rubygame/rubygame_shared.c +272 -0
- data/ext/rubygame/rubygame_shared.h +68 -0
- data/ext/rubygame/rubygame_shared.o +0 -0
- data/ext/rubygame/rubygame_sound.c +863 -0
- data/ext/rubygame/rubygame_sound.h +29 -0
- data/ext/rubygame/rubygame_sound.o +0 -0
- data/ext/rubygame/rubygame_surface.c +1151 -0
- data/ext/rubygame/rubygame_surface.h +62 -0
- data/ext/rubygame/rubygame_surface.o +0 -0
- data/ext/rubygame/rubygame_time.c +183 -0
- data/ext/rubygame/rubygame_time.h +32 -0
- data/ext/rubygame/rubygame_time.o +0 -0
- data/ext/rubygame/rubygame_ttf.c +599 -0
- data/ext/rubygame/rubygame_ttf.h +69 -0
- data/ext/rubygame/rubygame_ttf.o +0 -0
- data/ext/rubygame/rubygame_ttf.so +0 -0
- data/lib/rubygame.rb +41 -0
- data/lib/rubygame/clock.rb +128 -0
- data/lib/rubygame/color.rb +79 -0
- data/lib/rubygame/color/models/base.rb +111 -0
- data/lib/rubygame/color/models/hsl.rb +153 -0
- data/lib/rubygame/color/models/hsv.rb +149 -0
- data/lib/rubygame/color/models/rgb.rb +78 -0
- data/lib/rubygame/color/palettes/css.rb +49 -0
- data/lib/rubygame/color/palettes/palette.rb +100 -0
- data/lib/rubygame/color/palettes/x11.rb +177 -0
- data/lib/rubygame/constants.rb +238 -0
- data/lib/rubygame/event.rb +313 -0
- data/lib/rubygame/ftor.rb +370 -0
- data/lib/rubygame/hotspot.rb +265 -0
- data/lib/rubygame/keyconstants.rb +237 -0
- data/lib/rubygame/mediabag.rb +94 -0
- data/lib/rubygame/named_resource.rb +254 -0
- data/lib/rubygame/queue.rb +288 -0
- data/lib/rubygame/rect.rb +612 -0
- data/lib/rubygame/sfont.rb +223 -0
- data/lib/rubygame/sprite.rb +511 -0
- data/samples/FreeSans.ttf +0 -0
- data/samples/GPL.txt +340 -0
- data/samples/README +40 -0
- data/samples/chimp.bmp +0 -0
- data/samples/chimp.rb +302 -0
- data/samples/demo_gl.rb +151 -0
- data/samples/demo_gl_tex.rb +197 -0
- data/samples/demo_music.rb +77 -0
- data/samples/demo_rubygame.rb +296 -0
- data/samples/demo_sfont.rb +52 -0
- data/samples/demo_ttf.rb +193 -0
- data/samples/demo_utf8.rb +53 -0
- data/samples/fist.bmp +0 -0
- data/samples/load_and_blit.rb +22 -0
- data/samples/panda.png +0 -0
- data/samples/punch.wav +0 -0
- data/samples/ruby.png +0 -0
- data/samples/song.ogg +0 -0
- data/samples/term16.png +0 -0
- data/samples/whiff.wav +0 -0
- data/test/audio_spec.rb +236 -0
- data/test/color_spec.rb +544 -0
- data/test/image.png +0 -0
- data/test/music_spec.rb +727 -0
- data/test/named_resource_spec.rb +211 -0
- data/test/short.ogg +0 -0
- data/test/sound_spec.rb +564 -0
- data/test/surface_spec.rb +219 -0
- data/test/test_crop.rb +45 -0
- data/test/test_rect.rb +841 -0
- metadata +174 -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)
|
data/samples/demo_ttf.rb
ADDED
@@ -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
|
data/samples/song.ogg
ADDED
Binary file
|
data/samples/term16.png
ADDED
Binary file
|
data/samples/whiff.wav
ADDED
Binary file
|
data/test/audio_spec.rb
ADDED
@@ -0,0 +1,236 @@
|
|
1
|
+
|
2
|
+
require 'rubygame'
|
3
|
+
|
4
|
+
|
5
|
+
#########################
|
6
|
+
## ##
|
7
|
+
## GENERAL ##
|
8
|
+
## ##
|
9
|
+
#########################
|
10
|
+
|
11
|
+
|
12
|
+
describe "Opening audio for the first time" do
|
13
|
+
after :each do
|
14
|
+
Rubygame.close_audio
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return true" do
|
18
|
+
Rubygame.open_audio.should be_true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
describe "Opening audio when it's already open" do
|
24
|
+
before :each do
|
25
|
+
Rubygame.open_audio
|
26
|
+
end
|
27
|
+
|
28
|
+
after :each do
|
29
|
+
Rubygame.close_audio
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should return false" do
|
33
|
+
Rubygame.open_audio.should be_false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
describe "Opening audio that was opened then closed again" do
|
39
|
+
before :each do
|
40
|
+
Rubygame.open_audio
|
41
|
+
Rubygame.close_audio
|
42
|
+
end
|
43
|
+
|
44
|
+
after :each do
|
45
|
+
Rubygame.close_audio
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should return true" do
|
49
|
+
Rubygame.open_audio.should be_true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
describe "Opening audio with invalid argument" do
|
55
|
+
after :each do
|
56
|
+
Rubygame.close_audio
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should raise TypeError" do
|
60
|
+
lambda{ Rubygame.open_audio(:foo) }.should raise_error(TypeError)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
describe "Closing audio that was open" do
|
66
|
+
before :each do
|
67
|
+
Rubygame.open_audio
|
68
|
+
end
|
69
|
+
|
70
|
+
after :each do
|
71
|
+
Rubygame.close_audio
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should return true" do
|
75
|
+
Rubygame.close_audio.should be_true
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
describe "Closing audio that was not open" do
|
81
|
+
before :each do
|
82
|
+
end
|
83
|
+
|
84
|
+
after :each do
|
85
|
+
Rubygame.close_audio
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should return false" do
|
89
|
+
Rubygame.close_audio.should be_false
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
#########################
|
96
|
+
## ##
|
97
|
+
## FREQUENCY ##
|
98
|
+
## ##
|
99
|
+
#########################
|
100
|
+
|
101
|
+
|
102
|
+
describe "Opening audio with a valid frequency" do
|
103
|
+
after :each do
|
104
|
+
Rubygame.close_audio
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should not raise an error" do
|
108
|
+
lambda{ Rubygame.open_audio(:frequency => 44100) }.should_not raise_error
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
describe "Opening audio with a negative frequency" do
|
114
|
+
after :each do
|
115
|
+
Rubygame.close_audio
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should raise ArgumentError" do
|
119
|
+
lambda{ Rubygame.open_audio(:frequency => -1) }.should raise_error(ArgumentError)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
describe "Opening audio with a frequency of zero" do
|
125
|
+
after :each do
|
126
|
+
Rubygame.close_audio
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should raise ArgumentError" do
|
130
|
+
lambda{ Rubygame.open_audio(:frequency => 0) }.should raise_error(ArgumentError)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
#########################
|
137
|
+
## ##
|
138
|
+
## CHANNELS ##
|
139
|
+
## ##
|
140
|
+
#########################
|
141
|
+
|
142
|
+
|
143
|
+
describe "Opening audio with 1 channel (mono)" do
|
144
|
+
after :each do
|
145
|
+
Rubygame.close_audio
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should not raise an error" do
|
149
|
+
lambda{ Rubygame.open_audio(:channels => 1) }.should_not raise_error
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
|
154
|
+
describe "Opening audio with 2 channels (stereo)" do
|
155
|
+
after :each do
|
156
|
+
Rubygame.close_audio
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should not raise an error" do
|
160
|
+
lambda{ Rubygame.open_audio(:channels => 2) }.should_not raise_error
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
describe "Opening audio with a too-small number of channels" do
|
166
|
+
after :each do
|
167
|
+
Rubygame.close_audio
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should raise ArgumentError" do
|
171
|
+
lambda{ Rubygame.open_audio(:channels => 0) }.should raise_error(ArgumentError)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
describe "Opening audio with a too-large number of channels" do
|
177
|
+
after :each do
|
178
|
+
Rubygame.close_audio
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should raise ArgumentError" do
|
182
|
+
lambda{ Rubygame.open_audio(:channels => 3) }.should raise_error(ArgumentError)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
#########################
|
189
|
+
## ##
|
190
|
+
## FREQUENCY ##
|
191
|
+
## ##
|
192
|
+
#########################
|
193
|
+
|
194
|
+
|
195
|
+
describe "Opening audio with a valid buffer size" do
|
196
|
+
after :each do
|
197
|
+
Rubygame.close_audio
|
198
|
+
end
|
199
|
+
|
200
|
+
it "should not raise an error" do
|
201
|
+
lambda{ Rubygame.open_audio(:buffer => 512) }.should_not raise_error
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
|
206
|
+
describe "Opening audio with a non-power-of-two buffer size" do
|
207
|
+
after :each do
|
208
|
+
Rubygame.close_audio
|
209
|
+
end
|
210
|
+
|
211
|
+
it "should raise ArgumentError" do
|
212
|
+
lambda{ Rubygame.open_audio(:buffer => 511) }.should raise_error(ArgumentError)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
|
217
|
+
describe "Opening audio with a negative buffer size" do
|
218
|
+
after :each do
|
219
|
+
Rubygame.close_audio
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should raise ArgumentError" do
|
223
|
+
lambda{ Rubygame.open_audio(:buffer => -1) }.should raise_error(ArgumentError)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
|
228
|
+
describe "Opening audio with a buffer of zero" do
|
229
|
+
after :each do
|
230
|
+
Rubygame.close_audio
|
231
|
+
end
|
232
|
+
|
233
|
+
it "should raise ArgumentError" do
|
234
|
+
lambda{ Rubygame.open_audio(:buffer => 0) }.should raise_error(ArgumentError)
|
235
|
+
end
|
236
|
+
end
|