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,65 @@
|
|
1
|
+
require 'dxruby'
|
2
|
+
|
3
|
+
hlsl = <<EOS
|
4
|
+
texture tex0;
|
5
|
+
texture tex1;
|
6
|
+
float2 scale;
|
7
|
+
float2 pos;
|
8
|
+
float r, distance;
|
9
|
+
|
10
|
+
sampler Samp0 = sampler_state
|
11
|
+
{
|
12
|
+
Texture =<tex0>;
|
13
|
+
};
|
14
|
+
sampler Samp1 = sampler_state
|
15
|
+
{
|
16
|
+
Texture =<tex1>;
|
17
|
+
AddressU = BORDER;
|
18
|
+
AddressV = BORDER;
|
19
|
+
};
|
20
|
+
|
21
|
+
float4 PS(float2 input : TEXCOORD0) : COLOR0
|
22
|
+
{
|
23
|
+
float4 output;
|
24
|
+
float d;
|
25
|
+
|
26
|
+
clip(tex2D( Samp0, input ).r - 1.0);
|
27
|
+
|
28
|
+
d = sqrt((input.x-0.5)*(input.x-0.5) + (input.y-0.5)*(input.y-0.5))+1;
|
29
|
+
output = tex2D( Samp1, float2( pos.x + (input.x-0.5) / scale.x * distance / r * d, pos.y + (input.y-0.5) / scale.y * distance / r * d));
|
30
|
+
return output;
|
31
|
+
}
|
32
|
+
|
33
|
+
technique Lens
|
34
|
+
{
|
35
|
+
pass P0
|
36
|
+
{
|
37
|
+
PixelShader = compile ps_2_0 PS();
|
38
|
+
}
|
39
|
+
}
|
40
|
+
EOS
|
41
|
+
|
42
|
+
Window.width, Window.height = 800, 600
|
43
|
+
bgimage = Image.load("bgimage/BG42a.jpg")
|
44
|
+
image = Image.new(200,200).circle_fill(100,100,100,C_WHITE)
|
45
|
+
loupeimage = Image.new(200,200).circle(100,100,100,C_WHITE)
|
46
|
+
|
47
|
+
core = DXRuby::Shader::Core.new(hlsl, {:scale=>:float, :r=>:float, :distance=>:float, :tex1=>:texture, :pos=>:float})
|
48
|
+
shader = Shader.new(core, "Lens")
|
49
|
+
shader.scale = [bgimage.width.quo(image.width), bgimage.height.quo(image.height)]
|
50
|
+
shader.r = 1000
|
51
|
+
shader.distance = 500
|
52
|
+
shader.tex1 = bgimage
|
53
|
+
|
54
|
+
Window.loop do
|
55
|
+
shader.pos = [Input.mouse_pos_x.quo(bgimage.width), Input.mouse_pos_y.quo(bgimage.height)]
|
56
|
+
shader.distance += Input.y*10
|
57
|
+
shader.distance = 0 if shader.distance < 0
|
58
|
+
shader.distance = shader.r if shader.distance > shader.r
|
59
|
+
|
60
|
+
Window.draw(0,0,bgimage)
|
61
|
+
Window.draw_shader(Input.mouse_pos_x-image.width/2, Input.mouse_pos_y-image.width/2, image, shader)
|
62
|
+
Window.draw(Input.mouse_pos_x-image.width/2, Input.mouse_pos_y-image.width/2, loupeimage)
|
63
|
+
break if Input.key_push?(K_ESCAPE)
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'dxruby'
|
2
|
+
|
3
|
+
hlsl = <<EOS
|
4
|
+
float g_start;
|
5
|
+
float g_level;
|
6
|
+
texture tex0;
|
7
|
+
sampler Samp = sampler_state
|
8
|
+
{
|
9
|
+
Texture =<tex0>;
|
10
|
+
AddressU = BORDER;
|
11
|
+
AddressV = BORDER;
|
12
|
+
};
|
13
|
+
|
14
|
+
float4 PS(float2 input : TEXCOORD0) : COLOR0
|
15
|
+
{
|
16
|
+
float4 output;
|
17
|
+
float dist = radians(distance(input, float2(0.5, 0.5)) * 360 * 4 - g_start);
|
18
|
+
float height = sin(dist);
|
19
|
+
float slope = cos(dist);
|
20
|
+
float d = clamp(-1,1,dot(normalize(float3(input.y - 0.5, input.x - 0.5,0 )), float3(0.5,-0.5,0.5)))*slope+1;
|
21
|
+
input.y = input.y + height * g_level;
|
22
|
+
|
23
|
+
output = tex2D( Samp, input ) * d;
|
24
|
+
|
25
|
+
return output;
|
26
|
+
}
|
27
|
+
|
28
|
+
technique Raster
|
29
|
+
{
|
30
|
+
pass P0
|
31
|
+
{
|
32
|
+
PixelShader = compile ps_2_0 PS();
|
33
|
+
}
|
34
|
+
}
|
35
|
+
EOS
|
36
|
+
|
37
|
+
Window.width, Window.height = 800, 600
|
38
|
+
core = DXRuby::Shader::Core.new(hlsl, {:g_start=>:float, :g_level=>:float})
|
39
|
+
shader = Shader.new(core, "Raster")
|
40
|
+
shader.g_start = 0
|
41
|
+
shader.g_level = 0
|
42
|
+
image = Image.load("bgimage/BG42a.jpg")
|
43
|
+
|
44
|
+
Window.loop do
|
45
|
+
shader.g_start += 3
|
46
|
+
shader.g_level = 0.15
|
47
|
+
Window.draw_shader(0, 0, image, shader)
|
48
|
+
break if Input.key_push?(K_ESCAPE)
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!ruby -Ks
|
2
|
+
require 'dxruby'
|
3
|
+
require './shader/rasterscroll.rb'
|
4
|
+
|
5
|
+
map = [[0, 0, 0, 0, 0, 0, 0, 0, 29, 11, 11, 30, 34, 66, 67, 67],
|
6
|
+
[0, 0, 0, 24, 25, 26, 0, 0, 29, 11, 11, 39, 40, 6, 34, 34],
|
7
|
+
[0, 0, 24, 17, 31, 35, 0, 0, 12, 20, 11, 11, 11, 39, 40, 40],
|
8
|
+
[0, 24, 17, 34, 7, 44, 0, 28, 28, 29, 11, 11, 11, 11, 11, 11],
|
9
|
+
[0, 33, 31, 34, 35, 0, 28, 3, 37, 38, 11, 11, 11, 18, 19, 19],
|
10
|
+
[0, 42, 43, 43, 44, 28, 3, 38, 11, 11, 11, 18, 19, 13, 28, 28],
|
11
|
+
[0, 0, 0, 0, 3, 37, 38, 11, 11, 18, 19, 13, 28, 28, 28, 0],
|
12
|
+
[0, 0, 0, 3, 38, 11, 11, 11, 18, 13, 28, 28, 51, 52, 52, 52],
|
13
|
+
[0, 0, 3, 38, 11, 11, 18, 19, 13, 51, 52, 52, 86, 58, 61, 76],
|
14
|
+
[28, 0, 29, 11, 11, 18, 13, 28, 51, 86, 58, 58, 61, 61, 58, 62],
|
15
|
+
[0, 28, 29, 11, 18, 13, 28, 0, 60, 58, 61, 61, 61, 61, 76, 71],
|
16
|
+
[0, 28, 29, 11, 27, 28, 28, 51, 86, 61, 61, 58, 76, 70, 71, 0],
|
17
|
+
[0, 0, 29, 11, 36, 4, 28, 60, 58, 61, 58, 76, 71, 0, 1, 2],
|
18
|
+
[0, 28, 29, 11, 11, 36, 4, 69, 70, 70, 70, 71, 0, 1, 2, 0],
|
19
|
+
[0, 0, 12, 20, 11, 11, 27, 0, 1, 0, 1, 1, 1, 2, 2, 0],
|
20
|
+
[0, 0, 28, 12, 20, 11, 27, 0, 0, 0, 2, 2, 0, 2, 2, 0],
|
21
|
+
[0, 0, 0, 2, 29, 11, 27, 1, 2, 2, 2, 0, 0, 2, 2, 2],
|
22
|
+
[0, 0, 0, 2, 29, 11, 27, 1, 0, 1, 1, 2, 2, 0, 0, 2],
|
23
|
+
[0, 0, 0, 0, 29, 11, 27, 1, 0, 2, 2, 2, 1, 1, 2, 2],
|
24
|
+
[0, 45, 47, 2, 29, 11, 36, 4, 1, 2, 2, 0, 0, 2, 2, 0],
|
25
|
+
[45, 82, 56, 0, 29, 11, 11, 36, 4, 1, 2, 2, 2, 2, 0, 0],
|
26
|
+
[54, 0, 56, 0, 12, 20, 11, 11, 36, 37, 4, 0, 2, 2, 2, 2],
|
27
|
+
[54, 55, 81, 46, 47, 12, 20, 11, 11, 11, 36, 4, 1, 1, 1, 2],
|
28
|
+
[54, 55, 0, 0, 56, 0, 12, 19, 20, 11, 11, 36, 37, 4, 1, 1],
|
29
|
+
[54, 0, 55, 55, 56, 0, 0, 0, 12, 20, 11, 11, 11, 36, 37, 37],
|
30
|
+
[63, 73, 55, 55, 56, 0, 0, 2, 2, 29, 11, 11, 11, 11, 11, 11],
|
31
|
+
[0, 54, 0, 55, 81, 47, 0, 2, 3, 38, 11, 11, 11, 11, 11, 11],
|
32
|
+
[0, 54, 0, 0, 55, 56, 2, 0, 29, 11, 11, 11, 21, 22, 22, 22],
|
33
|
+
[0, 63, 64, 64, 64, 65, 0, 0, 29, 11, 11, 21, 15, 48, 49, 49],
|
34
|
+
[0, 0, 0, 0, 0, 0, 0, 0, 29, 11, 11, 30, 34, 57, 34, 34],
|
35
|
+
]
|
36
|
+
|
37
|
+
shader = RasterScrollShader.new(5, 0.1)
|
38
|
+
rt = RenderTarget.new(640, 480)
|
39
|
+
image = Image.load_to_array("image/maptile.png", 9, 10)
|
40
|
+
|
41
|
+
Window.loop do
|
42
|
+
rt.draw_tile(150, 16, map, image, 0, 0, 12, 14)
|
43
|
+
rt.update
|
44
|
+
shader.update
|
45
|
+
Window.draw_shader(0, 0, rt, shader)
|
46
|
+
break if Input.key_push?(K_ESCAPE)
|
47
|
+
end
|
48
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#!ruby -Ks
|
2
|
+
require 'dxruby'
|
3
|
+
require './shader/rgsssprite'
|
4
|
+
|
5
|
+
Window.width = 800
|
6
|
+
Window.height = 600
|
7
|
+
|
8
|
+
s = RgssSprite.new
|
9
|
+
s.image = Image.load('./bgimage/BG10a_80.jpg')
|
10
|
+
|
11
|
+
Window.loop do
|
12
|
+
|
13
|
+
# Z�Ńt���b�V��������
|
14
|
+
s.flash if Input.key_push?(K_Z)
|
15
|
+
|
16
|
+
# X�������Ă���ԃO���C�X�P�[���ɂȂ�
|
17
|
+
if Input.key_down?(K_X)
|
18
|
+
s.gray = 255
|
19
|
+
else
|
20
|
+
s.gray = 0
|
21
|
+
end
|
22
|
+
|
23
|
+
# C�������Ă���ԁA�ԐF�������Ȃ�
|
24
|
+
if Input.key_down?(K_C)
|
25
|
+
s.tone = [-255,0,0]
|
26
|
+
else
|
27
|
+
s.tone = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
# V�������Ă���ԁA���u�����h����
|
31
|
+
if Input.key_down?(K_V)
|
32
|
+
s.color = [60,0,0,255]
|
33
|
+
else
|
34
|
+
s.color = nil
|
35
|
+
end
|
36
|
+
|
37
|
+
s.update
|
38
|
+
s.draw
|
39
|
+
break if Input.key_push?(K_ESCAPE)
|
40
|
+
end
|
41
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'dxruby'
|
2
|
+
|
3
|
+
hlsl = <<EOS
|
4
|
+
texture tex0;
|
5
|
+
|
6
|
+
sampler Samp0 = sampler_state
|
7
|
+
{
|
8
|
+
Texture =<tex0>;
|
9
|
+
AddressU = WRAP;
|
10
|
+
AddressV = WRAP;
|
11
|
+
};
|
12
|
+
|
13
|
+
float4 PS(float2 input : TEXCOORD0) : COLOR0
|
14
|
+
{
|
15
|
+
return tex2D( Samp0, float2((input.x-0.5) / (input.y+0.20), (input.y-1) / (input.y+0.20)) );
|
16
|
+
}
|
17
|
+
|
18
|
+
technique SH
|
19
|
+
{
|
20
|
+
pass P0
|
21
|
+
{
|
22
|
+
PixelShader = compile ps_2_0 PS();
|
23
|
+
}
|
24
|
+
}
|
25
|
+
EOS
|
26
|
+
|
27
|
+
core = Shader::Core.new(hlsl,{})
|
28
|
+
shader = Shader.new(core, "SH")
|
29
|
+
|
30
|
+
image = Image.new(80, 80,[0, 255, 0])
|
31
|
+
image.box_fill(0, 0, 39, 39, [150,250,150])
|
32
|
+
image.box_fill(40, 0, 79, 39, [100,250,100])
|
33
|
+
image.box_fill(0, 40, 39, 79, [200,250,200])
|
34
|
+
image.box_fill(40, 40, 79, 79, [0,220,0])
|
35
|
+
|
36
|
+
rt = RenderTarget.new(640,240)
|
37
|
+
z = 0
|
38
|
+
x = 0
|
39
|
+
y = 0
|
40
|
+
Window.loop do
|
41
|
+
z -= 10
|
42
|
+
x += Input.x * 5
|
43
|
+
y -= Input.y * 2
|
44
|
+
y = 0 if y < 0
|
45
|
+
y = 100 if y > 100
|
46
|
+
|
47
|
+
rt.draw_tile(0, 0, [[0]], [image], x, z, 8, 3).update
|
48
|
+
Window.draw_ex(0, 240, rt, :shader=>shader, :scaley=>y/200.0+0.5, :centery=>240.0)
|
49
|
+
break if Input.key_push?(K_ESCAPE)
|
50
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'dxruby'
|
2
|
+
|
3
|
+
hlsl = <<EOS
|
4
|
+
texture tex0;
|
5
|
+
float2 raito;
|
6
|
+
|
7
|
+
sampler Samp0 = sampler_state
|
8
|
+
{
|
9
|
+
Texture =<tex0>;
|
10
|
+
AddressU = BORDER;
|
11
|
+
AddressV = BORDER;
|
12
|
+
};
|
13
|
+
|
14
|
+
float4 PS1(float2 input : TEXCOORD0) : COLOR0
|
15
|
+
{
|
16
|
+
float pi = acos(-1);
|
17
|
+
return tex2D( Samp0,
|
18
|
+
float2( ((1 - (acos((input.x*2 - 1.0) ) / pi)) - 0.5) + 0.5
|
19
|
+
, ((1 - (acos((input.y*2 - 1.0) ) / pi)) - 0.5) + 0.5) );
|
20
|
+
// , input.y ));
|
21
|
+
}
|
22
|
+
|
23
|
+
float4 PS2(float2 input : TEXCOORD0) : COLOR0
|
24
|
+
{
|
25
|
+
return tex2D( Samp0,
|
26
|
+
float2((input.x - 0.5) / cos(asin((input.y*2 - 1.0))) / raito.x + 0.5
|
27
|
+
, (input.y - 0.5) / raito.y + 0.5) );
|
28
|
+
}
|
29
|
+
|
30
|
+
technique Sphere1
|
31
|
+
{
|
32
|
+
pass P0
|
33
|
+
{
|
34
|
+
PixelShader = compile ps_2_0 PS1();
|
35
|
+
}
|
36
|
+
}
|
37
|
+
technique Sphere2
|
38
|
+
{
|
39
|
+
pass P0
|
40
|
+
{
|
41
|
+
PixelShader = compile ps_2_0 PS2();
|
42
|
+
}
|
43
|
+
}
|
44
|
+
EOS
|
45
|
+
|
46
|
+
Window.width, Window.height = 800, 600
|
47
|
+
image = Image.load("bgimage/world_map2.png")
|
48
|
+
image = image.slice(4, 5, image.width - 10, image.height - 9)
|
49
|
+
|
50
|
+
core = DXRuby::Shader::Core.new(hlsl, {:raito=>:float})
|
51
|
+
shader1 = Shader.new(core, "Sphere1")
|
52
|
+
shader2 = Shader.new(core, "Sphere2")
|
53
|
+
shader1.raito = shader2.raito = [600.quo(Window.width), 600.quo(Window.height)]
|
54
|
+
|
55
|
+
rt1 = RenderTarget.new(image.width/2, image.height)
|
56
|
+
rt2 = RenderTarget.new(Window.width, Window.height)
|
57
|
+
x = 0
|
58
|
+
|
59
|
+
Window.loop do
|
60
|
+
x -= 3
|
61
|
+
rt1.draw_tile(0, 0, [[0]], [image], x, 0, 2, 1).update
|
62
|
+
rt2.draw_ex(0, 0, rt1, :shader=>shader1, :centerx=>0, :centery=>0, :scalex=>Window.width.quo(rt1.width), :scaley=>Window.height.quo(rt1.height) ).update
|
63
|
+
Window.draw_ex(0, 0, rt2, :shader=>shader2,:angle=>23.4)
|
64
|
+
break if Input.key_push?(K_ESCAPE)
|
65
|
+
end
|
66
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#!ruby -Ks
|
2
|
+
require 'dxruby'
|
3
|
+
require './shader/transition'
|
4
|
+
|
5
|
+
Window.width = 800
|
6
|
+
Window.height = 600
|
7
|
+
|
8
|
+
shader = []
|
9
|
+
# ���[���摜��640*480�A�w�i�摜��800*600�Ȃ̂Ń��[���摜���g�債�ăV�F�[�_�ɐݒ肷��
|
10
|
+
# ����ȃ��\�b�h�`�F�C�����ł��Ă��܂��Ƃ����\
|
11
|
+
# ���\�b�h�̖߂�l�͌��\���������Ȃ̂ŁA�ł��Ă����͂��Ȃ̂ɂł��Ȃ����\�b�h����������A����������
|
12
|
+
shader << TransitionShader.new(100,
|
13
|
+
RenderTarget.new(800,600).
|
14
|
+
draw_scale(0, 0, Image.load("./rule/�E�Q����.png"), 800/640.0, 600/480.0, 0, 0).
|
15
|
+
update.
|
16
|
+
to_image,
|
17
|
+
20)
|
18
|
+
|
19
|
+
# �������摜�����̂܂ܐH�킹��Ɖ�ʑS�̂ɌJ��Ԃ��Ďg��
|
20
|
+
shader << TransitionShader.new(100,
|
21
|
+
Image.load("./rule/�`�F�b�J�[.png"),
|
22
|
+
20)
|
23
|
+
shader << TransitionShader.new(100,
|
24
|
+
Image.load("./rule/���u���C���h.png"),
|
25
|
+
20)
|
26
|
+
|
27
|
+
|
28
|
+
# �w�i�摜
|
29
|
+
bg = [Image.load('./bgimage/BG10a_80.jpg'),
|
30
|
+
Image.load('./bgimage/BG13a_80.jpg'),
|
31
|
+
Image.load('./bgimage/BG00a1_80.jpg')
|
32
|
+
]
|
33
|
+
|
34
|
+
count = 100
|
35
|
+
mode = 0
|
36
|
+
image_new = bg[0]
|
37
|
+
image_old = nil
|
38
|
+
|
39
|
+
# �X�^�[�g����new�̂ݕ\��
|
40
|
+
# Z����������new��old�ɂȂ��āAold����O�ɕ`�悳��A�g�����W�V�������������B
|
41
|
+
# new��3���̉摜�����ԂɁB
|
42
|
+
Window.loop do
|
43
|
+
if count < 100
|
44
|
+
count += 1
|
45
|
+
shader[mode].frame_count = count
|
46
|
+
end
|
47
|
+
|
48
|
+
if Input.key_down?(K_Z) && count == 100
|
49
|
+
count = 0
|
50
|
+
image_old = image_new
|
51
|
+
mode = mode == 2 ? 0 : mode + 1
|
52
|
+
image_new = bg[mode]
|
53
|
+
shader[mode].start
|
54
|
+
end
|
55
|
+
|
56
|
+
Window.draw(0,0,image_new)
|
57
|
+
Window.draw_shader(0,0,image_old, shader[mode]) if count < 100
|
58
|
+
|
59
|
+
break if Input.key_push?(K_ESCAPE)
|
60
|
+
end
|
61
|
+
|
62
|
+
|
@@ -0,0 +1,223 @@
|
|
1
|
+
require 'dxruby'
|
2
|
+
|
3
|
+
class Vector
|
4
|
+
def initialize(*v)
|
5
|
+
@vec = v
|
6
|
+
end
|
7
|
+
|
8
|
+
def rotate(angle)
|
9
|
+
x = @vec[0] * Math.cos(Math::PI / 180 * angle) - @vec[1] * Math.sin(Math::PI / 180 * angle)
|
10
|
+
y = @vec[0] * Math.sin(Math::PI / 180 * angle) + @vec[1] * Math.cos(Math::PI / 180 * angle)
|
11
|
+
temp = @vec.dup
|
12
|
+
temp[0] = x
|
13
|
+
temp[1] = y
|
14
|
+
Vector.new(*temp)
|
15
|
+
end
|
16
|
+
|
17
|
+
def +(v)
|
18
|
+
case v
|
19
|
+
when Vector
|
20
|
+
Vector.new(*@vec.map.with_index{|s,i|s+v[i]})
|
21
|
+
when Array
|
22
|
+
Vector.new(*@vec.map.with_index{|s,i|s+v[i]})
|
23
|
+
when Numeric
|
24
|
+
Vector.new(*@vec.map{|s|s+v})
|
25
|
+
else
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def *(matrix)
|
31
|
+
result = []
|
32
|
+
for i in 0..(matrix.size-1)
|
33
|
+
data = 0
|
34
|
+
for j in 0..(@vec.size-1)
|
35
|
+
data += @vec[j] * matrix[j][i]
|
36
|
+
end
|
37
|
+
result.push(data)
|
38
|
+
end
|
39
|
+
return Vector.new(*result)
|
40
|
+
end
|
41
|
+
|
42
|
+
def [](i)
|
43
|
+
@vec[i]
|
44
|
+
end
|
45
|
+
|
46
|
+
def size
|
47
|
+
@vec.size
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_a
|
51
|
+
@vec
|
52
|
+
end
|
53
|
+
|
54
|
+
def x
|
55
|
+
@vec[0]
|
56
|
+
end
|
57
|
+
def y
|
58
|
+
@vec[1]
|
59
|
+
end
|
60
|
+
def z
|
61
|
+
@vec[2]
|
62
|
+
end
|
63
|
+
def w
|
64
|
+
@vec[3]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class Matrix
|
69
|
+
def initialize(*arr)
|
70
|
+
@arr = Array.new(4) {|i| Vector.new(*arr[i])}
|
71
|
+
end
|
72
|
+
|
73
|
+
def *(a)
|
74
|
+
result = []
|
75
|
+
for i in 0..(a.size-1)
|
76
|
+
result.push(@arr[i] * a)
|
77
|
+
end
|
78
|
+
return Matrix.new(*result)
|
79
|
+
end
|
80
|
+
|
81
|
+
def [](i)
|
82
|
+
@arr[i]
|
83
|
+
end
|
84
|
+
|
85
|
+
def size
|
86
|
+
@arr.size
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.create_rotation_z(angle)
|
90
|
+
cos = Math.cos(Math::PI/180 * angle)
|
91
|
+
sin = Math.sin(Math::PI/180 * angle)
|
92
|
+
return Matrix.new(
|
93
|
+
[ cos, sin, 0, 0],
|
94
|
+
[-sin, cos, 0, 0],
|
95
|
+
[ 0, 0, 1, 0],
|
96
|
+
[ 0, 0, 0, 1]
|
97
|
+
)
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.create_rotation_x(angle)
|
101
|
+
cos = Math.cos(Math::PI/180 * angle)
|
102
|
+
sin = Math.sin(Math::PI/180 * angle)
|
103
|
+
return Matrix.new(
|
104
|
+
[ 1, 0, 0, 0],
|
105
|
+
[ 0, cos, sin, 0],
|
106
|
+
[ 0,-sin, cos, 0],
|
107
|
+
[ 0, 0, 0, 1]
|
108
|
+
)
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.create_rotation_y(angle)
|
112
|
+
cos = Math.cos(Math::PI/180 * angle)
|
113
|
+
sin = Math.sin(Math::PI/180 * angle)
|
114
|
+
return Matrix.new(
|
115
|
+
[ cos, 0,-sin, 0],
|
116
|
+
[ 0, 1, 0, 0],
|
117
|
+
[ sin, 0, cos, 0],
|
118
|
+
[ 0, 0, 0, 1]
|
119
|
+
)
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.create_transration(x, y, z)
|
123
|
+
return Matrix.new(
|
124
|
+
[ 1, 0, 0, 0],
|
125
|
+
[ 0, 1, 0, 0],
|
126
|
+
[ 0, 0, 1, 0],
|
127
|
+
[ x, y, z, 1]
|
128
|
+
)
|
129
|
+
end
|
130
|
+
|
131
|
+
def to_a
|
132
|
+
@arr.map {|v|v.to_a}.flatten
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
hlsl = <<EOS
|
138
|
+
float4x4 g_world, g_view, g_proj;
|
139
|
+
texture tex0;
|
140
|
+
|
141
|
+
sampler Samp = sampler_state
|
142
|
+
{
|
143
|
+
Texture =<tex0>;
|
144
|
+
};
|
145
|
+
|
146
|
+
struct VS_OUTPUT
|
147
|
+
{
|
148
|
+
float4 pos : POSITION;
|
149
|
+
float2 tex : TEXCOORD0;
|
150
|
+
};
|
151
|
+
|
152
|
+
VS_OUTPUT VS(float4 pos: POSITION, float2 tex: TEXCOORD0)
|
153
|
+
{
|
154
|
+
VS_OUTPUT output;
|
155
|
+
|
156
|
+
output.pos = mul(mul(mul(pos, g_world), g_view), g_proj);
|
157
|
+
output.tex = tex;
|
158
|
+
|
159
|
+
return output;
|
160
|
+
}
|
161
|
+
|
162
|
+
float4 PS(float2 input : TEXCOORD0) : COLOR0
|
163
|
+
{
|
164
|
+
return tex2D( Samp, input );
|
165
|
+
}
|
166
|
+
|
167
|
+
technique
|
168
|
+
{
|
169
|
+
pass
|
170
|
+
{
|
171
|
+
VertexShader = compile vs_2_0 VS();
|
172
|
+
PixelShader = compile ps_2_0 PS();
|
173
|
+
}
|
174
|
+
}
|
175
|
+
EOS
|
176
|
+
|
177
|
+
core = Shader::Core.new(hlsl, {:g_world=>:float, :g_view=>:float, :g_proj=>:float})
|
178
|
+
shader = Shader.new(core)
|
179
|
+
|
180
|
+
shader.g_view = Matrix.new([1, 0, 0, 0],
|
181
|
+
[0, -1, 0, 0],
|
182
|
+
[0, 0, 1, 0],
|
183
|
+
[-Window.width/2, Window.height/2, 0, 1]
|
184
|
+
).to_a
|
185
|
+
|
186
|
+
zn = 700.0
|
187
|
+
zf = 5000.0
|
188
|
+
sw = 640.0
|
189
|
+
sh = 480.0
|
190
|
+
shader.g_proj = Matrix.new([2.0 * zn / sw, 0, 0, 0],
|
191
|
+
[ 0, 2.0 * zn / sh, 0, 0],
|
192
|
+
[ 0, 0, zf / (zf - zn), 1],
|
193
|
+
[ 0, 0, -zn * zf / (zf - zn), 0]
|
194
|
+
).to_a
|
195
|
+
|
196
|
+
|
197
|
+
image = [Image.load("bgimage/BG42a.jpg"), Image.load("bgimage/BG00a1_80.jpg"),
|
198
|
+
Image.load("bgimage/BG10a_80.jpg"), Image.load("bgimage/BG13a_80.jpg"),
|
199
|
+
Image.load("bgimage/BG32a.jpg")]
|
200
|
+
|
201
|
+
a=0
|
202
|
+
Window.loop do
|
203
|
+
a += 1
|
204
|
+
idx = 0
|
205
|
+
image.map{|img|
|
206
|
+
idx += 1
|
207
|
+
[img,
|
208
|
+
Matrix.create_transration(0,0,-1000) *
|
209
|
+
Matrix.create_rotation_y(a+idx*72) *
|
210
|
+
Matrix.create_transration(0,0,1000) *
|
211
|
+
Matrix.create_rotation_x(20) *
|
212
|
+
Matrix.create_transration(300,300,1500)
|
213
|
+
]
|
214
|
+
}.sort_by{|ary|
|
215
|
+
-(Vector.new(0,0,0,1) * ary[1]).z
|
216
|
+
}.each do |ary|
|
217
|
+
shader.g_world = ary[1].to_a
|
218
|
+
Window.draw_shader(-ary[0].width/2, -ary[0].height/2, ary[0], shader)
|
219
|
+
end
|
220
|
+
break if Input.key_push?(K_ESCAPE)
|
221
|
+
end
|
222
|
+
|
223
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'dxruby'
|
2
|
+
require './shader/rgsssprite'
|
3
|
+
|
4
|
+
Window.width = 800
|
5
|
+
Window.height = 600
|
6
|
+
|
7
|
+
class Wingman
|
8
|
+
@@image = Image.load('./bgimage/BG42a.jpg')
|
9
|
+
@@shader = SpriteShader.new
|
10
|
+
def initialize
|
11
|
+
@count = 0
|
12
|
+
@flag = false
|
13
|
+
@@shader.gray = 255
|
14
|
+
end
|
15
|
+
def start
|
16
|
+
@flag = true
|
17
|
+
end
|
18
|
+
def update
|
19
|
+
@count += 2 if @flag
|
20
|
+
end
|
21
|
+
def draw
|
22
|
+
if @count < 180
|
23
|
+
Window.draw_ex(0, 0, @@image, :alpha => 128, :blend => :add, :angle => @count)
|
24
|
+
Window.draw_ex(0, 0, @@image, :alpha => 128, :blend => :add, :angle => -@count)
|
25
|
+
elsif @count < 300
|
26
|
+
@@shader.gray = (@count - 180) * 255 / 120
|
27
|
+
Window.draw_ex(0, 0, @@image, :angle => 180, :shader => @@shader)
|
28
|
+
else
|
29
|
+
Window.draw_ex(0, 0, @@image, :angle => 180, :shader => @@shader)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
w = Wingman.new
|
35
|
+
|
36
|
+
Window.loop do
|
37
|
+
w.update
|
38
|
+
w.draw
|
39
|
+
w.start if Input.key_push?(K_SPACE)
|
40
|
+
break if Input.key_push?(K_ESCAPE)
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|