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.
- checksums.yaml +7 -0
- data/LICENSE.txt +14 -0
- data/README-ja.md +125 -0
- data/README.md +120 -0
- data/lib/31/dxruby.so +0 -0
- data/lib/32/dxruby.so +0 -0
- data/lib/33/dxruby.so +0 -0
- data/lib/34/dxruby.so +0 -0
- data/lib/dxruby.rb +2 -0
- data/sample/classic_sample/8_puzzle.rb +55 -0
- data/sample/classic_sample/block_destroy.rb +161 -0
- data/sample/classic_sample/block_fall.rb +194 -0
- data/sample/classic_sample/data.png +0 -0
- data/sample/classic_sample/dot.rb +80 -0
- data/sample/classic_sample/drawtile.rb +173 -0
- data/sample/classic_sample/flight.rb +75 -0
- data/sample/classic_sample/hitrangeview.rb +66 -0
- data/sample/classic_sample/mapedit.rb +270 -0
- data/sample/classic_sample/meiro.rb +106 -0
- data/sample/classic_sample/minsample.rb +14 -0
- data/sample/classic_sample/race.rb +119 -0
- data/sample/classic_sample/readme_sample.txt +42 -0
- data/sample/classic_sample/sample.rb +110 -0
- data/sample/classic_sample/soundeffect.rb +46 -0
- data/sample/new_sample/biyo.rb +25 -0
- data/sample/new_sample/image/enemy1.png +0 -0
- data/sample/new_sample/image/enemy1bomb.png +0 -0
- data/sample/new_sample/image/enemy2.png +0 -0
- data/sample/new_sample/image/enemy2bomb.png +0 -0
- data/sample/new_sample/image/enemyshot1.png +0 -0
- data/sample/new_sample/image/enemyshot2.png +0 -0
- data/sample/new_sample/image/maptile.png +0 -0
- data/sample/new_sample/image/myship.png +0 -0
- data/sample/new_sample/image/myshot.png +0 -0
- data/sample/new_sample/iraira.rb +49 -0
- data/sample/new_sample/laser2.rb +292 -0
- data/sample/new_sample/raycast.rb +249 -0
- data/sample/new_sample/readme_sample.txt +27 -0
- data/sample/new_sample/rubima.rb +597 -0
- data/sample/new_sample/ruby.png +0 -0
- data/sample/new_sample/slg.rb +82 -0
- data/sample/new_sample/sprite_animation.rb +133 -0
- data/sample/new_sample/sprite_collision1.rb +216 -0
- data/sample/new_sample/sprite_collision2.rb +93 -0
- data/sample/new_sample/sprite_simple.rb +65 -0
- data/sample/new_sample2/ImageFont.dat +0 -0
- data/sample/new_sample2/ImageFont.dat.png +0 -0
- data/sample/new_sample2/autocall.rb +24 -0
- data/sample/new_sample2/effecttest.rb +136 -0
- data/sample/new_sample2/fibersprite.rb +89 -0
- data/sample/new_sample2/hitrange.rb +133 -0
- data/sample/new_sample2/hlstest.rb +27 -0
- data/sample/new_sample2/mapedit_perlin.rb +291 -0
- data/sample/new_sample2/noise.rb +33 -0
- data/sample/new_sample2/particle.rb +220 -0
- data/sample/new_sample2/readme_sample.txt +29 -0
- data/sample/new_sample2/scenetest.rb +200 -0
- data/sample/new_sample2/scenetest2.rb +120 -0
- data/sample/scroll_sample/map.dat +32 -0
- data/sample/scroll_sample/map.rb +77 -0
- data/sample/scroll_sample/map_sub.dat +32 -0
- data/sample/scroll_sample/mapedit.rb +102 -0
- data/sample/scroll_sample/readme_sample.txt +24 -0
- data/sample/scroll_sample/scroll1.rb +108 -0
- data/sample/scroll_sample/scroll2.rb +149 -0
- data/sample/scroll_sample/scroll3.rb +148 -0
- data/sample/scroll_sample/simple.rb +13 -0
- data/sample/shader_sample/Shader/Flash.rb +93 -0
- data/sample/shader_sample/Shader/RasterScroll.rb +71 -0
- data/sample/shader_sample/Shader/RgssSprite.rb +143 -0
- data/sample/shader_sample/Shader/Transition.rb +108 -0
- data/sample/shader_sample/bgimage/BG00a1_80.jpg +0 -0
- data/sample/shader_sample/bgimage/BG10a_80.jpg +0 -0
- data/sample/shader_sample/bgimage/BG13a_80.jpg +0 -0
- data/sample/shader_sample/bgimage/BG32a.jpg +0 -0
- data/sample/shader_sample/bgimage/BG42a.jpg +0 -0
- data/sample/shader_sample/bgimage/course.png +0 -0
- data/sample/shader_sample/bgimage/image1.png +0 -0
- data/sample/shader_sample/bgimage/world_map2.png +0 -0
- data/sample/shader_sample/fan.rb +53 -0
- data/sample/shader_sample/image/enemy1.png +0 -0
- data/sample/shader_sample/image/enemy2.png +0 -0
- data/sample/shader_sample/image/maptile.png +0 -0
- data/sample/shader_sample/readme_sample.txt +43 -0
- data/sample/shader_sample/rule//343/203/201/343/202/247/343/203/203/343/202/253/343/203/274.png +0 -0
- data/sample/shader_sample/rule//345/217/263/346/270/246/345/267/273/343/201/215.png +0 -0
- 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
- data/sample/shader_sample/sample_blur.rb +112 -0
- data/sample/shader_sample/sample_divide.rb +91 -0
- data/sample/shader_sample/sample_flash.rb +54 -0
- data/sample/shader_sample/sample_lens.rb +65 -0
- data/sample/shader_sample/sample_mapping.rb +50 -0
- data/sample/shader_sample/sample_rasterscroll.rb +48 -0
- data/sample/shader_sample/sample_rgsssprite.rb +41 -0
- data/sample/shader_sample/sample_spehari.rb +50 -0
- data/sample/shader_sample/sample_sphere.rb +66 -0
- data/sample/shader_sample/sample_transition.rb +62 -0
- data/sample/shader_sample/sample_vertexshader.rb +223 -0
- data/sample/shader_sample/sample_wingman.rb +47 -0
- data/sample/shader_sample/turn_transition.rb +74 -0
- metadata +141 -0
@@ -0,0 +1,597 @@
|
|
1
|
+
#!ruby -Ks
|
2
|
+
# ��т܃T���v���Q�[��
|
3
|
+
require 'dxruby'
|
4
|
+
|
5
|
+
# �w�i�`��
|
6
|
+
class Map
|
7
|
+
@@map = [[0, 0, 0, 0, 0, 0, 0, 0, 29, 11, 11, 30, 34, 66, 67, 67],
|
8
|
+
[0, 0, 0, 24, 25, 26, 0, 0, 29, 11, 11, 39, 40, 6, 34, 34],
|
9
|
+
[0, 0, 24, 17, 31, 35, 0, 0, 12, 20, 11, 11, 11, 39, 40, 40],
|
10
|
+
[0, 24, 17, 34, 7, 44, 0, 28, 28, 29, 11, 11, 11, 11, 11, 11],
|
11
|
+
[0, 33, 31, 34, 35, 0, 28, 3, 37, 38, 11, 11, 11, 18, 19, 19],
|
12
|
+
[0, 42, 43, 43, 44, 28, 3, 38, 11, 11, 11, 18, 19, 13, 28, 28],
|
13
|
+
[0, 0, 0, 0, 3, 37, 38, 11, 11, 18, 19, 13, 28, 28, 28, 0],
|
14
|
+
[0, 0, 0, 3, 38, 11, 11, 11, 18, 13, 28, 28, 51, 52, 52, 52],
|
15
|
+
[0, 0, 3, 38, 11, 11, 18, 19, 13, 51, 52, 52, 86, 58, 61, 76],
|
16
|
+
[28, 0, 29, 11, 11, 18, 13, 28, 51, 86, 58, 58, 61, 61, 58, 62],
|
17
|
+
[0, 28, 29, 11, 18, 13, 28, 0, 60, 58, 61, 61, 61, 61, 76, 71],
|
18
|
+
[0, 28, 29, 11, 27, 28, 28, 51, 86, 61, 61, 58, 76, 70, 71, 0],
|
19
|
+
[0, 0, 29, 11, 36, 4, 28, 60, 58, 61, 58, 76, 71, 0, 1, 2],
|
20
|
+
[0, 28, 29, 11, 11, 36, 4, 69, 70, 70, 70, 71, 0, 1, 2, 0],
|
21
|
+
[0, 0, 12, 20, 11, 11, 27, 0, 1, 0, 1, 1, 1, 2, 2, 0],
|
22
|
+
[0, 0, 28, 12, 20, 11, 27, 0, 0, 0, 2, 2, 0, 2, 2, 0],
|
23
|
+
[0, 0, 0, 2, 29, 11, 27, 1, 2, 2, 2, 0, 0, 2, 2, 2],
|
24
|
+
[0, 0, 0, 2, 29, 11, 27, 1, 0, 1, 1, 2, 2, 0, 0, 2],
|
25
|
+
[0, 0, 0, 0, 29, 11, 27, 1, 0, 2, 2, 2, 1, 1, 2, 2],
|
26
|
+
[0, 45, 47, 2, 29, 11, 36, 4, 1, 2, 2, 0, 0, 2, 2, 0],
|
27
|
+
[45, 82, 56, 0, 29, 11, 11, 36, 4, 1, 2, 2, 2, 2, 0, 0],
|
28
|
+
[54, 0, 56, 0, 12, 20, 11, 11, 36, 37, 4, 0, 2, 2, 2, 2],
|
29
|
+
[54, 55, 81, 46, 47, 12, 20, 11, 11, 11, 36, 4, 1, 1, 1, 2],
|
30
|
+
[54, 55, 0, 0, 56, 0, 12, 19, 20, 11, 11, 36, 37, 4, 1, 1],
|
31
|
+
[54, 0, 55, 55, 56, 0, 0, 0, 12, 20, 11, 11, 11, 36, 37, 37],
|
32
|
+
[63, 73, 55, 55, 56, 0, 0, 2, 2, 29, 11, 11, 11, 11, 11, 11],
|
33
|
+
[0, 54, 0, 55, 81, 47, 0, 2, 3, 38, 11, 11, 11, 11, 11, 11],
|
34
|
+
[0, 54, 0, 0, 55, 56, 2, 0, 29, 11, 11, 11, 21, 22, 22, 22],
|
35
|
+
[0, 63, 64, 64, 64, 65, 0, 0, 29, 11, 11, 21, 15, 48, 49, 49],
|
36
|
+
[0, 0, 0, 0, 0, 0, 0, 0, 29, 11, 11, 30, 34, 57, 34, 34],
|
37
|
+
]
|
38
|
+
temp = Image.load("image/maptile.png")
|
39
|
+
x = temp.width / 32
|
40
|
+
y = temp.height / 32
|
41
|
+
@@images = temp.slice_tiles(x, y, true)
|
42
|
+
|
43
|
+
# ������
|
44
|
+
def initialize
|
45
|
+
@y = 14 * 32 # �}�b�v�̏����ʒu
|
46
|
+
@count = 0 # 1�`�b�v�Ԃ�ړ�����t���[����
|
47
|
+
end
|
48
|
+
|
49
|
+
# �}�b�v�X�V
|
50
|
+
def update
|
51
|
+
@count -= 1
|
52
|
+
end
|
53
|
+
|
54
|
+
# �}�b�v�`��
|
55
|
+
def draw
|
56
|
+
$rt.draw_tile(0, 0, @@map, @@images, 0, @y + @count, 16, 16, 0)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# �G�P�̂��ꏈ��
|
61
|
+
class Enemy1bomb < Sprite
|
62
|
+
@@image0 = Image.load_tiles("image/enemy1bomb.png", 4, 2, true)
|
63
|
+
@@image1 = @@image0.map {|image| image.flush([128, 0, 0, 0])}
|
64
|
+
|
65
|
+
# �C���X�^���X������
|
66
|
+
def initialize(x, y)
|
67
|
+
super(x, y)
|
68
|
+
self.z = 10
|
69
|
+
self.target = $rt
|
70
|
+
@count = 0
|
71
|
+
end
|
72
|
+
|
73
|
+
# �X�V
|
74
|
+
def update
|
75
|
+
self.y += 1.5
|
76
|
+
@count += 1
|
77
|
+
if @count >= 40
|
78
|
+
self.vanish
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# �`��
|
83
|
+
def draw
|
84
|
+
self.image = @@image0[@count / 5]
|
85
|
+
super
|
86
|
+
$rt.draw(self.x-16, self.y-16, @@image1[@count / 5], 1)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# �G�Q�̂��ꏈ��
|
91
|
+
class Enemy2bomb < Sprite
|
92
|
+
@@image0 = Image.load_tiles("image/enemy2bomb.png", 4, 2, true)
|
93
|
+
@@image1 = @@image0.map {|image| image.flush([128, 0, 0, 0])}
|
94
|
+
|
95
|
+
# �C���X�^���X������
|
96
|
+
def initialize(x, y)
|
97
|
+
super(x, y)
|
98
|
+
self.z = 10
|
99
|
+
self.target = $rt
|
100
|
+
@count = 0
|
101
|
+
end
|
102
|
+
|
103
|
+
# �X�V
|
104
|
+
def update
|
105
|
+
self.y += 0.5
|
106
|
+
@count += 1
|
107
|
+
if @count >= 40
|
108
|
+
self.vanish
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# �`��
|
113
|
+
def draw
|
114
|
+
self.image = @@image0[@count / 5]
|
115
|
+
super
|
116
|
+
$rt.draw(self.x-16, self.y-16, @@image1[@count / 5], 1)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# �G�P�p�V���b�g�q�b�g��
|
121
|
+
class EnemyShot1Hit < Sprite
|
122
|
+
@@image = Image.load("image/enemyshot1.png")
|
123
|
+
|
124
|
+
# �C���X�^���X������
|
125
|
+
def initialize(x, y, angle)
|
126
|
+
super(x, y, @@image)
|
127
|
+
self.z = 20
|
128
|
+
self.alpha = 255
|
129
|
+
self.target = $rt
|
130
|
+
temp2 = angle + 180
|
131
|
+
@dx = Math.cos((temp2) / 180.0 * Math::PI)
|
132
|
+
@dy = Math.sin((temp2) / 180.0 * Math::PI)
|
133
|
+
end
|
134
|
+
|
135
|
+
# �X�V
|
136
|
+
def update
|
137
|
+
self.x += @dx
|
138
|
+
self.y += @dy
|
139
|
+
self.alpha -= 10
|
140
|
+
|
141
|
+
if self.alpha < 0
|
142
|
+
self.vanish
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# �G�P�p�V���b�g
|
148
|
+
class EnemyShot1 < Sprite
|
149
|
+
@@image = Image.load("image/enemyshot1.png")
|
150
|
+
@@sound = Array.new(3) do
|
151
|
+
v = 60
|
152
|
+
SoundEffect.new(60,WAVE_TRI) do
|
153
|
+
v = v - 1
|
154
|
+
[800, v]
|
155
|
+
end
|
156
|
+
end
|
157
|
+
@@soundnumber = 0
|
158
|
+
@@soundflag = false
|
159
|
+
|
160
|
+
# �C���X�^���X������
|
161
|
+
def initialize(x, y, angle)
|
162
|
+
super(x, y, @@image)
|
163
|
+
self.z = 20
|
164
|
+
self.collision = [4, 4, 11, 11]
|
165
|
+
self.target = $rt
|
166
|
+
@dx = Math.cos(angle / 180.0 * Math::PI) * 1.5
|
167
|
+
@dy = Math.sin(angle / 180.0 * Math::PI) * 1.5
|
168
|
+
@shot_angle = angle
|
169
|
+
end
|
170
|
+
|
171
|
+
# �X�V
|
172
|
+
def update
|
173
|
+
self.x += @dx
|
174
|
+
self.y += @dy
|
175
|
+
@@soundflag = false
|
176
|
+
end
|
177
|
+
|
178
|
+
def shot(obj)
|
179
|
+
self.vanish
|
180
|
+
$etc_objects << EnemyShot1Hit.new(self.x, self.y, @shot_angle)
|
181
|
+
if @@soundflag == false
|
182
|
+
@@sound[@@soundnumber].play
|
183
|
+
@@soundnumber += 1
|
184
|
+
@@soundnumber = 0 if @@soundnumber > 2
|
185
|
+
@@soundflag = true
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
# �G�Q�p�V���b�g�q�b�g��
|
191
|
+
class EnemyShot2Hit < Sprite
|
192
|
+
@@image = Image.load("image/enemyshot2.png")
|
193
|
+
|
194
|
+
# �C���X�^���X������
|
195
|
+
def initialize(x, y, angle)
|
196
|
+
super(x, y, @@image)
|
197
|
+
self.z = 20
|
198
|
+
self.alpha = 255 # �A���t�@�l
|
199
|
+
self.target = $rt
|
200
|
+
temp2 = angle + 180
|
201
|
+
@dx = Math.cos((temp2) / 180.0 * Math::PI) * 3.5
|
202
|
+
@dy = Math.sin((temp2) / 180.0 * Math::PI) * 3.5
|
203
|
+
end
|
204
|
+
|
205
|
+
# �X�V
|
206
|
+
def update
|
207
|
+
# �ړ�
|
208
|
+
self.x += @dx
|
209
|
+
self.y += @dy
|
210
|
+
self.alpha -= 10
|
211
|
+
if self.alpha < 0
|
212
|
+
self.vanish
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
# �G�Q�p�V���b�g
|
218
|
+
class EnemyShot2 < Sprite
|
219
|
+
@@image = Image.load("image/enemyshot2.png")
|
220
|
+
v = 60
|
221
|
+
@@sound = Array.new(3) do
|
222
|
+
v = 60
|
223
|
+
SoundEffect.new(60,WAVE_TRI) do
|
224
|
+
v = v - 1
|
225
|
+
[600, v]
|
226
|
+
end
|
227
|
+
end
|
228
|
+
@@soundnumber = 0
|
229
|
+
@@soundflag = false
|
230
|
+
|
231
|
+
# �C���X�^���X������
|
232
|
+
def initialize(x, y, angle)
|
233
|
+
super(x, y, @@image)
|
234
|
+
self.z = 20
|
235
|
+
self.collision = [6, 6, 17, 17]
|
236
|
+
self.target = $rt
|
237
|
+
@dx = Math.cos(angle / 180.0 * Math::PI) * 3.5
|
238
|
+
@dy = Math.sin(angle / 180.0 * Math::PI) * 3.5
|
239
|
+
@shot_angle = angle
|
240
|
+
end
|
241
|
+
|
242
|
+
# �X�V
|
243
|
+
def update
|
244
|
+
# �ړ�
|
245
|
+
self.x += @dx
|
246
|
+
self.y += @dy
|
247
|
+
@@soundflag = false
|
248
|
+
end
|
249
|
+
|
250
|
+
# ���@�ɓ��������Ƃ��ɌĂ�郁�\�b�h
|
251
|
+
def shot(obj)
|
252
|
+
self.vanish
|
253
|
+
$etc_objects << EnemyShot2Hit.new(self.x, self.y, @shot_angle)
|
254
|
+
if @@soundflag == false
|
255
|
+
@@sound[@@soundnumber].play
|
256
|
+
@@soundnumber += 1
|
257
|
+
@@soundnumber = 0 if @@soundnumber > 2
|
258
|
+
@@soundflag = true
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
# �G�P
|
264
|
+
class Enemy1 < Sprite
|
265
|
+
# �摜�ǂݍ��݁��t���b�V��/�e�摜����
|
266
|
+
image0 = Image.load_tiles("image/enemy1.png", 4, 1, true) # �ǂݍ���
|
267
|
+
image1 = image0.map {|image| image.flush([255, 200, 200, 200])}
|
268
|
+
image2 = image0.map {|image| image.flush([128, 0, 0, 0])}
|
269
|
+
@@image = [image0, image1, image2]
|
270
|
+
|
271
|
+
# SoundEffect�ł�����ʉ������B�R�܂ł̑��d�Đ����ł���悤�z�B
|
272
|
+
@@sound = Array.new(3) do
|
273
|
+
v = 60
|
274
|
+
f = 500
|
275
|
+
SoundEffect.new(120,WAVE_SAW) do
|
276
|
+
v = v - 0.5
|
277
|
+
f = f - 1
|
278
|
+
[f, v]
|
279
|
+
end
|
280
|
+
end
|
281
|
+
@@soundnumber = 0
|
282
|
+
@@soundflag = false
|
283
|
+
|
284
|
+
# �C���X�^���X������
|
285
|
+
def initialize(x, y)
|
286
|
+
super(x, y)
|
287
|
+
self.z = 10
|
288
|
+
self.collision = [0, 0, 47, 47] # �Փ˔���
|
289
|
+
self.target = $rt
|
290
|
+
@hp = 15 # �q�b�g�|�C���g
|
291
|
+
@shotcount = 0 # �e�����Ԋu�𑪂�J�E���^
|
292
|
+
@imagenumber = 0 # ��e������1(�t���b�V����\��)
|
293
|
+
@animecount = 0 # �A�j���[�V�����p�J�E���^
|
294
|
+
end
|
295
|
+
|
296
|
+
# �X�V
|
297
|
+
def update
|
298
|
+
# �ړ�
|
299
|
+
self.y += 2
|
300
|
+
|
301
|
+
# �e��������
|
302
|
+
@shotcount += 1
|
303
|
+
if @shotcount > 40
|
304
|
+
# �p�x�v�Z
|
305
|
+
angle = (Math.atan2($myship.y + 16 - (self.y + 24 + 8), $myship.x + 16 - (self.x + 16 + 8)) / Math::PI * 180)
|
306
|
+
|
307
|
+
# �e������
|
308
|
+
$enemy_shots << EnemyShot1.new(self.x + 16, self.y + 24, angle)
|
309
|
+
|
310
|
+
# �J�E���g������
|
311
|
+
@shotcount = 0
|
312
|
+
end
|
313
|
+
|
314
|
+
# �Ƃ肠�����t���[���A�t���b�V�����Ă��Ȃ���Ԃɂ���
|
315
|
+
@imagenumber = 0
|
316
|
+
|
317
|
+
# �A�j���[�V�����p�J�E���g
|
318
|
+
@animecount += 1
|
319
|
+
@animecount -= 80 if @animecount >= 80
|
320
|
+
|
321
|
+
@@soundflag = false
|
322
|
+
end
|
323
|
+
|
324
|
+
# ���@�V���b�g�ɓ��������Ƃ��ɌĂ�郁�\�b�h
|
325
|
+
def hit(obj)
|
326
|
+
# HP�����炷
|
327
|
+
@hp = @hp - obj.damage
|
328
|
+
|
329
|
+
# ���ꏈ��
|
330
|
+
if @hp <= 0
|
331
|
+
self.vanish
|
332
|
+
$etc_objects << Enemy1bomb.new(self.x, self.y)
|
333
|
+
|
334
|
+
# ������ʉ��̑��d�Đ�
|
335
|
+
if @@soundflag == false
|
336
|
+
@@sound[@@soundnumber].play
|
337
|
+
@@soundnumber += 1
|
338
|
+
@@soundnumber = 0 if @@soundnumber > 2
|
339
|
+
@@soundflag = true
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
# �t���b�V�����ɂ���
|
344
|
+
@imagenumber = 1
|
345
|
+
end
|
346
|
+
|
347
|
+
def draw
|
348
|
+
self.image = @@image[@imagenumber][@animecount / 20]
|
349
|
+
super
|
350
|
+
$rt.draw(self.x-16, self.y-16, @@image[2][@animecount / 20], 1)
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
# �G�Q
|
355
|
+
class Enemy2 < Sprite
|
356
|
+
# �摜�ǂݍ��݁��t���b�V��/�e�摜����
|
357
|
+
image0 = Image.load_tiles("image/enemy2.png", 4, 1, true) # �ǂݍ���
|
358
|
+
image1 = image0.map {|image| image.flush([255, 200, 200, 200])}
|
359
|
+
image2 = image0.map {|image| image.flush([128, 0, 0, 0])}
|
360
|
+
@@image = [image0, image1, image2]
|
361
|
+
v = 80
|
362
|
+
@@sound = SoundEffect.new(4000,WAVE_RECT, 5000) do
|
363
|
+
v = v - 0.03
|
364
|
+
[rand(300), v]
|
365
|
+
end
|
366
|
+
|
367
|
+
# �C���X�^���X������
|
368
|
+
def initialize(x, y)
|
369
|
+
super(x, y)
|
370
|
+
self.z = 10
|
371
|
+
self.collision = [0, 0, 127, 63] # �Փ˔���
|
372
|
+
self.target = $rt
|
373
|
+
@dy = 10 # �c�ړ���
|
374
|
+
@hp = 400 # �q�b�g�|�C���g
|
375
|
+
@shotcount = 0 # �e�����Ԋu�𑪂�J�E���^
|
376
|
+
@imagenumber = 0 # ��e������1(�t���b�V����\��)
|
377
|
+
@animecount = 0 # �A�j���[�V�����p�J�E���^
|
378
|
+
end
|
379
|
+
|
380
|
+
# �X�V
|
381
|
+
def update
|
382
|
+
# �ړ�
|
383
|
+
self.y += @dy
|
384
|
+
|
385
|
+
if @dy > 0 # ���Ɉړ���
|
386
|
+
@dy -= 0.3 # ����
|
387
|
+
else # �ړ��������Ă�����
|
388
|
+
@shotcount += 1 # �V���b�g�J�E���g�𑫂���
|
389
|
+
if @shotcount > 60 # �J�E���g��60������e������
|
390
|
+
# �p�x�v�Z
|
391
|
+
angle = (Math.atan2($myship.y + 16 - (self.y + 40 + 12), $myship.x + 16 - (self.x + 56 + 12)) / Math::PI * 180)
|
392
|
+
# 5������
|
393
|
+
$enemy_shots << EnemyShot2.new(self.x + 56, self.y + 40, angle - 45)
|
394
|
+
$enemy_shots << EnemyShot2.new(self.x + 56, self.y + 40, angle - 22.5)
|
395
|
+
$enemy_shots << EnemyShot2.new(self.x + 56, self.y + 40, angle)
|
396
|
+
$enemy_shots << EnemyShot2.new(self.x + 56, self.y + 40, angle + 22.5)
|
397
|
+
$enemy_shots << EnemyShot2.new(self.x + 56, self.y + 40, angle + 45)
|
398
|
+
# �J�E���g������
|
399
|
+
@shotcount = 0
|
400
|
+
end
|
401
|
+
end
|
402
|
+
|
403
|
+
# �Ƃ肠�����t���[���A�t���b�V�����Ă��Ȃ���Ԃɂ���
|
404
|
+
@imagenumber = 0
|
405
|
+
|
406
|
+
# �A�j���[�V�����p�J�E���g
|
407
|
+
@animecount += 1
|
408
|
+
@animecount -= 40 if @animecount >= 40
|
409
|
+
end
|
410
|
+
|
411
|
+
# ���@�V���b�g�����������Ƃ��ɌĂ�郁�\�b�h
|
412
|
+
def hit(obj)
|
413
|
+
# HP�����炷
|
414
|
+
@hp = @hp - obj.damage
|
415
|
+
|
416
|
+
# ���ꏈ��
|
417
|
+
if @hp <= 0
|
418
|
+
self.vanish
|
419
|
+
$etc_objects << Enemy2bomb.new(self.x, self.y)
|
420
|
+
@@sound.play
|
421
|
+
end
|
422
|
+
|
423
|
+
# �t���b�V�����ɂ���
|
424
|
+
@imagenumber = 1
|
425
|
+
end
|
426
|
+
|
427
|
+
# �`��
|
428
|
+
def draw
|
429
|
+
self.image = @@image[@imagenumber][@animecount / 10]
|
430
|
+
super
|
431
|
+
$rt.draw(self.x-16, self.y-16, @@image[2][@animecount / 10], 1) # �e
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
# ���@�p�V���b�g
|
436
|
+
class MyShot < Sprite
|
437
|
+
@@image = Image.load("image/myshot.png")
|
438
|
+
attr_accessor :damage
|
439
|
+
|
440
|
+
# �C���X�^���X������
|
441
|
+
def initialize(x, y, angle)
|
442
|
+
super(x, y, @@image)
|
443
|
+
self.z = 15
|
444
|
+
self.collision = [0, 0, 31, 31] # �Փ˔���
|
445
|
+
self.angle = angle + 90 # �p�x
|
446
|
+
self.target = $rt
|
447
|
+
@dx = Math.cos(angle / 180.0 * Math::PI) * 16 # ���ړ���
|
448
|
+
@dy = Math.sin(angle / 180.0 * Math::PI) * 16 # �c�ړ���
|
449
|
+
@damage = 5 # �G�ɓ��������Ƃ��ɗ^����_���[�W
|
450
|
+
end
|
451
|
+
|
452
|
+
# �X�V
|
453
|
+
def update
|
454
|
+
# �V���b�g�ړ�
|
455
|
+
self.x += @dx
|
456
|
+
self.y += @dy
|
457
|
+
end
|
458
|
+
|
459
|
+
# �G�ɓ��������Ƃ��ɌĂ�郁�\�b�h
|
460
|
+
def shot(obj)
|
461
|
+
self.vanish
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
# ���@
|
466
|
+
class MyShip < Sprite
|
467
|
+
|
468
|
+
# �摜�ǂݍ��݂Ɖe�摜����
|
469
|
+
@@image0 = Image.load_tiles("image/myship.png", 4, 1, true)
|
470
|
+
@@image1 = @@image0.map {|image| image.flush([128, 0, 0, 0])}
|
471
|
+
|
472
|
+
# �V���b�g������
|
473
|
+
f = 4000
|
474
|
+
@@sound = SoundEffect.new(20, WAVE_TRI) do # 20ms �̎O�p�g������
|
475
|
+
f = f - 120 # ���g���� 4000Hz ���� 1ms ���Ƃ� 120Hz ������
|
476
|
+
[f, 15] # [ ���g��, ���� ] �̔z���Ԃ�
|
477
|
+
end
|
478
|
+
|
479
|
+
# ����������
|
480
|
+
def initialize
|
481
|
+
super(200, 400)
|
482
|
+
self.z = 15
|
483
|
+
self.collision = [4, 4, 27, 27] # �Փ˔���
|
484
|
+
self.target = $rt
|
485
|
+
@animecount = 0 # �A�j���[�V�����p�J�E���g
|
486
|
+
|
487
|
+
end
|
488
|
+
|
489
|
+
def update
|
490
|
+
# �ړ�
|
491
|
+
dx = Input.x * 3
|
492
|
+
dy = Input.y * 3
|
493
|
+
if Input.x != 0 and Input.y != 0 # �i�i���̎��� 0.7 �{
|
494
|
+
dx *= 0.7
|
495
|
+
dy *= 0.7
|
496
|
+
end
|
497
|
+
self.x += dx
|
498
|
+
self.y += dy
|
499
|
+
|
500
|
+
# ��ʒ[�̔���
|
501
|
+
self.x = 0 if self.x < 0
|
502
|
+
self.x = 448 - 32 if self.x > 448 - 32
|
503
|
+
self.y = 0 if self.y < 0
|
504
|
+
self.y = 480 - 32 if self.y > 480 - 32
|
505
|
+
|
506
|
+
# �V���b�g
|
507
|
+
if Input.pad_push?(P_BUTTON0)
|
508
|
+
$my_shots << MyShot.new(self.x - 18, self.y - 32, 270)
|
509
|
+
$my_shots << MyShot.new(self.x + 18, self.y - 32, 270)
|
510
|
+
$my_shots << MyShot.new(self.x + 32, self.y - 16, 300)
|
511
|
+
$my_shots << MyShot.new(self.x - 32, self.y - 16, 240)
|
512
|
+
@@sound.play
|
513
|
+
end
|
514
|
+
|
515
|
+
# �A�j���[�V�����p�J�E���g
|
516
|
+
@animecount += 1
|
517
|
+
@animecount -= 80 if @animecount >= 80
|
518
|
+
end
|
519
|
+
|
520
|
+
# �`��
|
521
|
+
def draw
|
522
|
+
self.image = @@image0[@animecount / 20]
|
523
|
+
super
|
524
|
+
$rt.draw(self.x - 16, self.y - 16, @@image1[@animecount / 20], 1) # �e
|
525
|
+
end
|
526
|
+
end
|
527
|
+
|
528
|
+
# �������܂ł��N���X��`
|
529
|
+
|
530
|
+
# ���������炪�Q�[���̃��C������
|
531
|
+
|
532
|
+
Window.caption = "��тܗp�T���v���Q�[����DXRuby1.4��" # �E�B���h�E�̃L���v�V�����ݒ�
|
533
|
+
Window.width = 360 # �E�B���h�E�̉��T�C�Y�ݒ�
|
534
|
+
Window.height = 480 # �E�B���h�E�̏c�T�C�Y�ݒ�
|
535
|
+
Input.set_repeat(0, 5) # �L�[�̃I�[�g���s�[�g�ݒ�B5 �t���[���� 1 �� on
|
536
|
+
|
537
|
+
$etc_objects = [] # �I�u�W�F�N�g�z��
|
538
|
+
$my_shots = [] # �e
|
539
|
+
$enemies = [] # �G
|
540
|
+
$enemy_shots = [] # �G�̒e
|
541
|
+
|
542
|
+
$rt = RenderTarget.new(448,480)
|
543
|
+
screen_sprite = Sprite.new(0, 0)
|
544
|
+
screen_sprite.collision = [0, 0, 448, 480]
|
545
|
+
|
546
|
+
count = 0 # �G�o�������p�J�E���g
|
547
|
+
font = Font.new(32) # �t�H���g����
|
548
|
+
|
549
|
+
$myship = MyShip.new # ���@����
|
550
|
+
$etc_objects << $myship # ���@���I�u�W�F�N�g�z��ɒlj�
|
551
|
+
$etc_objects << Map.new # �w�i�I�u�W�F�N�g�������I�u�W�F�N�g�z��ɒlj�
|
552
|
+
|
553
|
+
# ���C�����[�v
|
554
|
+
Window.loop do
|
555
|
+
|
556
|
+
# �G�o������
|
557
|
+
count += 1
|
558
|
+
if count % 20 == 0 # 20 �J�E���g�� 1 ��
|
559
|
+
if count % 400 == 0 # 400 �J�E���g�� 1 ��
|
560
|
+
# �G 2 �̃I�u�W�F�N�g�������I�u�W�F�N�g�z��ɒlj�
|
561
|
+
$enemies << Enemy2.new(rand(240), -64)
|
562
|
+
count = 0
|
563
|
+
else
|
564
|
+
# �G 1 �̃I�u�W�F�N�g�������I�u�W�F�N�g�z��ɒlj�
|
565
|
+
$enemies << Enemy1.new(rand(320), -48)
|
566
|
+
end
|
567
|
+
end
|
568
|
+
|
569
|
+
# �I�u�W�F�N�g���X�V
|
570
|
+
Sprite.update([$etc_objects, $my_shots, $enemies, $enemy_shots])
|
571
|
+
|
572
|
+
# ��ʂ���o���������
|
573
|
+
$my_shots = screen_sprite.check($my_shots)
|
574
|
+
$enemies = screen_sprite.check($enemies)
|
575
|
+
$enemy_shots = screen_sprite.check($enemy_shots)
|
576
|
+
|
577
|
+
# �Փ˔���
|
578
|
+
Sprite.check($my_shots, $enemies) # ���@�V���b�g�ƓG
|
579
|
+
Sprite.check($enemy_shots, $myship) # �G�V���b�g�Ǝ��@
|
580
|
+
|
581
|
+
# �Փ˔���ŏ������L������z��폜
|
582
|
+
Sprite.clean([$etc_objects, $my_shots, $enemies, $enemy_shots])
|
583
|
+
|
584
|
+
# �I�u�W�F�N�g��`��
|
585
|
+
Sprite.draw([$etc_objects, $my_shots, $enemies, $enemy_shots])
|
586
|
+
|
587
|
+
$rt.update
|
588
|
+
Window.draw(-$myship.x/5,0,$rt)
|
589
|
+
|
590
|
+
# Esc �L�[�ŏI��
|
591
|
+
break if Input.key_push?(K_ESCAPE)
|
592
|
+
|
593
|
+
# �e����o��
|
594
|
+
Window.draw_font(0, 0, Window.get_load.to_i.to_s + " %", font, :z => 100)
|
595
|
+
Window.draw_font(0, 32, [$etc_objects, $my_shots, $enemies, $enemy_shots].flatten.size.to_s + " objects", font, :z => 100)
|
596
|
+
end
|
597
|
+
|
Binary file
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'dxruby'
|
2
|
+
|
3
|
+
map_image = [
|
4
|
+
Image.new(32,32,[128,128,128]),
|
5
|
+
Image.new(32,32,[100,230,100]),
|
6
|
+
Image.new(32,32,[0,200,0]),
|
7
|
+
Image.new(32,32,[255,220,100]),
|
8
|
+
Image.new(32,32,[255,100,0]),
|
9
|
+
Image.new(32,32,[0,0,255])
|
10
|
+
]
|
11
|
+
|
12
|
+
$map = [
|
13
|
+
[1,3,3,3,1,0,1,2,2,2,2,4,4,4,4,4],
|
14
|
+
[3,3,3,3,2,0,1,1,2,2,2,4,4,4,4,4],
|
15
|
+
[1,3,3,3,1,0,2,1,1,2,2,2,2,2,2,1],
|
16
|
+
[5,1,3,3,1,0,1,1,1,1,1,1,2,2,2,2],
|
17
|
+
[5,1,3,3,1,0,1,2,1,1,1,2,1,1,1,1],
|
18
|
+
[5,1,2,3,1,0,0,1,1,2,1,1,1,1,2,1],
|
19
|
+
[5,5,1,1,1,1,0,0,0,0,0,1,1,2,1,1],
|
20
|
+
[5,5,5,5,5,1,1,1,1,1,0,0,0,0,1,1],
|
21
|
+
[5,5,5,5,5,5,5,5,5,1,1,1,1,0,0,2],
|
22
|
+
[5,5,5,5,1,1,1,1,5,5,5,5,1,1,0,1],
|
23
|
+
[5,5,5,1,1,1,2,1,1,1,1,5,5,5,0,5],
|
24
|
+
[5,5,5,1,2,4,4,4,4,4,1,1,2,1,0,1],
|
25
|
+
]
|
26
|
+
|
27
|
+
x = 5
|
28
|
+
y = 5
|
29
|
+
s = Sprite.new(x*32, y*32, Image.new(32,32).circle_fill(16,16,16,C_WHITE))
|
30
|
+
speed = 9
|
31
|
+
|
32
|
+
$d = [[0,0],[0,0],[0,1],[0,0],[-1,0],[0,0],[1,0],[0,0],[0,-1],[0,0]]
|
33
|
+
|
34
|
+
def find(x, y, speed, temp)
|
35
|
+
[2,4,6,8].each do |i|
|
36
|
+
tx = x + $d[i][0]
|
37
|
+
ty = y + $d[i][1]
|
38
|
+
next if tx < 0 or tx > 15 or ty < 0 or ty > 11
|
39
|
+
|
40
|
+
if speed - $map[ty][tx] - 1 >= 0
|
41
|
+
if temp[ty][tx] == nil or temp[ty][tx] < speed - $map[ty][tx] - 1
|
42
|
+
temp[ty][tx] = speed - $map[ty][tx] - 1
|
43
|
+
find(tx, ty, speed - $map[ty][tx] - 1, temp)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
range = Image.new(32,32,[150,255,180,180])
|
50
|
+
cursor = Image.new(32,32).box(0,0,31,31,C_WHITE)
|
51
|
+
|
52
|
+
temp = Array.new(12) { Array.new(15) }
|
53
|
+
find(x, y, speed, temp)
|
54
|
+
|
55
|
+
Window.loop do
|
56
|
+
|
57
|
+
if Input.mouse_push?(M_LBUTTON)
|
58
|
+
if temp[Input.mouse_pos_y / 32][Input.mouse_pos_x / 32]
|
59
|
+
x = Input.mouse_pos_x / 32
|
60
|
+
y = Input.mouse_pos_y / 32
|
61
|
+
temp = Array.new(12) { Array.new(15) }
|
62
|
+
find(x, y, speed, temp)
|
63
|
+
s.x = x * 32
|
64
|
+
s.y = y * 32
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
Window.draw_tile(0,0,$map,map_image,0,0,16,12)
|
69
|
+
|
70
|
+
(0..11).each do |iy|
|
71
|
+
(0..15).each do |ix|
|
72
|
+
if temp[iy][ix]
|
73
|
+
Window.draw(ix*32, iy*32, range)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
s.draw
|
79
|
+
Window.draw((Input.mouse_pos_x / 32) * 32, (Input.mouse_pos_y / 32) * 32, cursor)
|
80
|
+
|
81
|
+
break if Input.key_push?(K_ESCAPE)
|
82
|
+
end
|