dxruby64 1.4.7

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 (101) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +14 -0
  3. data/README-ja.md +125 -0
  4. data/README.md +120 -0
  5. data/lib/31/dxruby.so +0 -0
  6. data/lib/32/dxruby.so +0 -0
  7. data/lib/33/dxruby.so +0 -0
  8. data/lib/34/dxruby.so +0 -0
  9. data/lib/dxruby.rb +2 -0
  10. data/sample/classic_sample/8_puzzle.rb +55 -0
  11. data/sample/classic_sample/block_destroy.rb +161 -0
  12. data/sample/classic_sample/block_fall.rb +194 -0
  13. data/sample/classic_sample/data.png +0 -0
  14. data/sample/classic_sample/dot.rb +80 -0
  15. data/sample/classic_sample/drawtile.rb +173 -0
  16. data/sample/classic_sample/flight.rb +75 -0
  17. data/sample/classic_sample/hitrangeview.rb +66 -0
  18. data/sample/classic_sample/mapedit.rb +270 -0
  19. data/sample/classic_sample/meiro.rb +106 -0
  20. data/sample/classic_sample/minsample.rb +14 -0
  21. data/sample/classic_sample/race.rb +119 -0
  22. data/sample/classic_sample/readme_sample.txt +42 -0
  23. data/sample/classic_sample/sample.rb +110 -0
  24. data/sample/classic_sample/soundeffect.rb +46 -0
  25. data/sample/new_sample/biyo.rb +25 -0
  26. data/sample/new_sample/image/enemy1.png +0 -0
  27. data/sample/new_sample/image/enemy1bomb.png +0 -0
  28. data/sample/new_sample/image/enemy2.png +0 -0
  29. data/sample/new_sample/image/enemy2bomb.png +0 -0
  30. data/sample/new_sample/image/enemyshot1.png +0 -0
  31. data/sample/new_sample/image/enemyshot2.png +0 -0
  32. data/sample/new_sample/image/maptile.png +0 -0
  33. data/sample/new_sample/image/myship.png +0 -0
  34. data/sample/new_sample/image/myshot.png +0 -0
  35. data/sample/new_sample/iraira.rb +49 -0
  36. data/sample/new_sample/laser2.rb +292 -0
  37. data/sample/new_sample/raycast.rb +249 -0
  38. data/sample/new_sample/readme_sample.txt +27 -0
  39. data/sample/new_sample/rubima.rb +597 -0
  40. data/sample/new_sample/ruby.png +0 -0
  41. data/sample/new_sample/slg.rb +82 -0
  42. data/sample/new_sample/sprite_animation.rb +133 -0
  43. data/sample/new_sample/sprite_collision1.rb +216 -0
  44. data/sample/new_sample/sprite_collision2.rb +93 -0
  45. data/sample/new_sample/sprite_simple.rb +65 -0
  46. data/sample/new_sample2/ImageFont.dat +0 -0
  47. data/sample/new_sample2/ImageFont.dat.png +0 -0
  48. data/sample/new_sample2/autocall.rb +24 -0
  49. data/sample/new_sample2/effecttest.rb +136 -0
  50. data/sample/new_sample2/fibersprite.rb +89 -0
  51. data/sample/new_sample2/hitrange.rb +133 -0
  52. data/sample/new_sample2/hlstest.rb +27 -0
  53. data/sample/new_sample2/mapedit_perlin.rb +291 -0
  54. data/sample/new_sample2/noise.rb +33 -0
  55. data/sample/new_sample2/particle.rb +220 -0
  56. data/sample/new_sample2/readme_sample.txt +29 -0
  57. data/sample/new_sample2/scenetest.rb +200 -0
  58. data/sample/new_sample2/scenetest2.rb +120 -0
  59. data/sample/scroll_sample/map.dat +32 -0
  60. data/sample/scroll_sample/map.rb +77 -0
  61. data/sample/scroll_sample/map_sub.dat +32 -0
  62. data/sample/scroll_sample/mapedit.rb +102 -0
  63. data/sample/scroll_sample/readme_sample.txt +24 -0
  64. data/sample/scroll_sample/scroll1.rb +108 -0
  65. data/sample/scroll_sample/scroll2.rb +149 -0
  66. data/sample/scroll_sample/scroll3.rb +148 -0
  67. data/sample/scroll_sample/simple.rb +13 -0
  68. data/sample/shader_sample/Shader/Flash.rb +93 -0
  69. data/sample/shader_sample/Shader/RasterScroll.rb +71 -0
  70. data/sample/shader_sample/Shader/RgssSprite.rb +143 -0
  71. data/sample/shader_sample/Shader/Transition.rb +108 -0
  72. data/sample/shader_sample/bgimage/BG00a1_80.jpg +0 -0
  73. data/sample/shader_sample/bgimage/BG10a_80.jpg +0 -0
  74. data/sample/shader_sample/bgimage/BG13a_80.jpg +0 -0
  75. data/sample/shader_sample/bgimage/BG32a.jpg +0 -0
  76. data/sample/shader_sample/bgimage/BG42a.jpg +0 -0
  77. data/sample/shader_sample/bgimage/course.png +0 -0
  78. data/sample/shader_sample/bgimage/image1.png +0 -0
  79. data/sample/shader_sample/bgimage/world_map2.png +0 -0
  80. data/sample/shader_sample/fan.rb +53 -0
  81. data/sample/shader_sample/image/enemy1.png +0 -0
  82. data/sample/shader_sample/image/enemy2.png +0 -0
  83. data/sample/shader_sample/image/maptile.png +0 -0
  84. data/sample/shader_sample/readme_sample.txt +43 -0
  85. data/sample/shader_sample/rule//343/203/201/343/202/247/343/203/203/343/202/253/343/203/274.png +0 -0
  86. data/sample/shader_sample/rule//345/217/263/346/270/246/345/267/273/343/201/215.png +0 -0
  87. data/sample/shader_sample/rule//346/250/252/343/203/226/343/203/251/343/202/244/343/203/263/343/203/211.png +0 -0
  88. data/sample/shader_sample/sample_blur.rb +112 -0
  89. data/sample/shader_sample/sample_divide.rb +91 -0
  90. data/sample/shader_sample/sample_flash.rb +54 -0
  91. data/sample/shader_sample/sample_lens.rb +65 -0
  92. data/sample/shader_sample/sample_mapping.rb +50 -0
  93. data/sample/shader_sample/sample_rasterscroll.rb +48 -0
  94. data/sample/shader_sample/sample_rgsssprite.rb +41 -0
  95. data/sample/shader_sample/sample_spehari.rb +50 -0
  96. data/sample/shader_sample/sample_sphere.rb +66 -0
  97. data/sample/shader_sample/sample_transition.rb +62 -0
  98. data/sample/shader_sample/sample_vertexshader.rb +223 -0
  99. data/sample/shader_sample/sample_wingman.rb +47 -0
  100. data/sample/shader_sample/turn_transition.rb +74 -0
  101. metadata +141 -0
