rubysdl-mswin32-1.9 2.1.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 (81) hide show
  1. data/NEWS.en +280 -0
  2. data/NEWS.ja +291 -0
  3. data/README.en +118 -0
  4. data/README.en.win32 +77 -0
  5. data/README.ja +166 -0
  6. data/README.ja.win32 +80 -0
  7. data/dll/SDL.dll +0 -0
  8. data/dll/SDL_image.dll +0 -0
  9. data/dll/SDL_mixer.dll +0 -0
  10. data/dll/SDL_ttf.dll +0 -0
  11. data/dll/SGE.dll +0 -0
  12. data/dll/jpeg.dll +0 -0
  13. data/dll/libcharset-1.dll +0 -0
  14. data/dll/libfreetype-6.dll +0 -0
  15. data/dll/libiconv-2.dll +0 -0
  16. data/dll/libogg-0.dll +0 -0
  17. data/dll/libpng12-0.dll +0 -0
  18. data/dll/libtiff-3.dll +0 -0
  19. data/dll/libvorbis-0.dll +0 -0
  20. data/dll/libvorbisfile-3.dll +0 -0
  21. data/dll/smpeg.dll +0 -0
  22. data/dll/zlib1.dll +0 -0
  23. data/doc/cdrom.rd +305 -0
  24. data/doc/collision.rd +121 -0
  25. data/doc/event.rd +1090 -0
  26. data/doc/font.rd +625 -0
  27. data/doc/general.rd +60 -0
  28. data/doc/init.rd +142 -0
  29. data/doc/joystick.rd +301 -0
  30. data/doc/mixer.rd +584 -0
  31. data/doc/mpeg.rd +420 -0
  32. data/doc/opengl.rd +144 -0
  33. data/doc/rsd.rb +158 -0
  34. data/doc/sdlskk.rd +404 -0
  35. data/doc/time.rd +34 -0
  36. data/doc/video.rd +2269 -0
  37. data/doc/wm.rd +78 -0
  38. data/ext/opengl.so +0 -0
  39. data/ext/sdl.so +0 -0
  40. data/install_rubysdl.rb +30 -0
  41. data/lib/rubysdl_aliases.rb +303 -0
  42. data/lib/rubysdl_compatible_ver1.rb +243 -0
  43. data/lib/sdl.rb +224 -0
  44. data/rubysdl_doc_old.en.rd +2181 -0
  45. data/rubysdl_doc_old.rd +2402 -0
  46. data/rubysdl_ref.html +5888 -0
  47. data/rubysdl_ref.rd +6577 -0
  48. data/sample/aadraw.rb +24 -0
  49. data/sample/alpha.rb +26 -0
  50. data/sample/alphadraw.rb +25 -0
  51. data/sample/bfont.rb +24 -0
  52. data/sample/caption.rb +21 -0
  53. data/sample/cdrom.rb +24 -0
  54. data/sample/collision.rb +97 -0
  55. data/sample/cursor.bmp +0 -0
  56. data/sample/cursor.rb +22 -0
  57. data/sample/ellipses.rb +39 -0
  58. data/sample/event2.rb +34 -0
  59. data/sample/font.bmp +0 -0
  60. data/sample/font.rb +26 -0
  61. data/sample/fpstimer.rb +175 -0
  62. data/sample/icon.bmp +0 -0
  63. data/sample/icon.bmp.gz +0 -0
  64. data/sample/icon.png +0 -0
  65. data/sample/joy2.rb +81 -0
  66. data/sample/kanji.rb +36 -0
  67. data/sample/load_from_io.rb +45 -0
  68. data/sample/movesp.rb +94 -0
  69. data/sample/playmod.rb +13 -0
  70. data/sample/plaympeg.rb +44 -0
  71. data/sample/playwave.rb +15 -0
  72. data/sample/randrect.rb +40 -0
  73. data/sample/sample.ttf +0 -0
  74. data/sample/sdl.rb +33 -0
  75. data/sample/sdlskk.rb +70 -0
  76. data/sample/sgetest.rb +33 -0
  77. data/sample/stetris.rb +274 -0
  78. data/sample/testgl.rb +165 -0
  79. data/sample/testsprite.rb +69 -0
  80. data/sample/transformblit.rb +42 -0
  81. metadata +134 -0
