rubysdl 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/LICENSE +505 -0
  2. data/MANIFEST +81 -0
  3. data/NEWS.en +144 -0
  4. data/NEWS.ja +151 -0
  5. data/README.en +117 -0
  6. data/README.ja +166 -0
  7. data/SDL_kanji.c +403 -0
  8. data/SDL_kanji.h +48 -0
  9. data/depend +18 -0
  10. data/doc/Makefile +18 -0
  11. data/doc/cdrom.rsd +431 -0
  12. data/doc/collision.rsd +162 -0
  13. data/doc/event.rsd +1487 -0
  14. data/doc/font.rsd +839 -0
  15. data/doc/general.rsd +49 -0
  16. data/doc/init.rsd +175 -0
  17. data/doc/joystick.rsd +387 -0
  18. data/doc/mixer.rsd +837 -0
  19. data/doc/mpeg.rsd +595 -0
  20. data/doc/rsd.rb +125 -0
  21. data/doc/sdlskk.rsd +496 -0
  22. data/doc/time.rsd +45 -0
  23. data/doc/video.rsd +2499 -0
  24. data/doc/wm.rsd +113 -0
  25. data/extconf.rb +92 -0
  26. data/lib/rubysdl_aliases.rb +431 -0
  27. data/lib/sdl.rb +271 -0
  28. data/rubysdl.h +109 -0
  29. data/rubysdl_cdrom.c +176 -0
  30. data/rubysdl_const_list.txt +280 -0
  31. data/rubysdl_doc.en.rd +2180 -0
  32. data/rubysdl_doc_old.rd +2402 -0
  33. data/rubysdl_event.c +346 -0
  34. data/rubysdl_event2.c +417 -0
  35. data/rubysdl_event_key.c +356 -0
  36. data/rubysdl_image.c +53 -0
  37. data/rubysdl_joystick.c +156 -0
  38. data/rubysdl_kanji.c +135 -0
  39. data/rubysdl_main.c +202 -0
  40. data/rubysdl_mixer.c +422 -0
  41. data/rubysdl_mouse.c +96 -0
  42. data/rubysdl_opengl.c +63 -0
  43. data/rubysdl_pixel.c +133 -0
  44. data/rubysdl_ref.html +5550 -0
  45. data/rubysdl_ref.rd +6163 -0
  46. data/rubysdl_rwops.c +90 -0
  47. data/rubysdl_sdlskk.c +312 -0
  48. data/rubysdl_sge_video.c +622 -0
  49. data/rubysdl_smpeg.c +341 -0
  50. data/rubysdl_time.c +36 -0
  51. data/rubysdl_ttf.c +324 -0
  52. data/rubysdl_video.c +749 -0
  53. data/rubysdl_wm.c +71 -0
  54. data/sample/aadraw.rb +24 -0
  55. data/sample/alpha.rb +27 -0
  56. data/sample/alphadraw.rb +25 -0
  57. data/sample/bfont.rb +24 -0
  58. data/sample/cdrom.rb +17 -0
  59. data/sample/collision.rb +97 -0
  60. data/sample/cursor.bmp +0 -0
  61. data/sample/cursor.rb +22 -0
  62. data/sample/ellipses.rb +35 -0
  63. data/sample/event2.rb +32 -0
  64. data/sample/font.bmp +0 -0
  65. data/sample/font.rb +25 -0
  66. data/sample/fpstimer.rb +175 -0
  67. data/sample/icon.bmp +0 -0
  68. data/sample/joy2.rb +81 -0
  69. data/sample/kanji.rb +36 -0
  70. data/sample/movesp.rb +93 -0
  71. data/sample/playmod.rb +14 -0
  72. data/sample/plaympeg.rb +48 -0
  73. data/sample/playwave.rb +16 -0
  74. data/sample/randrect.rb +40 -0
  75. data/sample/sample.ttf +0 -0
  76. data/sample/sdlskk.rb +70 -0
  77. data/sample/sgetest.rb +31 -0
  78. data/sample/stetris.rb +275 -0
  79. data/sample/testgl.rb +166 -0
  80. data/sample/testsprite.rb +68 -0
  81. data/sample/transformblit.rb +41 -0
  82. metadata +121 -0