@@ -0,0 +1,292 @@
1
+ #!ruby -Ks
2
+ require 'dxruby'
3
+
4
+ Window.mag_filter = TEXF_POINT
5
+ TO_RAD = Math::PI / 180
6
+ TO_DEG = 1 / Math::PI * 180
7
+
8
+ # �x�[�X�p�[�c
9
+ class BaseParts < Sprite
10
+ attr_accessor :next, :parts, :to_a
11
+ @@image = []
12
+ 40.times do |i|
13
+ @@image.push Image.new(60, 60).circle_fill(30, 30, 30, [255, 255*i/40, 255])
14
+ end
15
+
16
+ def initialize(x, y)
17
+ super
18
+
19
+ # �G��p�[�c����
20
+ prev_part = nil
21
+ parts1 = Array.new(8) do
22
+ temp = Parts.new # next�Ɏ��̃p�[�c�I�u�W�F�N�g������
23
+ prev_part.next = temp if prev_part
24
+ prev_part = temp
25
+ temp.joint_xp = 1 # �O�̃p�[�c����̐ڑ�x
26
+ temp.joint_yp = 10 # �O�̃p�[�c����̐ڑ�y
27
+ temp.joint_xn = 19 # ���̃p�[�c�ւ̐ڑ�x
28
+ temp.joint_yn = 10 # ���̃p�[�c�ւ̐ڑ�y
29
+ temp.collision = [10, 10, 10]
30
+ temp.joint_angle = 15
31
+ temp
32
+ end
33
+ prev_part = nil
34
+ parts2 = Array.new(8).map do
35
+ temp = Parts.new # next�Ɏ��̃p�[�c�I�u�W�F�N�g������
36
+ prev_part.next = temp if prev_part
37
+ prev_part = temp
38
+ temp.joint_xp = 1 # �O�̃p�[�c����̐ڑ�x
39
+ temp.joint_yp = 10 # �O�̃p�[�c����̐ڑ�y
40
+ temp.joint_xn = 19 # ���̃p�[�c�ւ̐ڑ�x
41
+ temp.joint_yn = 10 # ���̃p�[�c�ւ̐ڑ�y
42
+ temp.collision = [10, 10, 10]
43
+ temp.joint_angle = -15
44
+ temp
45
+ end
46
+ parts2[0].joint_angle_base = 180
47
+
48
+ self.image = @@image[0]
49
+ self.x = x
50
+ self.y = y
51
+ self.collision = [30, 30, 30]
52
+ @parts= [parts1, parts2]
53
+ @next = [[58, 30, parts1[0]], [2, 30, parts2[0]]]
54
+ @hp = 8000
55
+ @to_a = [self] + parts[0] + parts[1]
56
+ @count = 0
57
+ guide
58
+ update
59
+ end
60
+
61
+ # �`��ʒu�A�p�x����
62
+ def update
63
+ self.image = @@image[0]
64
+ @hitcount = 0
65
+ if @count == 0
66
+ self.y += 0.4
67
+ self.scale_x = self.scale_y = (@hp / 8000.0) * 0.5 + 0.5
68
+ @next[0][0] = (58.0 - center_x) * self.scale_x + center_x
69
+ @next[1][0] = (2.0 - center_x) * self.scale_x + center_x
70
+ @next.each do |ary|
71
+ ary[2].update(ary[0] + self.x, ary[1] + self.y, 0)
72
+ end
73
+ vanish if self.y > 480 + 100
74
+ end
75
+ end
76
+
77
+ # �`��
78
+ def draw
79
+ super
80
+ if @count == 0
81
+ @parts[0].each do |ary|
82
+ ary.draw
83
+ end
84
+ @parts[1].each do |ary|
85
+ ary.draw
86
+ end
87
+ else
88
+ @count += 1
89
+ vanish if @count > 60
90
+ self.scale_x += 0.1
91
+ self.scale_y += 0.1
92
+ self.alpha -= 4
93
+ @parts[0].each do |ary|
94
+ ary.scale_x += 0.1
95
+ ary.scale_y += 0.1
96
+ ary.alpha -= 4
97
+ ary.draw
98
+ end
99
+ @parts[1].each do |ary|
100
+ ary.scale_x += 0.1
101
+ ary.scale_y += 0.1
102
+ ary.alpha -= 4
103
+ ary.draw
104
+ end
105
+ end
106
+ end
107
+
108
+ # �}�E�X�J�[�\���ɂނ����ėU��
109
+ def guide
110
+ if @count == 0
111
+ @parts[0][7].guide
112
+ @parts[1][7].guide
113
+ end
114
+ end
115
+
116
+ def hit
117
+ @hp -= 1
118
+ self.image = @@image[@hitcount]
119
+ @hitcount += 1
120
+ if @hp <= 0
121
+ @count = 1
122
+ @to_a = []
123
+ end
124
+ end
125
+ end
126
+
127
+ # �G��p�[�c
128
+ class Parts < Sprite
129
+ attr_accessor :prev, :joint_xp, :joint_yp, :joint_xn, :joint_yn, :joint_angle, :joint_angle_base
130
+ attr_reader :next
131
+ @@image1 = Image.new(20,20).circle_fill(10,10,10,[255,0,0]).circle_fill(10,10,8,[255,160,160])
132
+ @@image2 = Image.new(20,20).circle_fill(10,10,10,[255,200,200]).circle_fill(10,10,8,[255,240,240])
133
+
134
+ def initialize
135
+ super
136
+ @next = nil
137
+ @joint_xp = @joint_yp = @joint_xn = @joint_yn = @joint_angle = @joint_angle_base = 0
138
+ @ang = 0
139
+ self.image = @@image1
140
+ end
141
+
142
+ def next=(n)
143
+ @next = n
144
+ n.prev = self
145
+ end
146
+
147
+ # �`��ʒu�A�p�x����
148
+ def update(jx = nil, jy = nil, angle = 0)
149
+ self.image = @@image1
150
+ a = @ang * TO_RAD
151
+ sina = Math.sin(a)
152
+ cosa = Math.cos(a)
153
+ tempx = -@joint_xp + center_x
154
+ tempy = -@joint_yp + center_y
155
+ @joint_angle += rand() * 1.2 - 0.6
156
+ @ang = @joint_angle + angle + @joint_angle_base
157
+ self.x = tempx * cosa - tempy * sina + jx - center_x
158
+ self.y = tempx * sina + tempy * cosa + jy - center_y
159
+ if @next
160
+ x = -@joint_xp + @joint_xn
161
+ y = -@joint_yp + @joint_yn
162
+ jnx = x * cosa - y * sina + jx
163
+ jny = x * sina + y * cosa + jy
164
+ @next.update(jnx, jny, @ang)
165
+ end
166
+ end
167
+
168
+ # �}�E�X�J�[�\���ɂނ����ėU��
169
+ def guide
170
+ mx = Input.mouse_pos_x
171
+ my = Input.mouse_pos_y
172
+ a = @ang * TO_RAD
173
+ sina = Math.sin(a)
174
+ cosa = Math.cos(a)
175
+ tempx = @joint_xn - center_x
176
+ tempy = @joint_yn - center_y
177
+ x = tempx * cosa - tempy * sina + self.x + center_x
178
+ y = tempx * sina + tempy * cosa + self.y + center_y
179
+ mangle = Math.atan2(my - y, mx - x) * TO_DEG
180
+ angle = (mangle + (180 - (@ang % 360))) % 360
181
+
182
+ if 180 < angle
183
+ @joint_angle = @joint_angle + 1
184
+ if @joint_angle > 30
185
+ @joint_angle = 30
186
+ @prev.guide if @prev
187
+ end
188
+ elsif 180 > angle
189
+ @joint_angle = @joint_angle - 1
190
+ if @joint_angle < -30
191
+ @joint_angle = -30
192
+ @prev.guide if @prev
193
+ end
194
+ end
195
+ end
196
+
197
+ def hit
198
+ self.image = @@image2
199
+ end
200
+ end
201
+
202
+ class Laser
203
+ @@image_houdai = Image.new(10,10,[0,255,0])
204
+
205
+ def initialize(x, y)
206
+ @s = []
207
+ 20.times do |i|
208
+ t = Sprite.new(x, y, Image.new(20, 1)) # �c1�s�N�Z���̉����̉摜
209
+ t.image[i, 0] = [128, 255, 255, 255] # �Y���ӏ��ɓ_������
210
+ t.scale_y = 800 # ����
211
+ t.center_x = 10 # �摜�̐^��
212
+ t.center_y = 1 # �摜�̉��̒[
213
+ t.collision = [i, 0, i, 0] # ��`��1�s�N�Z���̔���͈�
214
+ @s.push t
215
+ end
216
+ @s_collision = Sprite.new(x, y, Image.new(20, 1, [128, 255, 255, 255]))
217
+ @s_collision.collision = [0, 0, 19, 0]
218
+ @s_collision.scale_y = 800
219
+ @s_collision.center_x = 10 # �摜�̐^��
220
+ @s_collision.center_y = 1 # �摜�̉��̒[
221
+ end
222
+
223
+ # ���[�U�[���ˁA�G�Ƃ̏Փ˔��肨��ѕ`��
224
+ def update
225
+ if Input.mouse_down?(M_LBUTTON)
226
+ mx = Input.mouse_pos_x
227
+ my = Input.mouse_pos_y
228
+ es = []
229
+ Enemy.each do |e|
230
+ es += e.to_a
231
+ end
232
+ @s_collision.angle = angle = Math.atan2(mx - @s_collision.x, @s_collision.y - my) * TO_DEG
233
+ collision_ary = @s_collision.check(es)
234
+ if collision_ary.size > 0
235
+ @s.each do |i|
236
+ i.angle = angle
237
+ i.scale_y = 640000 #800**2
238
+ temp = i.check(collision_ary)
239
+ if temp.size > 0
240
+ min_length = 640000 #800**2
241
+ min_obj = nil
242
+ temp.each do |e|
243
+ length = ((e.x + e.center_x) - (i.x+10))**2 + ((e.y + e.center_y) - (i.y+10))**2
244
+ if min_length > length
245
+ min_obj = e
246
+ min_length = length
247
+ end
248
+ end
249
+ i.scale_y = min_length
250
+ min_obj.hit
251
+ end
252
+ i.scale_y = Math::sqrt(i.scale_y)
253
+ i.draw
254
+ end
255
+ else
256
+ @s_collision.draw
257
+ end
258
+ end
259
+ Window.draw(150,470,@@image_houdai)
260
+ Window.draw(510,470,@@image_houdai)
261
+ end
262
+ end
263
+
264
+ Enemy = [BaseParts.new(rand()*400+120, -100)]
265
+ laser = [Laser.new(145, 474), Laser.new(505, 474)]
266
+
267
+ x = 145
268
+ y = 474
269
+ count = 0
270
+ font = Font.new(32)
271
+
272
+ Window.loop do
273
+ count += 1
274
+ if count > 280
275
+ Enemy.push BaseParts.new(rand()*400+120, -100)
276
+ count = 0
277
+ end
278
+
279
+ Enemy.each do |e|
280
+ e.guide
281
+ e.update
282
+ end
283
+ Sprite.clean(Enemy)
284
+
285
+ Sprite.update(laser)
286
+ Sprite.draw(Enemy)
287
+
288
+ Window.drawFont(0,0,Window.getLoad.to_i.to_s + " %", font, :z=>3)
289
+
290
+ break if Input.key_push?(K_ESCAPE)
291
+ end
292
+
@@ -0,0 +1,249 @@
1
+ #!ruby -Ks
2
+ require 'dxruby'
3
+
4
+ class Vector
5
+ def initialize(*v)
6
+ @vec = v
7
+ end
8
+
9
+ def rotate(angle)
10
+ x = @vec[0] * Math.cos(Math::PI / 180 * angle) - @vec[1] * Math.sin(Math::PI / 180 * angle)
11
+ y = @vec[0] * Math.sin(Math::PI / 180 * angle) + @vec[1] * Math.cos(Math::PI / 180 * angle)
12
+ temp = @vec.dup
13
+ temp[0] = x
14
+ temp[1] = y
15
+ Vector.new(*temp)
16
+ end
17
+
18
+ def +(v)
19
+ case v
20
+ when Vector
21
+ Vector.new(*@vec.map.with_index{|s,i|s+v[i]})
22
+ when Array
23
+ Vector.new(*@vec.map.with_index{|s,i|s+v[i]})
24
+ when Numeric
25
+ Vector.new(*@vec.map{|s|s+v})
26
+ else
27
+ nil
28
+ end
29
+ end
30
+
31
+ def *(matrix)
32
+ result = []
33
+ for i in 0..(matrix.size-1)
34
+ data = 0
35
+ for j in 0..(@vec.size-1)
36
+ data += @vec[j] * matrix[j][i]
37
+ end
38
+ result.push(data)
39
+ end
40
+ return Vector.new(*result)
41
+ end
42
+
43
+ def [](i)
44
+ @vec[i]
45
+ end
46
+
47
+ def size
48
+ @vec.size
49
+ end
50
+
51
+ def to_a
52
+ @vec
53
+ end
54
+
55
+ def x
56
+ @vec[0]
57
+ end
58
+ def y
59
+ @vec[1]
60
+ end
61
+ def z
62
+ @vec[2]
63
+ end
64
+ def w
65
+ @vec[3]
66
+ end
67
+ end
68
+
69
+ class Matrix
70
+ def initialize(*arr)
71
+ @arr = Array.new(4) {|i| Vector.new(*arr[i])}
72
+ end
73
+
74
+ def *(a)
75
+ result = []
76
+ for i in 0..(a.size-1)
77
+ result.push(@arr[i] * a)
78
+ end
79
+ return Matrix.new(*result)
80
+ end
81
+
82
+ def [](i)
83
+ @arr[i]
84
+ end
85
+
86
+ def size
87
+ @arr.size
88
+ end
89
+
90
+ def self.create_rotation_z(angle)
91
+ cos = Math.cos(Math::PI/180 * angle)
92
+ sin = Math.sin(Math::PI/180 * angle)
93
+ return Matrix.new(
94
+ [ cos, sin, 0, 0],
95
+ [-sin, cos, 0, 0],
96
+ [ 0, 0, 1, 0],
97
+ [ 0, 0, 0, 1]
98
+ )
99
+ end
100
+
101
+ def self.create_rotation_x(angle)
102
+ cos = Math.cos(Math::PI/180 * angle)
103
+ sin = Math.sin(Math::PI/180 * angle)
104
+ return Matrix.new(
105
+ [ 1, 0, 0, 0],
106
+ [ 0, cos, sin, 0],
107
+ [ 0,-sin, cos, 0],
108
+ [ 0, 0, 0, 1]
109
+ )
110
+ end
111
+
112
+ def self.create_rotation_y(angle)
113
+ cos = Math.cos(Math::PI/180 * angle)
114
+ sin = Math.sin(Math::PI/180 * angle)
115
+ return Matrix.new(
116
+ [ cos, 0,-sin, 0],
117
+ [ 0, 1, 0, 0],
118
+ [ sin, 0, cos, 0],
119
+ [ 0, 0, 0, 1]
120
+ )
121
+ end
122
+
123
+ def self.create_transration(x, y, z)
124
+ return Matrix.new(
125
+ [ 1, 0, 0, 0],
126
+ [ 0, 1, 0, 0],
127
+ [ 0, 0, 1, 0],
128
+ [ x, y, z, 1]
129
+ )
130
+ end
131
+
132
+ def to_a
133
+ @arr.map {|v|v.to_a}.flatten
134
+ end
135
+ end
136
+
137
+
138
+ line1 = [568, 438, 568, 438, 607, 261, 607, 261, 520, 200, 520, 200, 531, 151,
139
+ 531, 151, 602, 115, 602, 115, 562, 19, 562, 19, 113, 21, 113, 21, 34, 83,
140
+ 34, 83, 81, 180, 81, 180, 221, 207, 221, 207, 251, 274, 251, 274, 204, 299,
141
+ 204, 299, 61, 262, 61, 262, 26, 358, 26, 358, 53, 430]
142
+ line2 = [88, 380, 88, 380, 479, 392, 479, 392, 536, 302, 536, 302, 534, 267,
143
+ 534, 267, 461, 210, 461, 210, 459, 151, 459, 151, 518, 91, 518, 91, 487, 53,
144
+ 487, 53, 156, 77, 156, 77, 125, 110, 125, 110, 292, 197, 292, 197, 311, 268,
145
+ 311, 268, 227, 342, 227, 342, 93, 330]
146
+
147
+ $walls = []
148
+
149
+ class Wall < Sprite
150
+ attr_reader :height
151
+ def initialize(x1, y1, x2, y2, height)
152
+ super(0,0)
153
+ self.collision = [x1, y1, x2, y2, x2, y2]
154
+ @height = height
155
+ end
156
+ end
157
+
158
+
159
+ tx = 53
160
+ ty = 430
161
+ line1.each_slice(2) do |x, y|
162
+ $walls << Wall.new(tx, ty, x, y, 1)
163
+ tx = x
164
+ ty = y
165
+ end
166
+ tx = 93
167
+ ty = 330
168
+ line2.each_slice(2) do |x, y|
169
+ $walls << Wall.new(tx, ty, x, y, 1)
170
+ tx = x
171
+ ty = y
172
+ end
173
+
174
+
175
+ $ray = []
176
+ (0..639).each do |x|
177
+ s = Sprite.new(0,0)
178
+ temp = Vector.new(400,0).rotate((x / 639.0 * 2 - 1) * 30)
179
+ s.collision = [0, 0, temp.x, temp.y, temp.x, temp.y]
180
+ s.center_x = s.center_y = 0
181
+ $ray << s
182
+ end
183
+
184
+
185
+ x = 300
186
+ y = 400
187
+ angle = 0
188
+
189
+ image = Image.new(1,1,C_RED)
190
+
191
+ Window.loop do
192
+
193
+ angle += Input.x*5
194
+ if Input.key_down?(K_UP)
195
+ x += Math.cos(Math::PI / 180 * angle) * 3
196
+ y += Math.sin(Math::PI / 180 * angle) * 3
197
+ end
198
+ if Input.key_down?(K_DOWN)
199
+ x -= Math.cos(Math::PI / 180 * angle) * 3
200
+ y -= Math.sin(Math::PI / 180 * angle) * 3
201
+ end
202
+
203
+ $ray.each_with_index do |r, i|
204
+ r.x = x
205
+ r.y = y
206
+ r.angle = angle
207
+ ary = r.check($walls)
208
+ z = 250000
209
+ ax, ay = Vector.new(r.collision[0], r.collision[1]).rotate(angle).to_a
210
+ ax += r.x + 0.5
211
+ ay += r.y + 0.5
212
+ bx, by = Vector.new(r.collision[2], r.collision[3]).rotate(angle).to_a
213
+ bx += r.x + 0.5
214
+ by += r.y + 0.5
215
+ px = 0
216
+ py = 0
217
+ height = 0
218
+ if ary.size > 0 then
219
+ ary.each do |w|
220
+ cx = w.collision[0] + w.x + 0.5
221
+ cy = w.collision[1] + w.y + 0.5
222
+ dx = w.collision[2] + w.x + 0.5
223
+ dy = w.collision[3] + w.y + 0.5
224
+ tempx = dx-cx
225
+ tempy = dy-cy
226
+
227
+ dR = (tempy * (cx - ax) - tempx * (cy - ay) ) / ((bx - ax) * tempy - (by - ay) * tempx)
228
+
229
+ ix = ax + dR * (bx - ax)
230
+ iy = ay + dR * (by - ay)
231
+
232
+ length = (ix - r.x)**2 + (iy - r.y)**2
233
+
234
+ if length < z
235
+ z = length
236
+ px = ix
237
+ py = iy
238
+ height = w.height
239
+ end
240
+ end
241
+ z = Math::sqrt(z)
242
+ c = 255 - z / 400 * 255
243
+ Window.draw_line(i, 240 + 400.0 / z * 10, i, 240 - 400.0 / z * 10 * height, [c, c, c])
244
+ Window.draw(px, py, image)
245
+ end
246
+ end
247
+ break if Input.key_push?(K_ESCAPE)
248
+ end
249
+
@@ -0,0 +1,27 @@
1
+ DXRuby �T���v���v���O����
2
+
3
+ �܂��ŏ��ɁA�\�[�X�������Ă��߂�Ȃ����B
4
+ �e�L�g�[�ɍ�������̂������Q�l�ɂȂ�΂��Ċ����ŋl�ߍ���ł���܂��B
5
+
6
+ biyo.rb
7
+ �E�E�EWindow.draw_morph�̃T���v���ł��B�X�y�[�X�ŐL�΂��āA�����Ƃт��т�񂵂܂��B
8
+
9
+ laser2.rb
10
+ �E�E�Eclassic_sample��laser.rb�̋����łł��B�}�E�X�̃{�^���Ń��[�U�[�����Ă܂��B
11
+ �G��͑��֐ߏ������Ă���A���[�U�[��1�s�N�Z�����P�ʂŏՓ˔�������Ă��܂��B
12
+
13
+ rubima.rb
14
+ �E�E�E��т܂Ɋ�e�����T���v���V���[�e�B���O�ł��BRenderTarget��Sprite�𗘗p�����`�ɏC�����܂����B
15
+
16
+ sprite_animation.rb
17
+ �E�E�ESprite�ɃA�j���[�V�����@�\��lj�����T���v���ł��B
18
+
19
+ sprite_collision.rb
20
+ �E�E�E�e��Փ˔���̃T���v���ł��B
21
+
22
+ sprite_collision2.rb
23
+ �E�E�E�摜����]/�ړ������ē������Ă��邩�ǂ����𔻒肷��T���v���ł��B
24
+
25
+ sprite_simple.rb
26
+ �E�E�E�P����Sprite�̃T���v���ł��B
27
+