Binary file
Binary file
Binary file
@@ -0,0 +1,81 @@
1
+ #
2
+ # Usage:
3
+ # ruby joy2.rb [n]
4
+ # n: if given, use n'th joystick
5
+ # if not given, show all connected joystick
6
+ #
7
+ require 'sdl'
8
+
9
+ White = [255,255,255]
10
+
11
+ def print_joystick_info
12
+ for i in 0..SDL::Joystick.num-1
13
+ print i,":",SDL::Joystick.index_name(0),"\n"
14
+ end
15
+ end
16
+
17
+ def display_button_state ( screen, joy )
18
+ for i in 0..joy.num_buttons-1
19
+ if joy.button(i) then
20
+ screen.fill_rect( i*30+30, 50, 10, 10, [0,0,128] )
21
+ else
22
+ screen.fill_rect( i*30+30, 50, 10, 10, White )
23
+ end
24
+ end
25
+ end
26
+
27
+ def display_hat_state ( screen, joy )
28
+ # display the state of only first hat
29
+ if joy.num_hats > 0 then
30
+ x = y = 0
31
+ x = 1 if ( joy.hat(0) & SDL::Joystick::HAT_RIGHT ) != 0
32
+ x = -1 if ( joy.hat(0) & SDL::Joystick::HAT_LEFT ) != 0
33
+ y = 1 if ( joy.hat(0) & SDL::Joystick::HAT_DOWN ) != 0
34
+ y = -1 if ( joy.hat(0) & SDL::Joystick::HAT_UP ) != 0
35
+ screen.fill_rect( 450 + x*40, 200 + y*40, 10, 10, White )
36
+ end
37
+ end
38
+
39
+ def display_axis_state ( screen, joy )
40
+ for i in 0..joy.num_axes-1
41
+ screen.fill_rect( i*30+130, joy.axis(i)*100/32768+200, 20, 20, White )
42
+ end
43
+ end
44
+
45
+ SDL.init( SDL::INIT_VIDEO|SDL::INIT_JOYSTICK )
46
+ screen = SDL::Screen.open(640, 480, 16, SDL::SWSURFACE)
47
+
48
+ if SDL::Joystick.num == 0 then
49
+ print "No joystick available\n"
50
+ exit
51
+ end
52
+
53
+ if ARGV.size == 0 then
54
+ print_joystick_info
55
+ exit
56
+ end
57
+
58
+ joynum = ARGV[0].to_i
59
+
60
+ if SDL::Joystick.num < joynum then
61
+ print "Joystick No.#{joynum} is not available\n"
62
+ exit
63
+ end
64
+
65
+ joy=SDL::Joystick.open(joynum)
66
+
67
+ while true
68
+
69
+ while event = SDL::Event.poll
70
+ case event
71
+ when SDL::Event::KeyDown, SDL::Event::Quit
72
+ exit
73
+ end
74
+ end
75
+ SDL::Joystick.update_all
76
+ screen.fill_rect(0,0,640,480,[0,0,0])
77
+ display_button_state screen, joy
78
+ display_hat_state screen, joy
79
+ display_axis_state screen, joy
80
+ screen.update_rect(0, 0, 0, 0)
81
+ end
@@ -0,0 +1,36 @@
1
+ #!/usr/local/bin/ruby -Ke
2
+ #
3
+ # This sample needs following two bdf files
4
+ # 8x16.bdf : alphabets
5
+ # jiskan16.bdf : chinese characters and kana
6
+ #
7
+ require 'sdl'
8
+
9
+ SDL.init( SDL::INIT_VIDEO )
10
+ screen = SDL::Screen.open(640,480,16,SDL::SWSURFACE)
11
+
12
+ font = SDL::Kanji.open("8x16.bdf",16)
13
+ font.add("jiskan16.bdf")
14
+ font.set_coding_system(SDL::Kanji::EUC)
15
+
16
+ y = 0
17
+ x = 0
18
+
19
+ while true
20
+ while event = SDL::Event.poll
21
+ case event
22
+ when SDL::Event::KeyDown, SDL::Event::Quit
23
+ exit
24
+ end
25
+ end
26
+ screen.fill_rect(0,0,640,480,0)
27
+
28
+ y = (y + 1) % 480
29
+ x = (x + 1) % 640
30
+
31
+ font.put(screen,"SDL Kanji�Υƥ�����",40,y,128,128,0)
32
+ font.put_tate(screen,"�Ľ񤭤�Ǥ��ޤ���",x,60,128,128,0)
33
+
34
+ screen.update_rect(0,0,0,0)
35
+ sleep 0.005
36
+ end
@@ -0,0 +1,45 @@
1
+ #
2
+ # Test for rwops
3
+ #
4
+ # This sample needs
5
+ # track01.ogg: Ogg Vorbis file
6
+
7
+ require 'sdl'
8
+ require 'stringio'
9
+ require 'zlib'
10
+
11
+ SDL.init( SDL::INIT_VIDEO|SDL::INIT_AUDIO )
12
+ SDL::Mixer.open(22050)
13
+
14
+ screen = SDL::setVideoMode(640,480,16,SDL::SWSURFACE)
15
+ SDL::WM::setCaption('from_str.rb','from_str.rb')
16
+
17
+ str = File.read("icon.bmp")
18
+ img = SDL::Surface.loadBMPFromIO(StringIO.new(str))
19
+ img2 = File.open("icon.bmp", "rb"){|f| SDL::Surface.loadBMPFromIO(f) }
20
+ img3 = Zlib::GzipReader.open("icon.bmp.gz"){|f| SDL::Surface.loadBMPFromIO(f) }
21
+ img4 = File.open("icon.png", "rb"){|f| SDL::Surface.loadFromIO(f) }
22
+
23
+ #mus = SDL::Mixer::Music.loadFromString(File.read("track01.ogg"))
24
+ mus = SDL::Mixer::Music.load("track01.ogg")
25
+ wav = File.open('sample.wav', "rb"){|f| SDL::Mixer::Wave.loadFromIO(f) }
26
+
27
+ SDL.blitSurface(img,0,0,32,32,screen,100,100)
28
+ SDL.blitSurface(img2,0,0,32,32,screen,200,100)
29
+ SDL.blitSurface(img3,0,0,32,32,screen,300,100)
30
+ SDL.blitSurface(img4,0,0,32,32,screen,400,100)
31
+ screen.updateRect(0, 0, 0, 0)
32
+
33
+ SDL::Mixer.playMusic(mus, -1)
34
+ SDL::Mixer.playChannel(0, wav, 0)
35
+
36
+ while true
37
+ while event = SDL::Event2.poll
38
+ case event
39
+ when SDL::Event2::KeyDown, SDL::Event2::Quit
40
+ exit
41
+ end
42
+ end
43
+
44
+ sleep 0.1
45
+ end
@@ -0,0 +1,94 @@
1
+ require 'sdl'
2
+
3
+ SDL.init(SDL::INIT_VIDEO)
4
+
5
+ screen = SDL::Screen.open(640,480,16,SDL::SWSURFACE)
6
+
7
+ image = SDL::Surface.load_bmp("icon.bmp")
8
+ image.set_color_key( SDL::SRCCOLORKEY || SDL::RLEACCEL ,0)
9
+ $image = image.display_format
10
+
11
+
12
+ class Sprite
13
+ def initialize
14
+ @x=rand(640)
15
+ @y=rand(480)
16
+ @dx=rand(11)-5
17
+ @dy=rand(11)-5
18
+ end
19
+
20
+ def move
21
+ @x += @dx
22
+ if @x >= 640 then
23
+ @dx *= -1
24
+ @x = 639
25
+ end
26
+ if @x < 0 then
27
+ @dx *= -1
28
+ @x = 0
29
+ end
30
+ @y += @dy
31
+ if @y >= 480 then
32
+ @dy *= -1
33
+ @y = 479
34
+ end
35
+ @y += @dy
36
+ if @y < 0 then
37
+ @dy *= -1
38
+ @y = 0
39
+ end
40
+ end
41
+
42
+ def draw(screen)
43
+ SDL::Surface.blit($image,0,0,32,32,screen,@x,@y)
44
+ end
45
+
46
+ end
47
+
48
+ sprites = []
49
+ for i in 1..5
50
+ sprites << Sprite.new
51
+ end
52
+
53
+ class MovableSp
54
+ def initialize()
55
+ @ud=@lr=0;
56
+ end
57
+
58
+ def move()
59
+ @ud=@lr=0;
60
+ @lr=-1 if SDL::Key.press?(SDL::Key::H) or SDL::Key.press?(SDL::Key::LEFT)
61
+ @lr=1 if SDL::Key.press?(SDL::Key::L) or SDL::Key.press?(SDL::Key::RIGHT)
62
+ @ud=1 if SDL::Key.press?(SDL::Key::J) or SDL::Key.press?(SDL::Key::DOWN)
63
+ @ud=-1 if SDL::Key.press?(SDL::Key::K) or SDL::Key.press?(SDL::Key::UP)
64
+ end
65
+
66
+ def draw(screen)
67
+ SDL::Surface.blit($image,0,0,32,32,screen,300+@lr*50,200+@ud*50)
68
+ end
69
+ end
70
+
71
+ sprites << MovableSp.new
72
+ black = screen.format.map_rgb(0, 0, 0)
73
+
74
+ while true
75
+ while event = SDL::Event.poll
76
+ case event
77
+ when SDL::Event::Quit
78
+ exit
79
+ when SDL::Event::KeyDown
80
+ exit if event.sym == SDL::Key::ESCAPE
81
+ end
82
+ end
83
+
84
+ screen.fill_rect(0,0,640,480,black)
85
+ SDL::Key.scan
86
+
87
+ sprites.each {|i|
88
+ i.move
89
+ i.draw(screen)
90
+ }
91
+ screen.update_rect(0,0,0,0)
92
+ end
93
+
94
+
@@ -0,0 +1,13 @@
1
+ # This sample needs a mod file `sample.it'.
2
+ #
3
+ require 'sdl'
4
+ SDL::init(SDL::INIT_AUDIO)
5
+
6
+ SDL::Mixer.open(22050)
7
+ music = SDL::Mixer::Music.load("sample.it")
8
+
9
+ SDL::Mixer.play_music(music,0)
10
+
11
+ while SDL::Mixer::play_music?
12
+ sleep 1
13
+ end
@@ -0,0 +1,44 @@
1
+ # This sample needs a MPEG file `sample.mpg'.
2
+ require 'sdl'
3
+
4
+ SDL.init( SDL::INIT_VIDEO|SDL::INIT_AUDIO )
5
+ SDL::Mixer.open
6
+
7
+ screen = SDL::Screen.open( 320, 240, 16, SDL::SWSURFACE )
8
+
9
+ mpeg = SDL::MPEG.load( 'sample.mpg' )
10
+
11
+ info = mpeg.info
12
+
13
+ p(info)
14
+
15
+ mpeg.enable_audio true
16
+ mpeg.enable_video true
17
+
18
+ mpeg.set_display(screen)
19
+ mpeg.set_display_region( 0, 0, screen.w, screen.h )
20
+ mpeg.play
21
+
22
+ loop do
23
+
24
+ case event = SDL::Event.poll
25
+ when SDL::Event::Quit
26
+ mpeg.stop
27
+ exit
28
+ when SDL::Event::KeyDown
29
+ case event.sym
30
+ when SDL::Key::S
31
+ mpeg.stop
32
+ when SDL::Key::P
33
+ mpeg.play
34
+ when SDL::Key::R
35
+ mpeg.rewind
36
+ mpeg.play
37
+ when SDL::Key::ESCAPE
38
+ exit
39
+ end
40
+ end
41
+
42
+ sleep 0.1
43
+
44
+ end
@@ -0,0 +1,15 @@
1
+ # This sample needs a wave file `sample.wav', please prepare.
2
+ require 'sdl'
3
+
4
+ SDL::init(SDL::INIT_AUDIO)
5
+
6
+ SDL::Mixer.open(22050, SDL::Mixer::DEFAULT_FORMAT, 2, 512)
7
+ wave = SDL::Mixer::Wave.load("sample.wav")
8
+
9
+ SDL::Mixer.play_channel(0, wave, 0)
10
+
11
+ while SDL::Mixer.play?(0)
12
+ sleep 1
13
+ end
14
+
15
+
@@ -0,0 +1,40 @@
1
+ # SDL random rect sample
2
+ # original code by adas@geocities.co.jp written by C
3
+ # auther TAMURA Kenichi <sgs02516@nifty.com>
4
+ #
5
+ require 'sdl'
6
+
7
+ src_w = 640
8
+ src_h = 480
9
+ src_d = 16
10
+
11
+ dst_w = 0
12
+ dst_h = 0
13
+
14
+ MAX = 1000
15
+ RECTSIZE = 400
16
+
17
+ SDL.init SDL::INIT_VIDEO
18
+ screen = SDL::setVideoMode src_w,src_h,src_d, SDL::SWSURFACE|SDL::ANYFORMAT
19
+
20
+ srand
21
+
22
+ (1 .. MAX).each do |i|
23
+ color = screen.mapRGB rand(256),rand(256),rand(256)
24
+ dst_w = rand(RECTSIZE) + 1
25
+ dst_h = rand(RECTSIZE) + 1
26
+ screen.fillRect rand(src_w-dst_w), rand(src_h-dst_h), dst_w, dst_h, color
27
+ screen.updateRect 0,0,0,0
28
+
29
+ while event = SDL::Event2.poll
30
+ case event
31
+ when SDL::Event2::Quit
32
+ exit
33
+ when SDL::Event2::KeyDown
34
+ exit if event.sym == SDL::Key::ESCAPE
35
+ end
36
+ end
37
+
38
+ SDL::Key.scan
39
+ end
40
+
Binary file
@@ -0,0 +1,33 @@
1
+ require 'rubysdl'
2
+
3
+ printf "%d \n" , SDL::INIT_TIMER | SDL::INIT_VIDEO
4
+
5
+ SDL.init(SDL::INIT_TIMER | SDL::INIT_VIDEO )
6
+ screen = SDL::Screen.setVideoMode(640,480,16,SDL::SWSURFACE)
7
+ exit if screen == nil
8
+
9
+ sprite = SDL::Surface.loadBMP("icon.bmp")
10
+ sprite.setColorKey( 0x00001000 | 0x00002000 ,0)
11
+ sprite = sprite.displayFormat
12
+
13
+
14
+ screen.fillRect(100,100,100,100,678432)
15
+ SDL.blitSurface(sprite,0,0,32,32,screen,0,0)
16
+ screen.updateRect(0,0,640,480)
17
+ event = SDL::Event.new
18
+
19
+ while true
20
+ if event.pollEvent != 0 then
21
+ if event.type==SDL::Event::QUIT then
22
+ break
23
+ end
24
+ if event.type==SDL::Event::KEYDOWN then
25
+ break
26
+ end
27
+ end
28
+ end
29
+
30
+
31
+
32
+
33
+
@@ -0,0 +1,70 @@
1
+ #
2
+ # SDLSKK from Ruby/SDL
3
+ #
4
+ # This sample needs three files.
5
+ # jisyo : SKK's dictionary
6
+ # rule_table : SDLSKK's
7
+ # nihongo.ttf : True Type Font file that has Japanese characters
8
+ #
9
+ # Usage:
10
+ # ruby sdlskk.rb [-m]
11
+ #
12
+ # -m Use minibuffer
13
+ #
14
+ require 'sdl'
15
+
16
+ use_minibuffer = (ARGV[0]=='-m')
17
+
18
+ SDL.init( SDL::INIT_VIDEO )
19
+ SDL::TTF.init
20
+ SDL::Event.enableUNICODE
21
+
22
+ font = SDL::TTF.open( 'nihongo.ttf', 14 )
23
+
24
+ dict = SDL::SKK::Dictionary.new
25
+ dict.load( 'jisyo', false )
26
+ table = SDL::SKK::RomKanaRuleTable.new( 'rule_table' )
27
+ bind = SDL::SKK::Keybind.new
28
+ bind.set_default_key
29
+
30
+ context = SDL::SKK::Context.new( dict, table, bind, use_minibuffer )
31
+
32
+ screen = SDL::Screen.open( 640, 480, 16, SDL::SWSURFACE )
33
+ SDL::WM.set_caption( $0, $0 )
34
+
35
+ BLACK = screen.format.map_rgb( 0, 0, 0 )
36
+ loop do
37
+
38
+ while event = SDL::Event.poll do
39
+ case event
40
+ when SDL::Event::Quit
41
+ exit
42
+ when SDL::Event::KeyDown
43
+ if event.sym == SDL::Key::ESCAPE then
44
+ exit
45
+ end
46
+ if event.sym == SDL::Key::F1
47
+ dict.save("test_user_dict")
48
+ end
49
+
50
+ context.input( event )
51
+ end
52
+ end
53
+
54
+ text_surface = context.render_str( font, 255, 0, 255 )
55
+
56
+ screen.fill_rect( 0, 0, 640, 480, BLACK )
57
+ SDL::Surface.blit( text_surface, 0, 0, 0, 0, screen, 0, 0 )
58
+
59
+ if use_minibuffer then
60
+ minibuffer_surface = context.render_minibuffer_str( font, 255, 0, 255 )
61
+ if minibuffer_surface then
62
+ SDL::Surface.blit( minibuffer_surface, 0, 0, 0, 0, screen, 0, 40 )
63
+ end
64
+ end
65
+
66
+ screen.update_rect( 0, 0, 0, 0 )
67
+
68
+ sleep 0.05
69
+
70
+ end