@@ -0,0 +1,166 @@
1
+ require 'sdl'
2
+ require 'opengl'
3
+
4
+ SDL.init SDL::INIT_VIDEO
5
+ SDL.setGLAttr SDL::GL_RED_SIZE,5
6
+ SDL.setGLAttr SDL::GL_GREEN_SIZE,5
7
+ SDL.setGLAttr SDL::GL_BLUE_SIZE,5
8
+ SDL.setGLAttr SDL::GL_DEPTH_SIZE,16
9
+ SDL.setGLAttr SDL::GL_DOUBLEBUFFER,1
10
+ SDL.setVideoMode 640,400,16,SDL::OPENGL
11
+ GL::Viewport( 0, 0, 640, 400 );
12
+ GL::MatrixMode( GL::PROJECTION );
13
+ GL::LoadIdentity( );
14
+
15
+ GL::MatrixMode( GL::MODELVIEW );
16
+ GL::LoadIdentity( );
17
+
18
+ GL::Enable(GL::DEPTH_TEST);
19
+
20
+ GL::DepthFunc(GL::LESS);
21
+
22
+ GL::ShadeModel(GL::SMOOTH);
23
+
24
+ event=SDL::Event.new
25
+ shadedCube=true
26
+
27
+ color =
28
+ [[ 1.0, 1.0, 0.0],
29
+ [ 1.0, 0.0, 0.0],
30
+ [ 0.0, 0.0, 0.0],
31
+ [ 0.0, 1.0, 0.0],
32
+ [ 0.0, 1.0, 1.0],
33
+ [ 1.0, 1.0, 1.0],
34
+ [ 1.0, 0.0, 1.0],
35
+ [ 0.0, 0.0, 1.0]]
36
+
37
+ cube =
38
+ [[ 0.5, 0.5, -0.5],
39
+ [ 0.5, -0.5, -0.5],
40
+ [-0.5, -0.5, -0.5],
41
+ [-0.5, 0.5, -0.5],
42
+ [-0.5, 0.5, 0.5],
43
+ [ 0.5, 0.5, 0.5],
44
+ [ 0.5, -0.5, 0.5],
45
+ [-0.5, -0.5, 0.5]]
46
+
47
+
48
+ loop do
49
+
50
+ if event.poll != 0 then
51
+ if event.type==SDL::Event::QUIT then
52
+ break
53
+ end
54
+ if event.type==SDL::Event::KEYDOWN then
55
+ exit
56
+ end
57
+ end
58
+
59
+ GL.ClearColor(0.0, 0.0, 0.0, 1.0);
60
+ GL.Clear(GL::COLOR_BUFFER_BIT|GL::DEPTH_BUFFER_BIT);
61
+
62
+
63
+ GL::Begin(GL::QUADS)
64
+
65
+ if shadedCube then
66
+ GL::Color(color[0]);
67
+ GL::Vertex(cube[0]);
68
+ GL::Color(color[1]);
69
+ GL::Vertex(cube[1]);
70
+ GL::Color(color[2]);
71
+ GL::Vertex(cube[2]);
72
+ GL::Color(color[3]);
73
+ GL::Vertex(cube[3]);
74
+
75
+ GL::Color(color[3]);
76
+ GL::Vertex(cube[3]);
77
+ GL::Color(color[4]);
78
+ GL::Vertex(cube[4]);
79
+ GL::Color(color[7]);
80
+ GL::Vertex(cube[7]);
81
+ GL::Color(color[2]);
82
+ GL::Vertex(cube[2]);
83
+
84
+ GL::Color(color[0]);
85
+ GL::Vertex(cube[0]);
86
+ GL::Color(color[5]);
87
+ GL::Vertex(cube[5]);
88
+ GL::Color(color[6]);
89
+ GL::Vertex(cube[6]);
90
+ GL::Color(color[1]);
91
+ GL::Vertex(cube[1]);
92
+
93
+ GL::Color(color[5]);
94
+ GL::Vertex(cube[5]);
95
+ GL::Color(color[4]);
96
+ GL::Vertex(cube[4]);
97
+ GL::Color(color[7]);
98
+ GL::Vertex(cube[7]);
99
+ GL::Color(color[6]);
100
+ GL::Vertex(cube[6]);
101
+
102
+ GL::Color(color[5]);
103
+ GL::Vertex(cube[5]);
104
+ GL::Color(color[0]);
105
+ GL::Vertex(cube[0]);
106
+ GL::Color(color[3]);
107
+ GL::Vertex(cube[3]);
108
+ GL::Color(color[4]);
109
+ GL::Vertex(cube[4]);
110
+
111
+ GL::Color(color[6]);
112
+ GL::Vertex(cube[6]);
113
+ GL::Color(color[1]);
114
+ GL::Vertex(cube[1]);
115
+ GL::Color(color[2]);
116
+ GL::Vertex(cube[2]);
117
+ GL::Color(color[7]);
118
+ GL::Vertex(cube[7]);
119
+
120
+ else
121
+ GL::Color(1.0, 0.0, 0.0);
122
+ GL::Vertex(cube[0]);
123
+ GL::Vertex(cube[1]);
124
+ GL::Vertex(cube[2]);
125
+ GL::Vertex(cube[3]);
126
+
127
+ GL::Color(0.0, 1.0, 0.0);
128
+ GL::Vertex(cube[3]);
129
+ GL::Vertex(cube[4]);
130
+ GL::Vertex(cube[7]);
131
+ GL::Vertex(cube[2]);
132
+
133
+ GL::Color(0.0, 0.0, 1.0);
134
+ GL::Vertex(cube[0]);
135
+ GL::Vertex(cube[5]);
136
+ GL::Vertex(cube[6]);
137
+ GL::Vertex(cube[1]);
138
+
139
+ GL::Color(0.0, 1.0, 1.0);
140
+ GL::Vertex(cube[5]);
141
+ GL::Vertex(cube[4]);
142
+ GL::Vertex(cube[7]);
143
+ GL::Vertex(cube[6]);
144
+
145
+ GL::Color(1.0, 1.0, 0.0);
146
+ GL::Vertex(cube[5]);
147
+ GL::Vertex(cube[0]);
148
+ GL::Vertex(cube[3]);
149
+ GL::Vertex(cube[4]);
150
+
151
+ GL::Color(1.0, 0.0, 1.0);
152
+ GL::Vertex(cube[6]);
153
+ GL::Vertex(cube[1]);
154
+ GL::Vertex(cube[2]);
155
+ GL::Vertex(cube[7]);
156
+
157
+ end
158
+
159
+ GL::End()
160
+
161
+ GL::MatrixMode(GL::MODELVIEW);
162
+ GL::Rotate(5.0, 1.0, 1.0, 1.0);
163
+
164
+ SDL.GLSwapBuffers
165
+
166
+ end
@@ -0,0 +1,68 @@
1
+ require 'sdl'
2
+
3
+ SDL.init( SDL::INIT_VIDEO )
4
+ screen = SDL::setVideoMode(640,480,16,SDL::SWSURFACE)
5
+ SDL::WM::setCaption('testsprite.rb','testsprite.rb icon')
6
+ image = SDL::Surface.loadBMP("icon.bmp")
7
+ image.setColorKey( SDL::SRCCOLORKEY ,0)
8
+ $image = image.displayFormat
9
+
10
+ class Sprite
11
+ def initialize
12
+ @x=rand(640)
13
+ @y=rand(480)
14
+ @dx=rand(11)-5
15
+ @dy=rand(11)-5
16
+ end
17
+
18
+ def move
19
+ @x += @dx
20
+ if @x >= 640 then
21
+ @dx *= -1
22
+ @x = 639
23
+ end
24
+ if @x < 0 then
25
+ @dx *= -1
26
+ @x = 0
27
+ end
28
+ @y += @dy
29
+ if @y >= 480 then
30
+ @dy *= -1
31
+ @y = 479
32
+ end
33
+ @y += @dy
34
+ if @y < 0 then
35
+ @dy *= -1
36
+ @y = 0
37
+ end
38
+ end
39
+
40
+ def draw(screen)
41
+ SDL.blitSurface($image,0,0,32,32,screen,@x,@y)
42
+ end
43
+
44
+ end
45
+
46
+ sprites = []
47
+ for i in 1..100
48
+ sprites << Sprite.new
49
+ end
50
+
51
+
52
+ while true
53
+ while event = SDL::Event2.poll
54
+ case event
55
+ when SDL::Event2::KeyDown, SDL::Event2::Quit
56
+ exit
57
+ end
58
+ end
59
+ screen.fillRect(0,0,640,480,0)
60
+
61
+ sprites.each {|i|
62
+ i.move
63
+ i.draw(screen)
64
+ }
65
+ screen.updateRect(0,0,0,0)
66
+ end
67
+
68
+
@@ -0,0 +1,41 @@
1
+ require 'sdl'
2
+
3
+ SDL.init( SDL::INIT_VIDEO )
4
+ screen = SDL::setVideoMode(640,480,16,SDL::SWSURFACE)
5
+
6
+ image = SDL::Surface.loadBMP("icon.bmp")
7
+ image.setColorKey( SDL::SRCCOLORKEY , image[0,0])
8
+ image = image.displayFormat
9
+
10
+ aimage = SDL::Surface.loadBMP("icon.bmp")
11
+ aimage.setColorKey( SDL::SRCCOLORKEY, aimage[0,0] )
12
+ aimage.setAlpha(SDL::SRCALPHA, 128 )
13
+ aimage = aimage.displayFormat
14
+
15
+ angle = 0
16
+
17
+ while true
18
+
19
+ event = SDL::Event2.poll
20
+ case event
21
+ when SDL::Event2::Quit
22
+ exit
23
+ when SDL::Event2::KeyDown
24
+ exit if event.sym == SDL::Key::ESCAPE
25
+ end
26
+
27
+ angle += 2
28
+
29
+ screen.fillRect(0,0,640,480,[100,100,100])
30
+
31
+ SDL.transform(image,screen,angle,1,1,image.w/2,image.h/2,100,100,0 )
32
+ SDL.transformBlit(image,screen,angle,1,1,image.w/2,image.h/2,200,200,0 )
33
+
34
+ SDL.transform(image,screen,angle,1,1,0,0,300,300,0 )
35
+ SDL.transformBlit(image,screen,angle,1,1,0,0,400,200,0 )
36
+
37
+ SDL.transformBlit(aimage,screen,angle,1,1,0,0,100,400,0 )
38
+
39
+ screen.updateRect(0,0,0,0)
40
+
41
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: rubysdl
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.3.0
7
+ date: 2007-02-25 00:00:00 +09:00
8
+ summary: The simple ruby extension library to use SDL
9
+ require_paths:
10
+ - lib
11
+ email: ohai@kmc.gr.jp
12
+ homepage: http://www.kmc.gr.jp/~ohai/
13
+ rubyforge_project:
14
+ description:
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: false
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ -
22
+ - ">"
23
+ - !ruby/object:Gem::Version
24
+ version: 0.0.0
25
+ version:
26
+ platform: ruby
27
+ signing_key:
28
+ cert_chain:
29
+ post_install_message:
30
+ authors:
31
+ - Ohbayashi Ippei
32
+ files:
33
+ - MANIFEST
34
+ - README.ja
35
+ - README.en
36
+ - NEWS.ja
37
+ - NEWS.en
38
+ - LICENSE
39
+ - depend
40
+ - extconf.rb
41
+ - lib/rubysdl_aliases.rb
42
+ - lib/sdl.rb
43
+ - rubysdl.h
44
+ - rubysdl_const_list.txt
45
+ - rubysdl_doc_old.rd
46
+ - rubysdl_ref.rd
47
+ - rubysdl_ref.html
48
+ - rubysdl_doc.en.rd
49
+ - rubysdl_event.c
50
+ - rubysdl_event_key.c
51
+ - rubysdl_main.c
52
+ - rubysdl_mixer.c
53
+ - rubysdl_mouse.c
54
+ - rubysdl_sge_video.c
55
+ - rubysdl_time.c
56
+ - rubysdl_video.c
57
+ - rubysdl_wm.c
58
+ - rubysdl_ttf.c
59
+ - rubysdl_cdrom.c
60
+ - rubysdl_joystick.c
61
+ - rubysdl_image.c
62
+ - rubysdl_opengl.c
63
+ - rubysdl_pixel.c
64
+ - rubysdl_event2.c
65
+ - rubysdl_smpeg.c
66
+ - rubysdl_sdlskk.c
67
+ - rubysdl_kanji.c
68
+ - rubysdl_rwops.c
69
+ - SDL_kanji.c
70
+ - SDL_kanji.h
71
+ - sample/testsprite.rb
72
+ - sample/playwave.rb
73
+ - sample/movesp.rb
74
+ - sample/alpha.rb
75
+ - sample/sgetest.rb
76
+ - sample/font.rb
77
+ - sample/cdrom.rb
78
+ - sample/playmod.rb
79
+ - sample/testgl.rb
80
+ - sample/icon.bmp
81
+ - sample/cursor.rb
82
+ - sample/event2.rb
83
+ - sample/joy2.rb
84
+ - sample/plaympeg.rb
85
+ - sample/cursor.bmp
86
+ - sample/transformblit.rb
87
+ - sample/randrect.rb
88
+ - sample/sdlskk.rb
89
+ - sample/ellipses.rb
90
+ - sample/collision.rb
91
+ - sample/stetris.rb
92
+ - sample/aadraw.rb
93
+ - sample/alphadraw.rb
94
+ - sample/fpstimer.rb
95
+ - sample/bfont.rb
96
+ - sample/font.bmp
97
+ - sample/kanji.rb
98
+ - sample/sample.ttf
99
+ - doc/Makefile
100
+ - doc/rsd.rb
101
+ - doc/cdrom.rsd
102
+ - doc/collision.rsd
103
+ - doc/event.rsd
104
+ - doc/font.rsd
105
+ - doc/general.rsd
106
+ - doc/init.rsd
107
+ - doc/joystick.rsd
108
+ - doc/mixer.rsd
109
+ - doc/mpeg.rsd
110
+ - doc/sdlskk.rsd
111
+ - doc/time.rsd
112
+ - doc/video.rsd
113
+ - doc/wm.rsd
114
+ test_files: []
115
+ rdoc_options: []
116
+ extra_rdoc_files: []
117
+ executables: []
118
+ extensions:
119
+ - extconf.rb
120
+ requirements: []
121
+ dependencies: []