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,220 @@
|
|
1
|
+
require 'dxruby'
|
2
|
+
|
3
|
+
class Sprite
|
4
|
+
def on_screen?(range = nil)
|
5
|
+
if range == nil
|
6
|
+
if self.target == nil
|
7
|
+
screen = [0, 0, Window.width, Window.height]
|
8
|
+
else
|
9
|
+
screen = [0, 0, self.target.width, self.target.height]
|
10
|
+
end
|
11
|
+
else
|
12
|
+
screen = range
|
13
|
+
end
|
14
|
+
|
15
|
+
xary = [0, self.image.width, 0, self.image.width]
|
16
|
+
yary = [0, 0, self.image.height, self.image.height]
|
17
|
+
|
18
|
+
if self.angle != 0 or self.scale_x != 1.0 or self.scale_y != 1.0
|
19
|
+
cos = Math.cos(self.angle / 180.0 * Math::PI)
|
20
|
+
sin = Math.sin(self.angle / 180.0 * Math::PI)
|
21
|
+
4.times do |i|
|
22
|
+
tempx = ((xary[i] - self.center_x) * cos - (yary[i] - self.center_x) * sin) * scale_x + self.center_x
|
23
|
+
tempy = ((xary[i] - self.center_x) * sin + (yary[i] - self.center_x) * cos) * scale_y + self.center_x
|
24
|
+
xary[i] = tempx
|
25
|
+
yary[i] = tempy
|
26
|
+
end
|
27
|
+
end
|
28
|
+
return !(screen[0] >= xary.max+self.x or screen[1] >= yary.max+self.y or screen[2] <= xary.min+self.x or screen[3] <= yary.min+self.y)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class StandardParticle < Sprite
|
33
|
+
attr_accessor :dx, :dy, :lifetime, :parent
|
34
|
+
|
35
|
+
def initialize
|
36
|
+
@dx = 0
|
37
|
+
@dy = 0
|
38
|
+
@lifetime = nil
|
39
|
+
end
|
40
|
+
|
41
|
+
def update
|
42
|
+
if @lifetime
|
43
|
+
@lifetime -= 1
|
44
|
+
if @lifetime == 0
|
45
|
+
self.vanish
|
46
|
+
return
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
if self.alpha > 0
|
51
|
+
self.alpha += @parent.d_alpha
|
52
|
+
self.alpha = 0 if self.alpha < 0
|
53
|
+
end
|
54
|
+
|
55
|
+
self.x += @dx
|
56
|
+
self.y += @dy
|
57
|
+
|
58
|
+
self.vanish unless self.on_screen?
|
59
|
+
|
60
|
+
@dy += @parent.gravity
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class ParticleFactory
|
65
|
+
attr_accessor :particles
|
66
|
+
|
67
|
+
@@all_objects = []
|
68
|
+
|
69
|
+
def self.step
|
70
|
+
obj = @@all_objects.map{|o|o.particles}
|
71
|
+
Sprite.update obj
|
72
|
+
Sprite.draw obj
|
73
|
+
Sprite.clean obj
|
74
|
+
@@all_objects.delete_if {|v| v.particles.empty?}
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.count
|
78
|
+
c = 0
|
79
|
+
@@all_objects.each do |o|
|
80
|
+
c += o.particles.size
|
81
|
+
end
|
82
|
+
c
|
83
|
+
end
|
84
|
+
|
85
|
+
def initialize(particle_class)
|
86
|
+
@particle_class = particle_class
|
87
|
+
@particles = []
|
88
|
+
end
|
89
|
+
|
90
|
+
def generate(count)
|
91
|
+
flag = @particles.empty?
|
92
|
+
count.times do |i|
|
93
|
+
temp = @particle_class.new
|
94
|
+
yield temp, i
|
95
|
+
@particles << temp
|
96
|
+
end
|
97
|
+
@@all_objects.push(self) if flag
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
class SampleEmitter
|
102
|
+
attr_accessor :gravity, :d_alpha, :image, :lifetime
|
103
|
+
|
104
|
+
class EmitterGenerator
|
105
|
+
attr_accessor :b, :interval, :count
|
106
|
+
def initialize(b, interval)
|
107
|
+
@b = b
|
108
|
+
@interval = interval
|
109
|
+
@count = 0
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def initialize(particle_class)
|
114
|
+
@factory = ParticleFactory.new(particle_class)
|
115
|
+
@screen = Sprite.new
|
116
|
+
@screen.collision = [0, 0, 639, 479]
|
117
|
+
@generator = []
|
118
|
+
@d_alpha = 0
|
119
|
+
end
|
120
|
+
|
121
|
+
def generate(count)
|
122
|
+
@factory.generate(count) do |p, i|
|
123
|
+
p.parent = self
|
124
|
+
p.lifetime = @lifetime
|
125
|
+
yield p, i
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def generate_line(count, x1, y1, x2, y2)
|
130
|
+
diff_x = x2 - x1 + 1
|
131
|
+
diff_y = y2 - y1 + 1
|
132
|
+
@factory.generate(count) do |p, i|
|
133
|
+
r = rand()
|
134
|
+
p.x = x1 + r * diff_x
|
135
|
+
p.y = y1 + r * diff_y
|
136
|
+
p.parent = self
|
137
|
+
p.lifetime = @lifetime
|
138
|
+
p.image = @image
|
139
|
+
yield p, i if block_given?
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def generate_circle(count, x, y, r, angle_min, angle_max)
|
144
|
+
@factory.generate(count) do |p, i|
|
145
|
+
angle = angle_min + rand() * (angle_max - angle_min)
|
146
|
+
p.x = x + Math.cos(angle / 180.0 * Math::PI) * r
|
147
|
+
p.y = y + Math.sin(angle / 180.0 * Math::PI) * r
|
148
|
+
p.parent = self
|
149
|
+
p.lifetime = @lifetime
|
150
|
+
p.image = @image
|
151
|
+
yield p, i, angle if block_given?
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def add_generator(interval, &b)
|
156
|
+
@generator << EmitterGenerator.new(b, interval)
|
157
|
+
end
|
158
|
+
|
159
|
+
def update
|
160
|
+
@generator.each do |g|
|
161
|
+
g.count += 1
|
162
|
+
if g.count >= g.interval
|
163
|
+
g.count = 0
|
164
|
+
g.b.call
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
class TestParticle < StandardParticle
|
172
|
+
|
173
|
+
def initialize
|
174
|
+
super
|
175
|
+
end
|
176
|
+
|
177
|
+
def hit(o)
|
178
|
+
@dy = -@dy * 0.5
|
179
|
+
self.collision_enable = false
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
class TestEmitter < SampleEmitter
|
184
|
+
attr_accessor :wall
|
185
|
+
|
186
|
+
def update
|
187
|
+
super
|
188
|
+
Sprite.check @wall, @factory.particles
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
image = Image.new(3,3)
|
193
|
+
image[1,0] = [128, 255, 255, 255]
|
194
|
+
image[1,2] = [128, 255, 255, 255]
|
195
|
+
image[0,1] = [128, 255, 255, 255]
|
196
|
+
image[2,1] = [128, 255, 255, 255]
|
197
|
+
image[1,1] = C_WHITE
|
198
|
+
|
199
|
+
emitter = TestEmitter.new(TestParticle)
|
200
|
+
emitter.gravity = 0.1
|
201
|
+
emitter.image = image
|
202
|
+
emitter.wall = Sprite.new(0, 400, Image.new(640, 180, C_WHITE))
|
203
|
+
|
204
|
+
emitter.add_generator(1) do
|
205
|
+
emitter.generate_circle(5, 200, 100, 1, 0, 360) do |p, i, angle|
|
206
|
+
p.dx = Math.cos(angle / 180.0 * Math::PI)*3
|
207
|
+
p.dy = Math.sin(angle / 180.0 * Math::PI)*3
|
208
|
+
p.blend = :add
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
font = Font.new(32)
|
213
|
+
Window.after_call[:particle] = ParticleFactory.method(:step)
|
214
|
+
|
215
|
+
Window.loop do
|
216
|
+
emitter.update
|
217
|
+
Window.draw_font(0,0,ParticleFactory.count.to_s, font)
|
218
|
+
Window.draw_font(0,32,Window.fps.to_s, font)
|
219
|
+
end
|
220
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
DXRuby �T���v���v���O����
|
2
|
+
|
3
|
+
�܂��ŏ��ɁA�\�[�X�������Ă��߂�Ȃ����B
|
4
|
+
�e�L�g�[�ɍ�������̂������Q�l�ɂȂ���Ċ����ŋl�ߍ���ł���܂��B
|
5
|
+
|
6
|
+
autocall.rb
|
7
|
+
�E�E�EWindow.autocall�̃T���v���ł��Bautocall��particle.rb�ł��g���Ă��܂��B
|
8
|
+
|
9
|
+
effecttest.rb
|
10
|
+
�E�E�EImage#effect_image_font��Font#info�̃T���v���ł��B
|
11
|
+
|
12
|
+
hlstest.rb
|
13
|
+
�E�E�EImage#change_hls�̃T���v���ł��B
|
14
|
+
|
15
|
+
particle.rb
|
16
|
+
�E�E�E�p�[�e�B�N���V�X�e���Ƀ`�������W���Ă݂܂����B�C�}�C�`�ł��B
|
17
|
+
|
18
|
+
scenetest.rb
|
19
|
+
�E�E�E�����_���Scene�N���X������Ă݂܂����B
|
20
|
+
|
21
|
+
scenetest2.rb
|
22
|
+
�E�E�E�����_���Scene�N���X�Ńh���N�G�I���j���[������Ă݂܂����B
|
23
|
+
|
24
|
+
hitrange.rb
|
25
|
+
�E�E�EHitRange���W���[����Sprite�̔h���N���X��include���邱�ƂŏՓ˔���͈͂�������悤�ɂȂ�܂��B
|
26
|
+
|
27
|
+
Image#flush�̃T���v����new_sample��rubima.rb�ɂ���܂��B�t���b�V���摜�쐬�Ɏg���Ă݂܂����B
|
28
|
+
|
29
|
+
|
@@ -0,0 +1,200 @@
|
|
1
|
+
#!ruby -Ks
|
2
|
+
require 'dxruby'
|
3
|
+
|
4
|
+
class ExitException < StandardError
|
5
|
+
end
|
6
|
+
|
7
|
+
module Window
|
8
|
+
@@created = false
|
9
|
+
|
10
|
+
def self.loop
|
11
|
+
unless @@created
|
12
|
+
Window.create
|
13
|
+
@@created = true
|
14
|
+
end
|
15
|
+
|
16
|
+
while(true) do
|
17
|
+
raise ExitException if Input.update
|
18
|
+
yield
|
19
|
+
Window.sync
|
20
|
+
Window.update
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.times(count)
|
25
|
+
unless @@created
|
26
|
+
Window.create
|
27
|
+
@@created = true
|
28
|
+
end
|
29
|
+
|
30
|
+
count.times do |i|
|
31
|
+
raise ExitException if Input.update
|
32
|
+
yield i
|
33
|
+
Window.sync
|
34
|
+
Window.update
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
class SpriteBase < Sprite
|
41
|
+
def initialize(angle)
|
42
|
+
self.x = 320 - self.image.width / 2
|
43
|
+
self.y = 240 - self.image.height / 2
|
44
|
+
speed = rand() * 5 + 2
|
45
|
+
@dx = Math.cos(angle / 180.0 * Math::PI) * speed
|
46
|
+
@dy = Math.sin(angle / 180.0 * Math::PI) * speed
|
47
|
+
end
|
48
|
+
|
49
|
+
def update
|
50
|
+
self.x += @dx
|
51
|
+
self.y += @dy
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class Hoge < SpriteBase
|
56
|
+
@@image = Image.new(16,16).circle_fill(8,8,8,C_YELLOW)
|
57
|
+
def initialize
|
58
|
+
self.image = @@image
|
59
|
+
super(rand(360))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
class Fuga < SpriteBase
|
64
|
+
@@image = Image.new(16,16).circle_fill(8,8,8,C_GREEN)
|
65
|
+
def initialize
|
66
|
+
self.image = @@image
|
67
|
+
super(rand(180) + 180)
|
68
|
+
end
|
69
|
+
|
70
|
+
def update
|
71
|
+
super
|
72
|
+
@dy += 0.2
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
class Scene
|
78
|
+
end
|
79
|
+
|
80
|
+
class FirstScene < Scene
|
81
|
+
def initialize
|
82
|
+
@objects = []
|
83
|
+
@screen_collision = Sprite.new
|
84
|
+
@screen_collision.collision = [0, 0, 639, 479]
|
85
|
+
end
|
86
|
+
|
87
|
+
def run
|
88
|
+
Window.loop do
|
89
|
+
if Input.key_push?(K_SPACE)
|
90
|
+
return SecondScene.new
|
91
|
+
end
|
92
|
+
if Input.key_push?(K_ESCAPE)
|
93
|
+
MenuScene.new(self).run
|
94
|
+
end
|
95
|
+
|
96
|
+
update
|
97
|
+
@objects = @screen_collision.check(@objects)
|
98
|
+
draw
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def update
|
103
|
+
@objects.push Hoge.new
|
104
|
+
Sprite.update @objects
|
105
|
+
end
|
106
|
+
|
107
|
+
def draw
|
108
|
+
Sprite.draw @objects
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
class SecondScene < Scene
|
113
|
+
def initialize
|
114
|
+
@objects = []
|
115
|
+
@screen_collision = Sprite.new
|
116
|
+
@screen_collision.collision = [0, 0, 639, 479]
|
117
|
+
end
|
118
|
+
|
119
|
+
def run
|
120
|
+
Window.loop do
|
121
|
+
if Input.key_push?(K_SPACE)
|
122
|
+
return nil
|
123
|
+
end
|
124
|
+
if Input.key_push?(K_ESCAPE)
|
125
|
+
MenuScene.new(self).run
|
126
|
+
end
|
127
|
+
|
128
|
+
update
|
129
|
+
@objects = @screen_collision.check(@objects)
|
130
|
+
draw
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def update
|
135
|
+
@objects.push Fuga.new
|
136
|
+
Sprite.update @objects
|
137
|
+
end
|
138
|
+
|
139
|
+
def draw
|
140
|
+
Sprite.draw @objects
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
class MenuScene < Scene
|
145
|
+
@@fadeimage = Image.new(1,1,C_BLACK)
|
146
|
+
@@backimage = Image.new(1,1,[192,0,0,0])
|
147
|
+
@@menuimage = Image.new(100,50,C_BLACK).box(0, 0, 99, 49, C_WHITE)
|
148
|
+
.draw_font_ex(10,10,"��?",Font.new(32))
|
149
|
+
|
150
|
+
def initialize(s)
|
151
|
+
@s = s
|
152
|
+
end
|
153
|
+
|
154
|
+
def run
|
155
|
+
Window.times(30) do |i|
|
156
|
+
@s.update
|
157
|
+
@s.draw
|
158
|
+
Window.draw_ex(0, 0, @@fadeimage, :alpha=>255*i/45, :scale_x=>640, :scale_y=>480, :center_x => 0, :center_y=>0)
|
159
|
+
end
|
160
|
+
|
161
|
+
Window.loop do
|
162
|
+
if Input.key_push?(K_ESCAPE)
|
163
|
+
break
|
164
|
+
end
|
165
|
+
|
166
|
+
@s.update
|
167
|
+
@s.draw
|
168
|
+
Window.draw_scale(0, 0, @@backimage, 640, 480, 0, 0)
|
169
|
+
Window.draw(270, 215, @@menuimage)
|
170
|
+
end
|
171
|
+
|
172
|
+
Window.times(30) do |i|
|
173
|
+
@s.update
|
174
|
+
@s.draw
|
175
|
+
Window.draw_ex(0, 0, @@fadeimage, :alpha=>255*(29 - i)/45, :scale_x=>640, :scale_y=>480, :center_x => 0, :center_y=>0)
|
176
|
+
end
|
177
|
+
|
178
|
+
return nil
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
|
184
|
+
scene = FirstScene.new
|
185
|
+
|
186
|
+
begin
|
187
|
+
|
188
|
+
loop do
|
189
|
+
result = scene.run
|
190
|
+
if Scene === result
|
191
|
+
scene = result
|
192
|
+
else
|
193
|
+
break
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
rescue ExitException
|
198
|
+
end
|
199
|
+
|
200
|
+
|
@@ -0,0 +1,120 @@
|
|
1
|
+
#!ruby -Ks
|
2
|
+
require 'dxruby'
|
3
|
+
|
4
|
+
class ExitException < StandardError
|
5
|
+
end
|
6
|
+
|
7
|
+
module Window
|
8
|
+
@@created = false
|
9
|
+
|
10
|
+
def self.loop
|
11
|
+
unless @@created
|
12
|
+
Window.create
|
13
|
+
@@created = true
|
14
|
+
end
|
15
|
+
|
16
|
+
while(true) do
|
17
|
+
raise ExitException if Input.update
|
18
|
+
yield
|
19
|
+
Window.sync
|
20
|
+
Window.update
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
class Scene
|
27
|
+
end
|
28
|
+
|
29
|
+
class FirstScene < Scene
|
30
|
+
@@image = Image.new(1,1,C_GREEN)
|
31
|
+
def initialize
|
32
|
+
end
|
33
|
+
|
34
|
+
def run
|
35
|
+
Window.loop do
|
36
|
+
if Input.key_push?(K_ESCAPE)
|
37
|
+
break
|
38
|
+
end
|
39
|
+
if Input.key_push?(K_SPACE)
|
40
|
+
MenuScene.new([self], 100, 100).run
|
41
|
+
end
|
42
|
+
|
43
|
+
draw
|
44
|
+
end
|
45
|
+
return nil
|
46
|
+
end
|
47
|
+
|
48
|
+
def draw
|
49
|
+
Window.draw_scale(0,0,@@image,640,480,0,0)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class MenuScene < Scene
|
54
|
+
|
55
|
+
@@font = Font.new(24)
|
56
|
+
@@image = Image.new(204,124,C_BLACK).box_fill(2,2,201,121,C_WHITE).box_fill(7,7,196,116,C_BLACK)
|
57
|
+
@@image.draw_font_ex(32, 22, "0001", @@font).draw_font_ex(120, 22, "0002", @@font)
|
58
|
+
@@image.draw_font_ex(32, 54, "0003", @@font).draw_font_ex(120, 54, "0004", @@font)
|
59
|
+
@@image.draw_font_ex(32, 86, "0005", @@font).draw_font_ex(120, 86, "0006", @@font)
|
60
|
+
@@image.box_fill(60, 0, 139, 23, [0,0,0,0])
|
61
|
+
@@cursor = Image.new(12,12).triangle_fill(0,0,5,5,0,10,C_WHITE)
|
62
|
+
@@menu = Image.new(80, 24, C_BLACK).draw_font_ex(10, -2, "MENU", @@font)
|
63
|
+
|
64
|
+
def initialize(s, x, y)
|
65
|
+
@s = s
|
66
|
+
@x = x
|
67
|
+
@y = y
|
68
|
+
@cx = 0
|
69
|
+
@cy = 0
|
70
|
+
end
|
71
|
+
|
72
|
+
def run
|
73
|
+
Window.loop do
|
74
|
+
if Input.key_push?(K_ESCAPE)
|
75
|
+
break
|
76
|
+
end
|
77
|
+
if Input.key_push?(K_SPACE)
|
78
|
+
MenuScene.new(@s + [self], @x + @cx * 88 - 45, @y + @cy * 32 + 24).run
|
79
|
+
end
|
80
|
+
|
81
|
+
@cx = 1 - @cx if Input.key_push?(K_LEFT) or Input.key_push?(K_RIGHT)
|
82
|
+
@cy -= 1 if Input.key_push?(K_UP)
|
83
|
+
@cy += 1 if Input.key_push?(K_DOWN)
|
84
|
+
@cy = 2 if @cy < 0
|
85
|
+
@cy = 0 if @cy >2
|
86
|
+
|
87
|
+
Sprite.draw @s
|
88
|
+
draw
|
89
|
+
Window.draw(@x + @cx * 88 + 16,@y + @cy * 32 + 29, @@cursor)
|
90
|
+
end
|
91
|
+
|
92
|
+
return nil
|
93
|
+
end
|
94
|
+
|
95
|
+
def draw
|
96
|
+
Window.draw(@x, @y, @@image)
|
97
|
+
if @s.size == 1
|
98
|
+
Window.draw(@x + 60, @y, @@menu)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
scene = FirstScene.new
|
105
|
+
|
106
|
+
begin
|
107
|
+
|
108
|
+
loop do
|
109
|
+
result = scene.run
|
110
|
+
if Scene === result
|
111
|
+
scene = result
|
112
|
+
else
|
113
|
+
break
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
rescue ExitException
|
118
|
+
end
|
119
|
+
|
120
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
11111111121111111113311111111111
|
2
|
+
11111111111111111333331111112111
|
3
|
+
12111111111111111113333111211111
|
4
|
+
11111111111111112111333111111121
|
5
|
+
11111111111111111111113311111111
|
6
|
+
11111110000000111111111311111111
|
7
|
+
11111100000000001111111131111111
|
8
|
+
11111000333000001111112111111311
|
9
|
+
11120003333200000111111111111311
|
10
|
+
11120000333220000111111111111311
|
11
|
+
11220000011220000111111111113111
|
12
|
+
11220000001220000111111311113111
|
13
|
+
11222000000000001111111331133111
|
14
|
+
11112220000000000111111133331111
|
15
|
+
11111222100000000011111133331111
|
16
|
+
11211112211000111001111133331111
|
17
|
+
11111111221111111100111333331111
|
18
|
+
11111111111111111110111333311111
|
19
|
+
11111111111222111111013333311111
|
20
|
+
11111111111112221111303333111111
|
21
|
+
11111111111111111111303331111111
|
22
|
+
11121111111111111113303331111111
|
23
|
+
11111111333331111333033331111121
|
24
|
+
11111111113333333331233311111222
|
25
|
+
11111111111113333333331111122222
|
26
|
+
11111111211111133333311111222222
|
27
|
+
11111111111111111333111111222221
|
28
|
+
11111211111111111111111111122211
|
29
|
+
11111111111111111111112111111111
|
30
|
+
11111111111121111111111111111111
|
31
|
+
11111111111111111111111111111111
|
32
|
+
11111111111111111111111111111111
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'dxruby'
|
2
|
+
|
3
|
+
# �}�b�v
|
4
|
+
class Map
|
5
|
+
attr_reader :mapdata
|
6
|
+
# target�͕`����RenderTarget/Window
|
7
|
+
def initialize(filename, mapimage, target=Window)
|
8
|
+
@mapimage, @target = mapimage, target
|
9
|
+
@mapdata = []
|
10
|
+
File.open(filename, "rt") do |fh|
|
11
|
+
lines = fh.readlines
|
12
|
+
lines.each do |line|
|
13
|
+
ary = []
|
14
|
+
line.chomp.each_char do |o|
|
15
|
+
if o != "x"
|
16
|
+
ary << o.to_i
|
17
|
+
else
|
18
|
+
ary << nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
@mapdata << ary
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# x/y�̓}�b�v���̍���̍��W(�s�N�Z���\��)
|
27
|
+
# �`��T�C�Y�͕`���(initialize��target)�ɂ�莩���I�ɒ��������
|
28
|
+
def draw(x, y)
|
29
|
+
image = @mapimage[0]
|
30
|
+
@target.draw_tile(0, 0, @mapdata, @mapimage, x, y,
|
31
|
+
(@target.width + image.width - 1) / image.width,
|
32
|
+
(@target.height + image.height - 1) / image.height)
|
33
|
+
end
|
34
|
+
|
35
|
+
def [](x, y)
|
36
|
+
@mapdata[y % @mapdata.size][x % @mapdata[0].size]
|
37
|
+
end
|
38
|
+
|
39
|
+
def []=(x, y, v)
|
40
|
+
@mapdata[y % @mapdata.size][x % @mapdata[0].size] = v
|
41
|
+
end
|
42
|
+
|
43
|
+
def size_x
|
44
|
+
@mapdata[0].size
|
45
|
+
end
|
46
|
+
|
47
|
+
def size_y
|
48
|
+
@mapdata.size
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
if __FILE__ == $0
|
53
|
+
mapimage = []
|
54
|
+
mapimage.push(Image.new(32, 32, [100, 100, 200])) # �C
|
55
|
+
mapimage.push(Image.new(32, 32, [50, 200, 50])) # ���n
|
56
|
+
mapimage.push(Image.new(32, 32, [50, 200, 50]). # �̍���
|
57
|
+
box_fill(13, 0, 18, 28, [200, 50, 50]))
|
58
|
+
mapimage.push(Image.new(32, 32, [50, 200, 50]). # �R
|
59
|
+
triangle_fill(15, 0, 0, 31, 31, 31, [200, 100,100]))
|
60
|
+
mapimage.push(Image.new(32, 32). # �̂����܁B�w�i�͓����F�ɂ��Ă����B
|
61
|
+
box_fill(13, 16, 18, 31, [200, 50, 50]).
|
62
|
+
circle_fill(16, 10, 8, [0, 255, 0]))
|
63
|
+
|
64
|
+
rt = RenderTarget.new(560,400)
|
65
|
+
map1 = Map.new("map.dat", mapimage, rt)
|
66
|
+
map2 = Map.new("map_sub.dat", mapimage, rt)
|
67
|
+
x = 0
|
68
|
+
y = 0
|
69
|
+
Window.loop do
|
70
|
+
map1.draw(x, y)
|
71
|
+
map2.draw(x, y)
|
72
|
+
Window.draw(40, 40, rt)
|
73
|
+
x += 1
|
74
|
+
y += 1
|
75
|
+
break if Input.key_push?(K_ESCAPE)
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
xxxxxxxxxxxxxxxxxxxxxxxxxxxx4xxx
|
2
|
+
x4xxxxxxxxxxxxxxxxxxxxxxxx4xxxxx
|
3
|
+
xxxxxxxxxxxxxxxx4xxxxxxxxxxxxx4x
|
4
|
+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
5
|
+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
6
|
+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
7
|
+
xxxxxxxxxxxxxxxxxxxxxx4xxxxxxxxx
|
8
|
+
xxx4xxxxxxx4xxxxxxxxxxxxxxxxxxxx
|
9
|
+
xxx4xxxxxxx44xxxxxxxxxxxxxxxxxxx
|
10
|
+
xx44xxxxxxx44xxxxxxxxxxxxxxxxxxx
|
11
|
+
xx44xxxxxxx44xxxxxxxxxxxxxxxxxxx
|
12
|
+
xx444xxxxxxxxxxxxxxxxxxxxxxxxxxx
|
13
|
+
xxxx444xxxxxxxxxxxxxxxxxxxxxxxxx
|
14
|
+
xxxxx444xxxxxxxxxxxxxxxxxxxxxxxx
|
15
|
+
xx4xxxx44xxxxxxxxxxxxxxxxxxxxxxx
|
16
|
+
xxxxxxxx44xxxxxxxxxxxxxxxxxxxxxx
|
17
|
+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
18
|
+
xxxxxxxxxxx444xxxxxxxxxxxxxxxxxx
|
19
|
+
xxxxxxxxxxxxx444xxxxxxxxxxxxxxxx
|
20
|
+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
21
|
+
xxx4xxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
22
|
+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx4x
|
23
|
+
xxxxxxxxxxxxxxxxxxxx4xxxxxxxx444
|
24
|
+
xxxxxxxxxxxxxxxxxxxxxxxxxxx44444
|
25
|
+
xxxxxxxx4xxxxxxxxxxxxxxxxx444444
|
26
|
+
xxxxxxxxxxxxxxxxxxxxxxxxxx44444x
|
27
|
+
xxxxx4xxxxxxxxxxxxxxxxxxxxx444xx
|
28
|
+
xxxxxxxxxxxxxxxxxxxxxx4xxxxxxxxx
|
29
|
+
xxxxxxxxxxxx4xxxxxxxxxxxxxxxxxxx
|
30
|
+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
31
|
+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
32
|
+
xxxxxxxxx4xxxxxxxxxxxxxxxxxxxxxx
|