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,102 @@
|
|
1
|
+
# �ȈՃ}�b�v�G�f�B�^
|
2
|
+
require 'dxruby'
|
3
|
+
require './map'
|
4
|
+
|
5
|
+
# �}�b�v�f�[�^
|
6
|
+
map = Array.new(32) { [1] * 32 }
|
7
|
+
|
8
|
+
# �G�̃f�[�^�����
|
9
|
+
mapimage = []
|
10
|
+
mapimage.push(Image.new(32, 32, [100, 100, 200])) # �C
|
11
|
+
mapimage.push(Image.new(32, 32, [50, 200, 50])) # ���n
|
12
|
+
mapimage.push(Image.new(32, 32, [50, 200, 50]). # �̍���
|
13
|
+
box_fill(13, 0, 18, 28, [200, 50, 50]))
|
14
|
+
mapimage.push(Image.new(32, 32, [50, 200, 50]). # �R
|
15
|
+
triangle_fill(15, 0, 0, 31, 31, 31, [200, 100,100]))
|
16
|
+
mapimage.push(Image.new(32, 32). # �̂����܁B�w�i�͓����F�ɂ��Ă����B
|
17
|
+
box_fill(13, 16, 18, 31, [200, 50, 50]).
|
18
|
+
circle_fill(16, 10, 8, [0, 255, 0]))
|
19
|
+
|
20
|
+
wakuimage = Image.new(36, 36).box(0, 0, 35, 35, [255, 255, 255, 255]) # �I��g
|
21
|
+
|
22
|
+
rt = RenderTarget.new(32*32, 32*32)
|
23
|
+
|
24
|
+
filename = Window.open_filename([["dat file(*.dat)", "*.dat"]], "open file name")
|
25
|
+
ext = File.extname(filename)
|
26
|
+
basename = File.basename(filename, ext)
|
27
|
+
|
28
|
+
map_base = Map.new(filename, mapimage, rt)
|
29
|
+
map_sub = Map.new(basename + "_sub" + ext, mapimage, rt)
|
30
|
+
|
31
|
+
select = 0
|
32
|
+
|
33
|
+
Window.height = 512
|
34
|
+
|
35
|
+
# ���C�����[�v
|
36
|
+
Window.loop do
|
37
|
+
|
38
|
+
# �}�E�X���N���b�N
|
39
|
+
if Input.mouse_down?(M_LBUTTON) then
|
40
|
+
x, y = Input.mouse_pos_x, Input.mouse_pos_y
|
41
|
+
if x >= 512 then # �E�̂ق��Ȃ�
|
42
|
+
for i in 0..3
|
43
|
+
if x >= 560 and x < 592 and y >= i * 64 + 64 and y < i * 64 + 96 then
|
44
|
+
select = i
|
45
|
+
break
|
46
|
+
end
|
47
|
+
end
|
48
|
+
else # ���̂ق��Ȃ�
|
49
|
+
if x > 0 and y > 0 and y < 512 then
|
50
|
+
map_base[x/16, y/16] = select
|
51
|
+
map_sub[x/16, y/16-1] = (select == 2 ? 4 : nil)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# �I��g�`��
|
57
|
+
Window.draw(558, select * 64 + 62, wakuimage)
|
58
|
+
|
59
|
+
# �}�b�v�`�b�v�`��
|
60
|
+
for i in 0..3
|
61
|
+
Window.draw(560, i * 64 + 64, mapimage[i])
|
62
|
+
Window.draw(560, 2 * 64 + 64 - 32, mapimage[4])
|
63
|
+
end
|
64
|
+
|
65
|
+
# �}�b�v��rt�ɕ`��
|
66
|
+
map_base.draw(0, 0)
|
67
|
+
map_sub.draw(0, 0)
|
68
|
+
|
69
|
+
# �S�̐}�`��
|
70
|
+
Window.draw_ex(0, 0, rt, :center_x => 0, :center_y => 0, :scale_x => 0.5, :scale_y => 0.5)
|
71
|
+
|
72
|
+
if Input.key_push?(K_ESCAPE) then
|
73
|
+
filename = Window.save_filename([["dat file(*.dat)", "*.dat"]], "save file name")
|
74
|
+
if filename
|
75
|
+
ext = File.extname(filename)
|
76
|
+
basename = File.basename(filename, ext)
|
77
|
+
File.open(filename, "wt") do |fh|
|
78
|
+
map_base.mapdata.each do |line|
|
79
|
+
data = ""
|
80
|
+
line.each do |o|
|
81
|
+
data += o.to_s
|
82
|
+
end
|
83
|
+
fh.puts(data)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
File.open(basename + "_sub" + ext, "wt") do |fh|
|
87
|
+
map_sub.mapdata.each do |line|
|
88
|
+
data = ""
|
89
|
+
line.each do |o|
|
90
|
+
if o
|
91
|
+
data += "4"
|
92
|
+
else
|
93
|
+
data += "x"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
fh.puts(data)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
break
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
DXRuby �T���v���v���O����
|
2
|
+
|
3
|
+
�܂��ŏ��ɁA�\�[�X�������Ă��߂�Ȃ����B
|
4
|
+
�e�L�g�[�ɍ�������̂������Q�l�ɂȂ���Ċ����ŋl�ߍ���ł���܂��B
|
5
|
+
|
6
|
+
scroll1.rb
|
7
|
+
�E�E�E���X�ƃ��[�v����h�[�i�c�^���E�̃X�N���[���ł��BFiber��RenderTarget���g���Ă��܂��B
|
8
|
+
|
9
|
+
scroll2.rb
|
10
|
+
�E�E�E��ʂ̈ړ��͈͂���ƃX�N���[�����A�}�b�v�̒[�Ŏ~�܂�܂��B
|
11
|
+
|
12
|
+
scroll3.rb
|
13
|
+
�E�E�E��ʂ̒[�܂ł����ƂP��ʕ��X�N���[�����A�}�b�v�̓��[�v���܂��B
|
14
|
+
|
15
|
+
mapedit.rb
|
16
|
+
�E�E�E�X�N���[���T���v���p�̃}�b�v������ȈՃ}�b�v�G�f�B�^�ł��B
|
17
|
+
|
18
|
+
map.rb
|
19
|
+
�E�E�E�X�N���[���T���v���Ŏg���}�b�v�Ǘ��N���XMap�ł��B
|
20
|
+
|
21
|
+
simple.rb
|
22
|
+
�E�E�EWindow.draw_tile�̃V���v���ȃT���v���ł��B
|
23
|
+
|
24
|
+
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# �X�N���[���T���v�����̂P(�P�����[�v�X�N���[��)
|
2
|
+
require 'dxruby'
|
3
|
+
require './map'
|
4
|
+
|
5
|
+
# �G�̃f�[�^�����
|
6
|
+
mapimage = []
|
7
|
+
mapimage.push(Image.new(32, 32, [100, 100, 200])) # �C
|
8
|
+
mapimage.push(Image.new(32, 32, [50, 200, 50])) # ���n
|
9
|
+
mapimage.push(Image.new(32, 32, [50, 200, 50]). # �̍���
|
10
|
+
box_fill(13, 0, 18, 28, [200, 50, 50]))
|
11
|
+
mapimage.push(Image.new(32, 32, [50, 200, 50]). # �R
|
12
|
+
triangle_fill(15, 0, 0, 31, 31, 31, [200, 100,100]))
|
13
|
+
mapimage.push(Image.new(32, 32). # �̂����܁B�w�i�͓����F�ɂ��Ă����B
|
14
|
+
box_fill(13, 16, 18, 31, [200, 50, 50]).
|
15
|
+
circle_fill(16, 10, 8, [0, 255, 0]))
|
16
|
+
|
17
|
+
# Fiber���g���₷�����郂�W���[��
|
18
|
+
module FiberSprite
|
19
|
+
def initialize(x=0,y=0,image=nil)
|
20
|
+
super
|
21
|
+
@fiber = Fiber.new do
|
22
|
+
self.fiber_proc
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def update
|
27
|
+
@fiber.resume
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
def wait(t=1)
|
32
|
+
t.times{Fiber.yield}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# ���L����
|
37
|
+
class Player < Sprite
|
38
|
+
include FiberSprite
|
39
|
+
attr_accessor :mx, :my
|
40
|
+
|
41
|
+
def initialize(x, y, map, target=Window)
|
42
|
+
@mx, @my, @map, self.target = x, y, map, target
|
43
|
+
super(8.5 * 32, 6 * 32)
|
44
|
+
|
45
|
+
# ���͏�ɂ͂ݏo���ĕ`�悳���̂ł��̂Ԃ�ʒu�����H
|
46
|
+
self.center_x = 0
|
47
|
+
self.center_y = 16
|
48
|
+
self.offset_sync = true
|
49
|
+
|
50
|
+
# �_�l�ԉ摜
|
51
|
+
self.image = Image.new(32, 48).
|
52
|
+
circle(15, 5, 5, [255, 255, 255]).
|
53
|
+
line(5, 18, 26, 18, [255, 255, 255]).
|
54
|
+
line(15, 10, 15, 31, [255, 255, 255]).
|
55
|
+
line(15, 31, 5, 47, [255, 255, 255]).
|
56
|
+
line(15, 31, 25, 47, [255, 255, 255])
|
57
|
+
end
|
58
|
+
|
59
|
+
# Player#update����ƌĂ��Fiber�̒��g
|
60
|
+
def fiber_proc
|
61
|
+
loop do
|
62
|
+
ix, iy = Input.x, Input.y
|
63
|
+
|
64
|
+
# �����ꂽ�`�F�b�N
|
65
|
+
if ix + iy != 0 and (ix == 0 or iy == 0) and # �i�i���͋p��
|
66
|
+
@map[@mx/32+ix, @my/32+iy] == 1 # �ړ��悪���n�̂Ƃ��̂�
|
67
|
+
# 8�t���[����1�}�X�ړ�
|
68
|
+
8.times do
|
69
|
+
@mx += ix * 4
|
70
|
+
@my += iy * 4
|
71
|
+
wait # wait����Ǝ��̃t���[����
|
72
|
+
end
|
73
|
+
else
|
74
|
+
wait
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# RenderTarget�쐬
|
81
|
+
rt = RenderTarget.new(640-64, 480-64)
|
82
|
+
|
83
|
+
# �}�b�v�̍쐬
|
84
|
+
map_base = Map.new("map.dat", mapimage, rt)
|
85
|
+
map_sub = Map.new("map_sub.dat", mapimage, rt)
|
86
|
+
|
87
|
+
# ���L����
|
88
|
+
player = Player.new(0, 0, map_base, rt)
|
89
|
+
|
90
|
+
Window.loop do
|
91
|
+
# �l�ړ�����
|
92
|
+
player.update
|
93
|
+
|
94
|
+
# rt�Ƀx�[�X�}�b�v��`��
|
95
|
+
map_base.draw(player.mx - player.x, player.my - player.y)
|
96
|
+
|
97
|
+
# rt�ɐl�`��
|
98
|
+
player.draw
|
99
|
+
|
100
|
+
# rt�ɏ�w�}�b�v��`��
|
101
|
+
map_sub.draw(player.mx - player.x, player.my - player.y)
|
102
|
+
|
103
|
+
# rt����ʂɕ`��
|
104
|
+
Window.draw(32, 32, rt)
|
105
|
+
|
106
|
+
# �G�X�P�[�v�L�[�ŏI��
|
107
|
+
break if Input.key_push?(K_ESCAPE)
|
108
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# �X�N���[���T���v�����̂Q(�[�Ŏ~�܂�X�N���[��)
|
2
|
+
require 'dxruby'
|
3
|
+
require './map'
|
4
|
+
|
5
|
+
# �G�̃f�[�^�����
|
6
|
+
mapimage = []
|
7
|
+
mapimage.push(Image.new(32, 32, [100, 100, 200])) # �C
|
8
|
+
mapimage.push(Image.new(32, 32, [50, 200, 50])) # ���n
|
9
|
+
mapimage.push(Image.new(32, 32, [50, 200, 50]). # �̍���
|
10
|
+
box_fill(13, 0, 18, 28, [200, 50, 50]))
|
11
|
+
mapimage.push(Image.new(32, 32, [50, 200, 50]). # �R
|
12
|
+
triangle_fill(15, 0, 0, 31, 31, 31, [200, 100,100]))
|
13
|
+
mapimage.push(Image.new(32, 32). # �̂����܁B�w�i�͓����F�ɂ��Ă����B
|
14
|
+
box_fill(13, 16, 18, 31, [200, 50, 50]).
|
15
|
+
circle_fill(16, 10, 8, [0, 255, 0]))
|
16
|
+
|
17
|
+
# Fiber���g���₷�����郂�W���[��
|
18
|
+
module FiberSprite
|
19
|
+
def initialize(x=0,y=0,image=nil)
|
20
|
+
super
|
21
|
+
@fiber = Fiber.new do
|
22
|
+
self.fiber_proc
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def update
|
27
|
+
@fiber.resume
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
def wait(t=1)
|
32
|
+
t.times{Fiber.yield}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# ���L����
|
37
|
+
class Player < Sprite
|
38
|
+
include FiberSprite
|
39
|
+
attr_accessor :mx, :my
|
40
|
+
|
41
|
+
def initialize(x, y, map, target=Window)
|
42
|
+
@mx, @my, @map, self.target = x, y, map, target
|
43
|
+
super(8.5 * 32, 6 * 32)
|
44
|
+
|
45
|
+
# ���͏�ɂ͂ݏo���ĕ`�悳���̂ł��̂Ԃ�ʒu�����H
|
46
|
+
self.center_x = 0
|
47
|
+
self.center_y = 16
|
48
|
+
self.offset_sync = true
|
49
|
+
|
50
|
+
# �_�l�ԉ摜
|
51
|
+
self.image = Image.new(32, 48).
|
52
|
+
circle(15, 5, 5, [255, 255, 255]).
|
53
|
+
line(5, 18, 26, 18, [255, 255, 255]).
|
54
|
+
line(15, 10, 15, 31, [255, 255, 255]).
|
55
|
+
line(15, 31, 5, 47, [255, 255, 255]).
|
56
|
+
line(15, 31, 25, 47, [255, 255, 255])
|
57
|
+
end
|
58
|
+
|
59
|
+
# Player#update����ƌĂ��Fiber�̒��g
|
60
|
+
def fiber_proc
|
61
|
+
loop do
|
62
|
+
ix, iy = Input.x, Input.y
|
63
|
+
|
64
|
+
# �����ꂽ�`�F�b�N
|
65
|
+
if ix + iy != 0 and (ix == 0 or iy == 0) and # �i�i���͋p��
|
66
|
+
@map[@mx/32+ix, @my/32+iy] == 1 and # �ړ��悪���n�̂Ƃ��̂�
|
67
|
+
@mx/32 + ix >= 0 and @mx/32 + ix < @map.size_x and # �}�b�v�̒[�܂ł����s���Ȃ�
|
68
|
+
@my/32 + iy >= 0 and @my/32 + iy < @map.size_y
|
69
|
+
# 8�t���[����1�}�X�ړ�
|
70
|
+
8.times do
|
71
|
+
@mx += ix * 4 # �}�b�v��̍��W
|
72
|
+
@my += iy * 4
|
73
|
+
self.x += ix * 4 # ��ʏ�̍��W
|
74
|
+
self.y += iy * 4
|
75
|
+
wait # wait����Ǝ��̃t���[����
|
76
|
+
end
|
77
|
+
else
|
78
|
+
wait
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# RenderTarget�쐬
|
85
|
+
rt = RenderTarget.new(640-64, 480-64)
|
86
|
+
|
87
|
+
# �}�b�v�̍쐬
|
88
|
+
map_base = Map.new("map.dat", mapimage, rt)
|
89
|
+
map_sub = Map.new("map_sub.dat", mapimage, rt)
|
90
|
+
|
91
|
+
# ���L����
|
92
|
+
player = Player.new(480, 480, map_base, rt)
|
93
|
+
|
94
|
+
# �}�b�v���W
|
95
|
+
map_x = player.mx - player.x
|
96
|
+
map_y = player.my - player.y
|
97
|
+
|
98
|
+
# ��ʓ��̎��L�����ړ��͈�
|
99
|
+
min_x = 128
|
100
|
+
max_x = 640 - 64 - 128 - 32
|
101
|
+
min_y = 128
|
102
|
+
max_y = 480 - 64 - 128 - 32
|
103
|
+
|
104
|
+
Window.loop do
|
105
|
+
# �l�ړ�����
|
106
|
+
player.update
|
107
|
+
|
108
|
+
# ������x��ʂ̒[�܂ōs������}�b�v���X�N���[�������Ď��L�����͎~�߂�
|
109
|
+
if player.x < min_x
|
110
|
+
# �}�b�v�̒[����Ȃ���������������
|
111
|
+
if map_x > 0
|
112
|
+
map_x -= 4
|
113
|
+
player.x += 4
|
114
|
+
end
|
115
|
+
end
|
116
|
+
if player.x > max_x
|
117
|
+
if map_x < map_base.size_x * 32 - rt.width
|
118
|
+
map_x += 4
|
119
|
+
player.x -= 4
|
120
|
+
end
|
121
|
+
end
|
122
|
+
if player.y < min_y
|
123
|
+
if map_y > 0
|
124
|
+
map_y -= 4
|
125
|
+
player.y += 4
|
126
|
+
end
|
127
|
+
end
|
128
|
+
if player.y > max_y
|
129
|
+
if map_y < map_base.size_y * 32 - rt.height
|
130
|
+
map_y += 4
|
131
|
+
player.y -= 4
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
# rt�Ƀx�[�X�}�b�v��`��
|
136
|
+
map_base.draw(map_x, map_y)
|
137
|
+
|
138
|
+
# rt�ɐl�`��
|
139
|
+
player.draw
|
140
|
+
|
141
|
+
# rt�ɏ�w�}�b�v��`��
|
142
|
+
map_sub.draw(map_x, map_y)
|
143
|
+
|
144
|
+
# rt����ʂɕ`��
|
145
|
+
Window.draw(32, 32, rt)
|
146
|
+
|
147
|
+
# �G�X�P�[�v�L�[�ŏI��
|
148
|
+
break if Input.key_push?(K_ESCAPE)
|
149
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
# �X�N���[���T���v�����̂Q(�[�Ŏ~�܂�X�N���[��)
|
2
|
+
require 'dxruby'
|
3
|
+
require './map'
|
4
|
+
|
5
|
+
# �G�̃f�[�^�����
|
6
|
+
mapimage = []
|
7
|
+
mapimage.push(Image.new(32, 32, [100, 100, 200])) # �C
|
8
|
+
mapimage.push(Image.new(32, 32, [50, 200, 50])) # ���n
|
9
|
+
mapimage.push(Image.new(32, 32, [50, 200, 50]). # �̍���
|
10
|
+
box_fill(13, 0, 18, 28, [200, 50, 50]))
|
11
|
+
mapimage.push(Image.new(32, 32, [50, 200, 50]). # �R
|
12
|
+
triangle_fill(15, 0, 0, 31, 31, 31, [200, 100,100]))
|
13
|
+
mapimage.push(Image.new(32, 32). # �̂����܁B�w�i�͓����F�ɂ��Ă����B
|
14
|
+
box_fill(13, 16, 18, 31, [200, 50, 50]).
|
15
|
+
circle_fill(16, 10, 8, [0, 255, 0]))
|
16
|
+
|
17
|
+
# Fiber���g���₷�����郂�W���[��
|
18
|
+
module FiberSprite
|
19
|
+
def initialize(x=0,y=0,image=nil)
|
20
|
+
super
|
21
|
+
@fiber = Fiber.new do
|
22
|
+
self.fiber_proc
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def update
|
27
|
+
@fiber.resume
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
def wait(t=1)
|
32
|
+
t.times{Fiber.yield}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# ���L����
|
37
|
+
class Player < Sprite
|
38
|
+
include FiberSprite
|
39
|
+
attr_accessor :mx, :my
|
40
|
+
|
41
|
+
def initialize(x, y, map, target=Window)
|
42
|
+
@mx, @my, @map, self.target = x, y, map, target
|
43
|
+
super(8 * 32, 6 * 32)
|
44
|
+
|
45
|
+
# ���͏�ɂ͂ݏo���ĕ`�悳���̂ł��̂Ԃ�ʒu�����H
|
46
|
+
self.center_x = 0
|
47
|
+
self.center_y = 16
|
48
|
+
self.offset_sync = true
|
49
|
+
|
50
|
+
# �_�l�ԉ摜
|
51
|
+
self.image = Image.new(32, 48).
|
52
|
+
circle(15, 5, 5, [255, 255, 255]).
|
53
|
+
line(5, 18, 26, 18, [255, 255, 255]).
|
54
|
+
line(15, 10, 15, 31, [255, 255, 255]).
|
55
|
+
line(15, 31, 5, 47, [255, 255, 255]).
|
56
|
+
line(15, 31, 25, 47, [255, 255, 255])
|
57
|
+
end
|
58
|
+
|
59
|
+
# Player#update����ƌĂ��Fiber�̒��g
|
60
|
+
def fiber_proc
|
61
|
+
loop do
|
62
|
+
ix, iy = Input.x, Input.y
|
63
|
+
|
64
|
+
# �����ꂽ�`�F�b�N
|
65
|
+
if ix + iy != 0 and (ix == 0 or iy == 0) and # �i�i���͋p��
|
66
|
+
@map[@mx/32+ix, @my/32+iy] == 1 # �ړ��悪���n�̂Ƃ��̂�
|
67
|
+
# 8�t���[����1�}�X�ړ�
|
68
|
+
8.times do
|
69
|
+
@mx += ix * 4 # �}�b�v��̍��W
|
70
|
+
@my += iy * 4
|
71
|
+
self.x += ix * 4 # ��ʏ�̍��W
|
72
|
+
self.y += iy * 4
|
73
|
+
wait # wait����Ǝ��̃t���[����
|
74
|
+
end
|
75
|
+
else
|
76
|
+
wait
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# RenderTarget�쐬
|
83
|
+
rt = RenderTarget.new(608-64, 480-64)
|
84
|
+
|
85
|
+
# �}�b�v�̍쐬
|
86
|
+
map_base = Map.new("map.dat", mapimage, rt)
|
87
|
+
map_sub = Map.new("map_sub.dat", mapimage, rt)
|
88
|
+
|
89
|
+
# ���L����
|
90
|
+
player = Player.new(480, 480, map_base, rt)
|
91
|
+
|
92
|
+
# �}�b�v���W
|
93
|
+
map_x = player.mx - player.x
|
94
|
+
map_y = player.my - player.y
|
95
|
+
|
96
|
+
# ��ʓ��̎��L�����ړ��͈�
|
97
|
+
min_x = 0
|
98
|
+
max_x = 608 - 64 - 32
|
99
|
+
min_y = 0
|
100
|
+
max_y = 480 - 64 - 32
|
101
|
+
|
102
|
+
# ���C������
|
103
|
+
fiber = Fiber.new do
|
104
|
+
loop do
|
105
|
+
# �l�ړ�����
|
106
|
+
player.update
|
107
|
+
|
108
|
+
# ��ʂ̒[�܂ł���������
|
109
|
+
dx = dy = 0
|
110
|
+
dx = -8 if player.x < min_x
|
111
|
+
dx = 8 if player.x > max_x
|
112
|
+
dy = -8 if player.y < min_y
|
113
|
+
dy = 8 if player.y > max_y
|
114
|
+
|
115
|
+
if dx != 0 or dy != 0
|
116
|
+
count = (dx != 0 ? 512/8 : 384/8)
|
117
|
+
count.times do
|
118
|
+
map_x += dx
|
119
|
+
map_y += dy
|
120
|
+
player.x -= dx
|
121
|
+
player.y -= dy
|
122
|
+
Fiber.yield
|
123
|
+
end
|
124
|
+
else
|
125
|
+
Fiber.yield
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
Window.loop do
|
131
|
+
# ���C��������Fiber
|
132
|
+
fiber.resume
|
133
|
+
|
134
|
+
# rt�Ƀx�[�X�}�b�v��`��
|
135
|
+
map_base.draw(map_x, map_y)
|
136
|
+
|
137
|
+
# rt�ɐl�`��
|
138
|
+
player.draw
|
139
|
+
|
140
|
+
# rt�ɏ�w�}�b�v��`��
|
141
|
+
map_sub.draw(map_x, map_y)
|
142
|
+
|
143
|
+
# rt����ʂɕ`��
|
144
|
+
Window.draw(48, 32, rt)
|
145
|
+
|
146
|
+
# �G�X�P�[�v�L�[�ŏI��
|
147
|
+
break if Input.key_push?(K_ESCAPE)
|
148
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'dxruby'
|
2
|
+
|
3
|
+
count = 0
|
4
|
+
image = Image.new(200, 200).box_fill(0, 0, 99, 99, C_RED)
|
5
|
+
.box_fill(100, 0, 199, 99, C_YELLOW)
|
6
|
+
.box_fill(0, 100, 99, 199, C_GREEN)
|
7
|
+
.box_fill(100, 100, 199, 199, C_BLUE)
|
8
|
+
|
9
|
+
Window.loop do
|
10
|
+
Window.drawTile(0, 0, [[0]], [image], count, count, 5, 4)
|
11
|
+
count += 1
|
12
|
+
break if Input.key_push?(K_ESCAPE)
|
13
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# -*- coding: Windows-31J -*-
|
2
|
+
|
3
|
+
class FlashShader < DXRuby::Shader
|
4
|
+
hlsl = <<EOS
|
5
|
+
// (1) �O���[�o���ϐ�
|
6
|
+
float3 g_color;
|
7
|
+
float g_level;
|
8
|
+
texture tex0;
|
9
|
+
|
10
|
+
// (2) �T���v��
|
11
|
+
sampler Samp0 = sampler_state
|
12
|
+
{
|
13
|
+
Texture =<tex0>;
|
14
|
+
AddressU=BORDER;
|
15
|
+
AddressV=BORDER;
|
16
|
+
};
|
17
|
+
|
18
|
+
// (3) ���o�͂̍\����
|
19
|
+
struct PixelIn
|
20
|
+
{
|
21
|
+
float2 UV : TEXCOORD0;
|
22
|
+
};
|
23
|
+
struct PixelOut
|
24
|
+
{
|
25
|
+
float4 Color : COLOR0;
|
26
|
+
};
|
27
|
+
|
28
|
+
// (4) �s�N�Z���V�F�[�_�̃v���O����
|
29
|
+
PixelOut PS(PixelIn input)
|
30
|
+
{
|
31
|
+
PixelOut output;
|
32
|
+
output.Color.rgb = tex2D( Samp0, input.UV ).rgb * g_level + g_color * (1.0-g_level);
|
33
|
+
output.Color.a = tex2D( Samp0, input.UV ).a;
|
34
|
+
|
35
|
+
return output;
|
36
|
+
}
|
37
|
+
|
38
|
+
// (5) technique��`
|
39
|
+
technique Flash
|
40
|
+
{
|
41
|
+
pass P0 // �p�X
|
42
|
+
{
|
43
|
+
PixelShader = compile ps_2_0 PS();
|
44
|
+
}
|
45
|
+
}
|
46
|
+
EOS
|
47
|
+
|
48
|
+
@@core = DXRuby::Shader::Core.new(
|
49
|
+
hlsl,
|
50
|
+
{
|
51
|
+
:g_color => :float,
|
52
|
+
:g_level => :float,
|
53
|
+
}
|
54
|
+
)
|
55
|
+
|
56
|
+
|
57
|
+
# color�̓t���b�V���F�Aduration�͑J�ڂɂ�����t���[����
|
58
|
+
def initialize(duration, color = [255, 255, 255])
|
59
|
+
super(@@core, "Flash")
|
60
|
+
self.color = color
|
61
|
+
self.g_level = 1.0
|
62
|
+
@duration = duration
|
63
|
+
@count = 0
|
64
|
+
|
65
|
+
# �V�F�[�_�p�����[�^�ݒ�̃��\�b�h�͊O������J�Ƃ���
|
66
|
+
class << self
|
67
|
+
protected :g_color, :g_color=, :g_level, :g_level=
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def color=(c)
|
72
|
+
raise DXRuby::DXRubyError, "�F�z�s���ł�" if c.size != 3
|
73
|
+
self.g_color = c.map{|v| v.fdiv(255)}
|
74
|
+
end
|
75
|
+
|
76
|
+
def duration=(d)
|
77
|
+
@duration = d
|
78
|
+
end
|
79
|
+
|
80
|
+
def start
|
81
|
+
@count = 0
|
82
|
+
self.g_level = 0.0
|
83
|
+
end
|
84
|
+
|
85
|
+
def next
|
86
|
+
@count += 1
|
87
|
+
if @count > @duration
|
88
|
+
self.g_level = 1.0
|
89
|
+
else
|
90
|
+
self.g_level = @count.fdiv(@duration)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# -*- coding: Windows-31J -*-
|
2
|
+
|
3
|
+
class RasterScrollShader < DXRuby::Shader
|
4
|
+
hlsl = <<EOS
|
5
|
+
float g_start;
|
6
|
+
float g_level;
|
7
|
+
texture tex0;
|
8
|
+
sampler Samp = sampler_state
|
9
|
+
{
|
10
|
+
Texture =<tex0>;
|
11
|
+
AddressU = CLAMP;
|
12
|
+
AddressV = CLAMP;
|
13
|
+
};
|
14
|
+
|
15
|
+
struct PixelIn
|
16
|
+
{
|
17
|
+
float2 UV : TEXCOORD0;
|
18
|
+
};
|
19
|
+
struct PixelOut
|
20
|
+
{
|
21
|
+
float4 Color : COLOR0;
|
22
|
+
};
|
23
|
+
|
24
|
+
PixelOut PS(PixelIn input)
|
25
|
+
{
|
26
|
+
PixelOut output;
|
27
|
+
input.UV.x = input.UV.x + sin(radians(input.UV.y*360-g_start))*g_level;
|
28
|
+
output.Color = tex2D( Samp, input.UV );
|
29
|
+
|
30
|
+
return output;
|
31
|
+
}
|
32
|
+
|
33
|
+
technique Raster
|
34
|
+
{
|
35
|
+
pass P0
|
36
|
+
{
|
37
|
+
PixelShader = compile ps_2_0 PS();
|
38
|
+
}
|
39
|
+
}
|
40
|
+
EOS
|
41
|
+
|
42
|
+
@@core = DXRuby::Shader::Core.new(
|
43
|
+
hlsl,
|
44
|
+
{
|
45
|
+
:g_start => :float,
|
46
|
+
:g_level => :float,
|
47
|
+
}
|
48
|
+
)
|
49
|
+
|
50
|
+
attr_accessor :speed, :level
|
51
|
+
|
52
|
+
# speed��1�t���[���ɐi�ފp�x(360�x�n)�Alevel�͐U���̑傫��(1.0��Image�T�C�Y)
|
53
|
+
def initialize(speed=5, level=0.1)
|
54
|
+
super(@@core, "Raster")
|
55
|
+
self.g_start = 0.0
|
56
|
+
self.g_level = 0.0
|
57
|
+
@speed = speed
|
58
|
+
@level = level
|
59
|
+
|
60
|
+
# �V�F�[�_�p�����[�^�ݒ�̃��\�b�h�͊O������J�Ƃ���
|
61
|
+
class << self
|
62
|
+
protected :g_start, :g_start=, :g_level, :g_level=
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def update
|
67
|
+
self.g_start += @speed
|
68
|
+
self.g_level = @level
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|