rubysdl-mswin32-1.8 2.1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) 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 +72 -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 +25 -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/cdrom.rb +24 -0
  53. data/sample/collision.rb +97 -0
  54. data/sample/cursor.bmp +0 -0
  55. data/sample/cursor.rb +22 -0
  56. data/sample/ellipses.rb +39 -0
  57. data/sample/event2.rb +34 -0
  58. data/sample/font.bmp +0 -0
  59. data/sample/font.rb +26 -0
  60. data/sample/fpstimer.rb +175 -0
  61. data/sample/icon.bmp +0 -0
  62. data/sample/icon.bmp.gz +0 -0
  63. data/sample/icon.png +0 -0
  64. data/sample/joy2.rb +81 -0
  65. data/sample/kanji.rb +36 -0
  66. data/sample/load_from_io.rb +45 -0
  67. data/sample/movesp.rb +94 -0
  68. data/sample/playmod.rb +13 -0
  69. data/sample/plaympeg.rb +44 -0
  70. data/sample/playwave.rb +15 -0
  71. data/sample/randrect.rb +40 -0
  72. data/sample/rubysdl.rb +34 -0
  73. data/sample/sample.ttf +0 -0
  74. data/sample/sdlskk.rb +70 -0
  75. data/sample/sgetest.rb +33 -0
  76. data/sample/stetris.rb +274 -0
  77. data/sample/testgl.rb +165 -0
  78. data/sample/testsprite.rb +69 -0
  79. data/sample/transformblit.rb +42 -0
  80. metadata +135 -0
data/sample/aadraw.rb ADDED
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ require 'sdl'
3
+
4
+ SDL.init( SDL::INIT_VIDEO )
5
+ screen = SDL::Screen.open(640,480,16,SDL::SWSURFACE)
6
+ SDL::WM::set_caption $0, $0
7
+
8
+ Red=screen.format.map_rgb(255,0,0)
9
+ screen.draw_line(20,20,300,200,Red, true)
10
+ screen.draw_circle(100,100,50,[87,87,87], false, true)
11
+ screen.draw_circle(300,300,30,Red, true, true)
12
+ screen.draw_ellipse(320,240,100,200,[200,255,0], false, true)
13
+
14
+ screen.flip
15
+
16
+ while true
17
+ while event = SDL::Event.poll
18
+ case event
19
+ when SDL::Event::KeyDown, SDL::Event::Quit
20
+ exit
21
+ end
22
+ end
23
+
24
+ sleep 0.2
25
+ end
data/sample/alpha.rb ADDED
@@ -0,0 +1,26 @@
1
+ require 'sdl'
2
+
3
+ SDL.init( SDL::INIT_VIDEO )
4
+ screen = SDL::Screen.open(640,480,16,SDL::SWSURFACE)
5
+
6
+ image = SDL::Surface.load_bmp("icon.bmp")
7
+ image.set_color_key( SDL::SRCCOLORKEY ,0)
8
+ image = image.display_format
9
+
10
+
11
+ i=0;
12
+ black = screen.format.map_rgb(0,0,0)
13
+ while true
14
+ while event = SDL::Event.poll
15
+ case event
16
+ when SDL::Event::Quit, SDL::Event::KeyDown
17
+ exit
18
+ end
19
+ end
20
+ screen.fillRect(0,0,640,480,black)
21
+
22
+ image.set_alpha(SDL::SRCALPHA,i%256)
23
+ screen.put(image,310,195)
24
+ i+=1
25
+ screen.flip
26
+ end
@@ -0,0 +1,25 @@
1
+ require 'sdl'
2
+
3
+ SDL.init( SDL::INIT_VIDEO )
4
+ screen = SDL::Screen.open(640,480,16,SDL::SWSURFACE)
5
+ SDL::WM::set_caption $0, $0
6
+
7
+ Red=screen.format.map_rgb(255,0,0)
8
+ screen.draw_circle(320,240,220,[140,180,0], true, true)
9
+ screen.draw_line(20,20,300,200,Red,true, rand(64)+128)
10
+ screen.draw_circle(100,100,50,[87,87,87],false,true,rand(64)+128)
11
+ screen.draw_circle(300,170,50,[87,80,0],true, false, rand(64)+128)
12
+ screen.draw_ellipse(320,240,100,200,[200,255,0],false, false, rand(64)+128)
13
+
14
+ screen.flip
15
+
16
+ while true
17
+ while event = SDL::Event.poll
18
+ case event
19
+ when SDL::Event::KeyDown, SDL::Event::Quit
20
+ exit
21
+ end
22
+ end
23
+
24
+ sleep 0.2
25
+ end
data/sample/bfont.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'sdl'
2
+
3
+ SDL.init( SDL::INIT_VIDEO )
4
+ screen = SDL::Screen.open(640,480,16,SDL::SWSURFACE)
5
+
6
+ font = SDL::BMFont.open("font.bmp",SDL::BMFont::TRANSPARENT)
7
+
8
+ y = 0
9
+
10
+ while true
11
+ while event = SDL::Event.poll
12
+ case event
13
+ when SDL::Event::KeyDown, SDL::Event::Quit
14
+ exit
15
+ end
16
+ end
17
+ screen.fill_rect(0,0,640,480,0)
18
+
19
+ y = (y + 1) % 480
20
+ font.textout(screen,"BitMapFont Testing..",40,y)
21
+
22
+ screen.updateRect(0,0,0,0)
23
+ sleep 0.005
24
+ end
data/sample/cdrom.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'sdl'
2
+
3
+ SDL.init( SDL::INIT_CDROM )
4
+
5
+ num_drive = SDL::CD.num_drive
6
+ if num_drive == 0
7
+ print "No cdrom drive is detected\n"
8
+ exit
9
+ else
10
+ print "#{num_drive} cdrom drives are detected\n"
11
+ end
12
+
13
+ print SDL::CD.index_name(0),"\n"
14
+ cd=SDL::CD.open(0)
15
+ cd.status
16
+ print cd.num_tracks," ",cd.status, "\n"
17
+
18
+ begin
19
+ cd.play_tracks 1,0,1,0
20
+ sleep 100
21
+ ensure
22
+ cd.stop
23
+ end
24
+
@@ -0,0 +1,97 @@
1
+ require 'sdl'
2
+
3
+ SDL.init( SDL::INIT_VIDEO )
4
+ screen = SDL::Screen.open(640,480,16,SDL::SWSURFACE)
5
+ SDL::WM::set_caption('collision.rb','collision.rb icon')
6
+ $image = SDL::Surface.load_bmp("icon.bmp")
7
+ $image.set_color_key( SDL::SRCCOLORKEY ,0)
8
+ $image = $image.display_format
9
+ $cMap = $image.make_collision_map
10
+
11
+ class Sprite
12
+
13
+ attr_reader :x, :y
14
+
15
+ def initialize(screen)
16
+ @screen = screen
17
+ @x=rand(screen.w)
18
+ @y=rand(screen.h)
19
+ @dx=rand(11)-5
20
+ @dy=rand(11)-5
21
+ end
22
+
23
+ def move
24
+ @x, @dx = move_coord(@x, @dx, xMax)
25
+ @y, @dy = move_coord(@y, @dy, yMax)
26
+ end
27
+
28
+ def bounce
29
+ @dx *= -1
30
+ @dy *= -1
31
+ move
32
+ end
33
+
34
+ def draw
35
+ SDL::Surface.blit($image,0,0,$image.w,$image.h,@screen,@x,@y)
36
+ end
37
+
38
+ def collide_with?(sprite)
39
+ $cMap.collision_check(@x, @y, $cMap, sprite.x, sprite.y) != nil
40
+ end
41
+
42
+ private
43
+
44
+ def move_coord(coord, delta, max)
45
+ coord += delta
46
+ if coord >= max then
47
+ delta *= -1
48
+ coord = max - 1
49
+ end
50
+ if coord < 0 then
51
+ delta *= -1
52
+ coord = 0
53
+ end
54
+ [coord, delta]
55
+ end
56
+
57
+ def xMax
58
+ @screen.w - $image.w
59
+ end
60
+
61
+ def yMax
62
+ @screen.h - $image.h
63
+ end
64
+
65
+ end
66
+
67
+ def detect_collisions(sprites)
68
+ collisions = []
69
+ for i in (0 ... sprites.size - 1) do
70
+ for j in (i + 1 ... sprites.size) do
71
+ if sprites[i].collide_with?(sprites[j])
72
+ collisions << sprites[i]
73
+ collisions << sprites[j]
74
+ end
75
+ end
76
+ end
77
+ collisions.uniq
78
+ end
79
+
80
+ sprites = (1..8).collect {Sprite.new(screen)}
81
+
82
+ background = screen.format.map_rgb(64, 64, 64)
83
+ while true
84
+ while event = SDL::Event.poll
85
+ case event
86
+ when SDL::Event::KeyDown, SDL::Event::Quit
87
+ exit
88
+ end
89
+ end
90
+
91
+ screen.fill_rect(0,0,640,480,background)
92
+ sprites.each {|i| i.move}
93
+ detect_collisions(sprites).each {|i| i.bounce}
94
+ sprites.each {|i| i.draw}
95
+ screen.update_rect(0,0,0,0)
96
+ end
97
+
data/sample/cursor.bmp ADDED
Binary file
data/sample/cursor.rb ADDED
@@ -0,0 +1,22 @@
1
+ require 'sdl'
2
+
3
+ SDL.init( SDL::INIT_VIDEO )
4
+ screen = SDL::Screen.open(640,480,16,SDL::SWSURFACE)
5
+ screen.fill_rect 0,0,640,480,[32,240,100]
6
+ screen.flip
7
+ SDL::WM::set_caption $0,$0
8
+
9
+ image=SDL::Surface.load_bmp 'cursor.bmp'
10
+ SDL::Mouse.set_cursor image,image[0,0],image[1,1],image[7,0],543
11
+
12
+
13
+ while true
14
+
15
+ while event = SDL::Event2.poll
16
+ case event
17
+ when SDL::Event2::KeyDown, SDL::Event2::Quit
18
+ exit
19
+ end
20
+ end
21
+ sleep 0.01
22
+ end
@@ -0,0 +1,39 @@
1
+ # SDL random ellipses
2
+ # Author: Wayne Conrad <wconrad@yagni.com>
3
+
4
+ require 'sdl'
5
+
6
+ def show(fill)
7
+ screen = SDL::Screen.open(640, 480, 16, SDL::SWSURFACE)
8
+ format = screen.format
9
+ loop do
10
+ color = format.map_rgb(rand(256),rand(256),rand(256))
11
+ x = rand(screen.w)
12
+ y = rand(screen.h)
13
+ xr = rand(80)
14
+ yr = rand(80)
15
+ screen.draw_ellipse(x, y, xr, yr, color, fill)
16
+ while event = SDL::Event.poll
17
+ case event
18
+ when SDL::Event::Quit
19
+ exit
20
+ when SDL::Event::KeyDown
21
+ if event.sym == SDL::Key::ESCAPE
22
+ exit
23
+ else
24
+ return
25
+ end
26
+ when SDL::Event::MouseButtonDown
27
+ return
28
+ end
29
+ end
30
+ screen.updateRect(0, 0, 0, 0)
31
+ sleep 0.05
32
+ end
33
+ screen.destroy
34
+ end
35
+
36
+ srand
37
+ SDL.init SDL::INIT_VIDEO
38
+ show(false)
39
+ show(true)
data/sample/event2.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'sdl'
2
+
3
+ SDL.init( SDL::INIT_VIDEO )
4
+ screen = SDL::Screen.open(640,480,16,SDL::SWSURFACE)
5
+ SDL::WM::set_caption $0,$0
6
+
7
+ loop do
8
+ while event=SDL::Event.poll
9
+ case event
10
+ when SDL::Event::Active
11
+ print "Active ", (event.gain)?"gain":"lost","\n"
12
+ when SDL::Event::KeyDown
13
+ print "KeyDown sym:#{event.sym} mod:#{event.mod}","\n"
14
+ if event.sym==SDL::Key::A then
15
+ e=SDL::Event::KeyDown.new
16
+ e.sym=3333
17
+ e.mod=3333
18
+ e.press=true
19
+ e.unicode=200
20
+ SDL::Event.push(e)
21
+ end
22
+ when SDL::Event::KeyUp
23
+ print "KeyUp sym:#{event.sym} mod:#{event.mod}","\n"
24
+
25
+ when SDL::Event::Quit
26
+ exit
27
+
28
+ end
29
+ end
30
+
31
+ sleep 0.05
32
+ end
33
+
34
+
data/sample/font.bmp ADDED
Binary file
data/sample/font.rb ADDED
@@ -0,0 +1,26 @@
1
+ require 'sdl'
2
+
3
+ SDL.init( SDL::INIT_VIDEO )
4
+
5
+ screen = SDL::Screen.open(640,480,16,SDL::SWSURFACE)
6
+ SDL::WM::set_caption($0,$0)
7
+
8
+ SDL::TTF.init
9
+
10
+ font = SDL::TTF.open('sample.ttf',24)
11
+ font.style = SDL::TTF::STYLE_NORMAL
12
+
13
+ font.draw_solid_utf8(screen,'test SDL_ttf',300,150,255,255,255)
14
+
15
+ screen.flip
16
+
17
+ loop do
18
+ while event = SDL::Event2.poll
19
+ case event
20
+ when SDL::Event2::KeyDown, SDL::Event2::Quit
21
+ font.close
22
+ exit
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,175 @@
1
+ require 'sdl'
2
+
3
+ class FPSTimerSample
4
+ FPS_COUNT = 10
5
+
6
+ attr_accessor :fps
7
+ attr_reader :real_fps, :total_skip
8
+ attr_reader :count_sleep
9
+ # +fps+ is the number of frames per second that you want to keep,
10
+ # +accurary+ is the accurary of sleep/SDL.delay in milisecond
11
+ def initialize(fps = 60, accurary = 10, skip_limit = 15)
12
+ @fps = fps
13
+ @accurary = accurary / 1000.0
14
+ @skip_limit = skip_limit
15
+ end
16
+
17
+ # reset timer, you should call just before starting loop
18
+ def reset
19
+ @old = get_ticks
20
+ @skip = 0
21
+ @real_fps = @fps
22
+ @frame_count = 0
23
+ @fps_old = @old
24
+ @count_sleep = 0
25
+ @total_skip = 0
26
+ end
27
+
28
+ # execute given block and wait
29
+ def wait_frame
30
+ now = get_ticks
31
+ nxt = @old + (1.0/@fps)
32
+ if nxt > now || @skip > @skip_limit
33
+ yield
34
+ @skip = 0
35
+ wait(nxt)
36
+ @old = nxt
37
+ else
38
+ @skip += 1
39
+ @total_skip += 1
40
+ @old = get_ticks
41
+ end
42
+
43
+ calc_real_fps
44
+ end
45
+
46
+ private
47
+ def wait(nxt)
48
+ while nxt > get_ticks + @accurary
49
+ sleep(@accurary - 0.005)
50
+ @count_sleep += 1
51
+ end
52
+
53
+ while nxt > get_ticks
54
+ # busy loop, do nothing
55
+ end
56
+ end
57
+
58
+ def get_ticks
59
+ SDL.get_ticks / 1000.0
60
+ end
61
+
62
+ def calc_real_fps
63
+ @frame_count += 1
64
+ if @frame_count >= FPS_COUNT
65
+ @frame_count = 0
66
+ now = get_ticks
67
+ @real_fps = FPS_COUNT / (now - @fps_old)
68
+ @fps_old = now
69
+ end
70
+ end
71
+ end
72
+
73
+ class FPSTimerLight
74
+ N = 12
75
+ DT = 2
76
+ FPS_COUNT = 10
77
+
78
+ attr_reader :fps
79
+ attr_reader :real_fps
80
+ # +fps+ is the number of frames per second that you want to keep,
81
+ # +accurary+ is the accurary of sleep/SDL.delay in milisecond
82
+ def initialize(fps = 60, accurary = 10, skip_limit = 15)
83
+ @fps = fps
84
+ @accurary = accurary * N
85
+ @skip_limit = 15
86
+ @one_frame = 1000*N / fps
87
+ @delay = accurary - 2
88
+ end
89
+
90
+ # reset timer, you should call just before starting loop
91
+ def reset
92
+ @old = get_ticks
93
+ @skip = 0
94
+
95
+ # for calculate real fps
96
+ @frame_count = 0
97
+ @fps_old = @old
98
+ @real_fps = @fps
99
+ end
100
+
101
+ def wait_frame
102
+ now = get_ticks
103
+ nxt = @old + @one_frame
104
+ if nxt > now || @skip > @skip_limit
105
+ yield
106
+ @skip = 0
107
+ wait(nxt)
108
+ @old = nxt
109
+ else
110
+ @skip += 1
111
+ @total_skip += 1
112
+ @old = get_ticks
113
+ end
114
+
115
+ calc_real_fps
116
+ end
117
+
118
+ private
119
+ def get_ticks
120
+ SDL.get_ticks * N
121
+ end
122
+
123
+ def wait(nxt)
124
+ while nxt > get_ticks + @accurary
125
+ SDL.delay(@delay)
126
+ end
127
+
128
+ while nxt > get_ticks
129
+ # busy loop, do nothing
130
+ end
131
+ end
132
+
133
+ def calc_real_fps
134
+ @frame_count += 1
135
+ if @frame_count >= FPS_COUNT
136
+ @frame_count = 0
137
+ now = get_ticks
138
+ @real_fps = (N*1000*FPS_COUNT)/(now - @fps_old)
139
+ @fps_old = now
140
+ end
141
+ end
142
+ end
143
+
144
+ if __FILE__ == $0
145
+ timer = FPSTimerSample.new
146
+ log = []
147
+
148
+ timer.reset
149
+ 300.times do
150
+ sleep 0.005 if rand(5) == 0
151
+ timer.wait_frame do
152
+ log << timer.real_fps.to_s
153
+ end
154
+ end
155
+
156
+ puts log
157
+ printf "skip:%d\n", timer.total_skip
158
+ printf "sleep:%d\n", timer.count_sleep
159
+
160
+ puts
161
+
162
+ timer = FPSTimerLight.new
163
+ log = []
164
+
165
+ timer.reset
166
+ old = SDL.get_ticks
167
+ 300.times do
168
+ sleep 0.005 if rand(5) == 0
169
+ timer.wait_frame do
170
+ log << timer.real_fps
171
+ end
172
+ end
173
+
174
+ puts log
175
+ end