cyross-ruby-miyako-mswin32 2.0.5
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.
- data/README +929 -0
- data/img/cursor.png +0 -0
- data/img/cursors.png +0 -0
- data/img/dice.png +0 -0
- data/img/wait_cursor.png +0 -0
- data/img/win_base.png +0 -0
- data/img/window.png +0 -0
- data/install_miyako.rb +61 -0
- data/lib/Miyako/API/audio.rb +198 -0
- data/lib/Miyako/API/basic_data.rb +573 -0
- data/lib/Miyako/API/bitmap.rb +507 -0
- data/lib/Miyako/API/choices.rb +475 -0
- data/lib/Miyako/API/collision.rb +460 -0
- data/lib/Miyako/API/diagram.rb +561 -0
- data/lib/Miyako/API/drawing.rb +151 -0
- data/lib/Miyako/API/fixedmap.rb +428 -0
- data/lib/Miyako/API/font.rb +403 -0
- data/lib/Miyako/API/input.rb +447 -0
- data/lib/Miyako/API/layout.rb +433 -0
- data/lib/Miyako/API/map.rb +529 -0
- data/lib/Miyako/API/map_event.rb +198 -0
- data/lib/Miyako/API/modules.rb +109 -0
- data/lib/Miyako/API/movie.rb +154 -0
- data/lib/Miyako/API/parts.rb +189 -0
- data/lib/Miyako/API/plane.rb +166 -0
- data/lib/Miyako/API/screen.rb +325 -0
- data/lib/Miyako/API/shape.rb +443 -0
- data/lib/Miyako/API/sprite.rb +752 -0
- data/lib/Miyako/API/sprite_animation.rb +481 -0
- data/lib/Miyako/API/spriteunit.rb +147 -0
- data/lib/Miyako/API/story.rb +300 -0
- data/lib/Miyako/API/textbox.rb +725 -0
- data/lib/Miyako/API/utility.rb +388 -0
- data/lib/Miyako/API/viewport.rb +140 -0
- data/lib/Miyako/API/yuki.rb +996 -0
- data/lib/Miyako/EXT/miyako_cairo.rb +62 -0
- data/lib/Miyako/EXT/raster_scroll.rb +138 -0
- data/lib/Miyako/EXT/slides.rb +157 -0
- data/lib/Miyako/miyako.rb +171 -0
- data/lib/Miyako/miyako_no_katana.so +0 -0
- data/logo/EGSR_logo.png +0 -0
- data/logo/EGSR_logo_bg.png +0 -0
- data/logo/EGSR_logo_fg.png +0 -0
- data/logo/EGSR_title_banner.png +0 -0
- data/logo/EGSR_title_logo.png +0 -0
- data/logo/miyako.png +0 -0
- data/logo/miyako_banner.png +0 -0
- data/logo/space.png +0 -0
- data/sample/Animation1/m1ku.rb +68 -0
- data/sample/Animation1/m1ku_arm_0.png +0 -0
- data/sample/Animation1/m1ku_arm_1.png +0 -0
- data/sample/Animation1/m1ku_arm_2.png +0 -0
- data/sample/Animation1/m1ku_arm_3.png +0 -0
- data/sample/Animation1/m1ku_back.jpg +0 -0
- data/sample/Animation1/m1ku_body.png +0 -0
- data/sample/Animation1/m1ku_eye_0.png +0 -0
- data/sample/Animation1/m1ku_eye_1.png +0 -0
- data/sample/Animation1/m1ku_eye_2.png +0 -0
- data/sample/Animation1/m1ku_eye_3.png +0 -0
- data/sample/Animation1/m1ku_hair_front.png +0 -0
- data/sample/Animation1/m1ku_hair_rear.png +0 -0
- data/sample/Animation1/readme.txt +72 -0
- data/sample/Animation2/lex.rb +96 -0
- data/sample/Animation2/lex_back.png +0 -0
- data/sample/Animation2/lex_body.png +0 -0
- data/sample/Animation2/lex_roadroller.png +0 -0
- data/sample/Animation2/lex_wheel_0.png +0 -0
- data/sample/Animation2/lex_wheel_1.png +0 -0
- data/sample/Animation2/lex_wheel_2.png +0 -0
- data/sample/Animation2/readme.txt +72 -0
- data/sample/Animation2/song_title.png +0 -0
- data/sample/Diagram_sample/back.png +0 -0
- data/sample/Diagram_sample/chr01.png +0 -0
- data/sample/Diagram_sample/chr02.png +0 -0
- data/sample/Diagram_sample/cursor.png +0 -0
- data/sample/Diagram_sample/diagram_sample_yuki2.rb +387 -0
- data/sample/Diagram_sample/readme.txt +90 -0
- data/sample/Diagram_sample/wait_cursor.png +0 -0
- data/sample/Room3/blue.rb +297 -0
- data/sample/Room3/ending.rb +180 -0
- data/sample/Room3/green.rb +220 -0
- data/sample/Room3/image/akamatsu.png +0 -0
- data/sample/Room3/image/aoyama.png +0 -0
- data/sample/Room3/image/congra.png +0 -0
- data/sample/Room3/image/congratulation.png +0 -0
- data/sample/Room3/image/congratulation_bg.png +0 -0
- data/sample/Room3/image/cursor.png +0 -0
- data/sample/Room3/image/midori.png +0 -0
- data/sample/Room3/image/mittsu_no_oheya.png +0 -0
- data/sample/Room3/image/mittsu_no_oheya_logo.png +0 -0
- data/sample/Room3/image/room_blue.png +0 -0
- data/sample/Room3/image/room_green.png +0 -0
- data/sample/Room3/image/room_red.png +0 -0
- data/sample/Room3/image/start.png +0 -0
- data/sample/Room3/image/three_doors.png +0 -0
- data/sample/Room3/image/wait_cursor.png +0 -0
- data/sample/Room3/main.rb +120 -0
- data/sample/Room3/main_component.rb +59 -0
- data/sample/Room3/readme.txt +76 -0
- data/sample/Room3/red.rb +227 -0
- data/sample/Room3/room3.rb +27 -0
- data/sample/Room3/title.rb +184 -0
- data/sample/ball_action_sample.rb +204 -0
- data/sample/blit_rop.rb +70 -0
- data/sample/cairo_sample.rb +25 -0
- data/sample/circle_collision_test.rb +62 -0
- data/sample/collision_test.rb +33 -0
- data/sample/collision_test2.rb +104 -0
- data/sample/fixed_map_test/cursor.png +0 -0
- data/sample/fixed_map_test/fixed_map_sample.rb +140 -0
- data/sample/fixed_map_test/map.csv +19 -0
- data/sample/fixed_map_test/map_01.png +0 -0
- data/sample/fixed_map_test/mapchip.csv +23 -0
- data/sample/fixed_map_test/monster.png +0 -0
- data/sample/fixed_map_test/readme.txt +72 -0
- data/sample/map_test/chara.rb +58 -0
- data/sample/map_test/chr1.png +0 -0
- data/sample/map_test/cursor.png +0 -0
- data/sample/map_test/main_parts.rb +69 -0
- data/sample/map_test/main_scene.rb +153 -0
- data/sample/map_test/map.png +0 -0
- data/sample/map_test/map2.png +0 -0
- data/sample/map_test/map_layer.csv +127 -0
- data/sample/map_test/map_manager.rb +75 -0
- data/sample/map_test/map_test.rb +23 -0
- data/sample/map_test/mapchip.csv +21 -0
- data/sample/map_test/oasis.rb +71 -0
- data/sample/map_test/readme.txt +89 -0
- data/sample/map_test/route.rb +157 -0
- data/sample/map_test/sea.png +0 -0
- data/sample/map_test/town.rb +74 -0
- data/sample/map_test/wait_cursor.png +0 -0
- data/sample/map_test/window.png +0 -0
- data/sample/polygon_test.rb +35 -0
- data/sample/rasterscroll.rb +25 -0
- data/sample/takahashi.rb +42 -0
- data/sample/text.png +0 -0
- data/sample/textbox_sample.rb +190 -0
- data/sample/transform.rb +54 -0
- data/sample/utility_test.rb +73 -0
- data/sample/utility_test2.rb +61 -0
- data/sample/utility_test3.rb +64 -0
- data/sample/utility_test4.rb +73 -0
- data/uninstall_miyako.rb +19 -0
- metadata +196 -0
data/sample/blit_rop.rb
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# 画像ビット操作サンプル
|
|
2
|
+
# 2009.4.17 Cyross Makoto
|
|
3
|
+
|
|
4
|
+
require 'Miyako/miyako'
|
|
5
|
+
|
|
6
|
+
include Miyako
|
|
7
|
+
|
|
8
|
+
# 画像が画面をはみ出そうになったら移動量を+-反転
|
|
9
|
+
# spr:: 移動対象のスプライト
|
|
10
|
+
# amt:: 移動量配列
|
|
11
|
+
# 返却値:: 変更した移動量配列
|
|
12
|
+
def turn(spr, amt)
|
|
13
|
+
amt[0] = -amt[0] if (spr.x + spr.ow) >= Screen.w
|
|
14
|
+
amt[0] = -amt[0] if spr.x <= 0
|
|
15
|
+
amt[1] = -amt[1] if (spr.y + spr.oh) >= Screen.h
|
|
16
|
+
amt[1] = -amt[1] if spr.y <= 0
|
|
17
|
+
return amt
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# マスク画像を作成
|
|
21
|
+
bmask = Sprite.new(:size=>Size.new(100,100), :type=>:ac)
|
|
22
|
+
Drawing.circle(bmask, [50,50], 50, [255,255,255], :fill)
|
|
23
|
+
|
|
24
|
+
# 描画用スプライトを作成
|
|
25
|
+
spr1 = Sprite.new(:size=>Size.new(100,100), :type=>:ac)
|
|
26
|
+
spr2 = Sprite.new(:size=>Size.new(100,100), :type=>:ac)
|
|
27
|
+
spr3 = Sprite.new(:size=>Size.new(100,100), :type=>:ac)
|
|
28
|
+
|
|
29
|
+
# 転送元背景を準備
|
|
30
|
+
bk = Sprite.new(:file=>"Animation1/m1ku_back.jpg", :type=>:as)
|
|
31
|
+
text = Sprite.new(:file=>"text.png", :type=>:ac)
|
|
32
|
+
# 表示用背景を準備(元画像を反転)
|
|
33
|
+
bk2 = bk.inverse
|
|
34
|
+
|
|
35
|
+
spr2.centering
|
|
36
|
+
spr3.right.bottom
|
|
37
|
+
|
|
38
|
+
# 移動量配列を設定
|
|
39
|
+
@amt1 = [ 4, 4]
|
|
40
|
+
@amt2 = [ 4,-4]
|
|
41
|
+
@amt3 = [-4,-4]
|
|
42
|
+
|
|
43
|
+
# Main Routine
|
|
44
|
+
Miyako.main_loop do
|
|
45
|
+
break if Input.quit_or_escape?
|
|
46
|
+
# マスク画像の転送
|
|
47
|
+
bmask.render_to(spr1)
|
|
48
|
+
bk.render_to(spr2){|src, dst| src.ox = spr2.x; src.oy = spr2.y}
|
|
49
|
+
bk2.render_to(spr3){|src, dst| src.ox = spr3.x; src.oy = spr3.y}
|
|
50
|
+
# 元画像をandして描画用スプライトへ転送
|
|
51
|
+
spr1.and!(bk){|src, dst| src.ox = spr1.x; src.oy = spr1.y}
|
|
52
|
+
# 元画像をorして描画用スプライトへ転送
|
|
53
|
+
spr2.or!(text)
|
|
54
|
+
# 元画像をxorして描画用スプライトへ転送
|
|
55
|
+
spr3.xor!(text)
|
|
56
|
+
|
|
57
|
+
# 画像を画面に描画
|
|
58
|
+
bk2.render
|
|
59
|
+
spr1.render
|
|
60
|
+
spr2.render
|
|
61
|
+
spr3.render
|
|
62
|
+
# スプライトの移動
|
|
63
|
+
spr1.move(*@amt1)
|
|
64
|
+
spr2.move(*@amt2)
|
|
65
|
+
spr3.move(*@amt3)
|
|
66
|
+
# 画像が画面をはみ出そうになったら移動量を+-反転
|
|
67
|
+
@amt1 = turn(spr1, @amt1)
|
|
68
|
+
@amt2 = turn(spr2, @amt2)
|
|
69
|
+
@amt3 = turn(spr3, @amt3)
|
|
70
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
# MiyakoCairoサンプル
|
|
3
|
+
# 2009.4.12 Cyross Makoto
|
|
4
|
+
|
|
5
|
+
require 'Miyako/miyako'
|
|
6
|
+
require 'Miyako/EXT/miyako_cairo'
|
|
7
|
+
|
|
8
|
+
sprite = Miyako::Sprite.new(:file=>"Animation2/lex_body.png", :type=>:ck)
|
|
9
|
+
sprite.bitmap.saveBMP("./sample.bmp")
|
|
10
|
+
|
|
11
|
+
surface = Miyako::MiyakoCairo.to_cairo_surface(sprite)
|
|
12
|
+
surface.write_to_png("./sample.png")
|
|
13
|
+
|
|
14
|
+
surface = Cairo::ImageSurface.new(Cairo::Format::ARGB32, 320, 240)
|
|
15
|
+
context = Cairo::Context.new(surface)
|
|
16
|
+
|
|
17
|
+
context.set_source_rgb(1.0, 0.5, 0.8)
|
|
18
|
+
context.fill{
|
|
19
|
+
context.rectangle(50, 50, 150, 100)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
surface.write_to_png("./sample2.png")
|
|
23
|
+
|
|
24
|
+
sprite = Miyako::MiyakoCairo.to_sprite(surface)
|
|
25
|
+
sprite.bitmap.saveBMP("./sample2.bmp")
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
# 円コリジョン(CircleCollision)サンプル
|
|
3
|
+
# 2009.4.25 Cyross Makoto
|
|
4
|
+
|
|
5
|
+
require 'Miyako/miyako'
|
|
6
|
+
|
|
7
|
+
include Miyako
|
|
8
|
+
|
|
9
|
+
Screen.fps = 60
|
|
10
|
+
|
|
11
|
+
# Utility.in_bounds?引数生成
|
|
12
|
+
def segments(sprite, amounts, idx)
|
|
13
|
+
[
|
|
14
|
+
[sprite.pos[idx], sprite.pos[idx] + sprite.size[idx] - 1],
|
|
15
|
+
[0, Screen.size[idx]],
|
|
16
|
+
amounts[idx]
|
|
17
|
+
]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
radius = 16
|
|
21
|
+
size = [32, 32]
|
|
22
|
+
pos = [16, 16]
|
|
23
|
+
sprite1 = Sprite.new({:size=>size, :type=>:as})
|
|
24
|
+
Drawing.circle(sprite1, pos, radius, [255,0,0], true)
|
|
25
|
+
collision1 = CircleCollision.new(pos, radius)
|
|
26
|
+
sprite2 = Sprite.new({:size=>size, :type=>:as})
|
|
27
|
+
Drawing.circle(sprite2, pos, radius, [0,255,0], true)
|
|
28
|
+
collision2 = CircleCollision.new(pos, radius)
|
|
29
|
+
caution = Shape.text({:font => Font.serif }){ text "collision!" }
|
|
30
|
+
|
|
31
|
+
sprite1.center.move(0, 128)
|
|
32
|
+
sprite2.move_to(176, 0)
|
|
33
|
+
|
|
34
|
+
amounts = [8, -8]
|
|
35
|
+
|
|
36
|
+
amount1 = [amounts.sample, amounts.sample]
|
|
37
|
+
amount2 = [amounts.sample, amounts.sample]
|
|
38
|
+
|
|
39
|
+
Miyako.main_loop do
|
|
40
|
+
break if Input.quit_or_escape?
|
|
41
|
+
if collision1.collision?(sprite1.pos, collision2, sprite2.pos)
|
|
42
|
+
amount1 = [amounts.sample, amounts.sample]
|
|
43
|
+
amount2 = [amounts.sample, amounts.sample]
|
|
44
|
+
caution.render
|
|
45
|
+
end
|
|
46
|
+
amount1[0] = -amount1[0] unless Utility.in_bounds?(*segments(sprite1, amount1, 0))
|
|
47
|
+
amount1[1] = -amount1[1] unless Utility.in_bounds?(*segments(sprite1, amount1, 1))
|
|
48
|
+
amount2[0] = -amount2[0] unless Utility.in_bounds?(*segments(sprite2, amount2, 0))
|
|
49
|
+
amount2[1] = -amount2[1] unless Utility.in_bounds?(*segments(sprite2, amount2, 1))
|
|
50
|
+
|
|
51
|
+
sprite1.move(*amount1)
|
|
52
|
+
sprite2.move(*amount2)
|
|
53
|
+
|
|
54
|
+
sprite1.render
|
|
55
|
+
sprite2.render
|
|
56
|
+
|
|
57
|
+
Font.serif.draw_text(Screen,
|
|
58
|
+
"distance = #{collision1.interval(sprite1.pos, collision2, sprite2.pos)}",
|
|
59
|
+
0,
|
|
60
|
+
Screen.h - Font.serif.line_height
|
|
61
|
+
)
|
|
62
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
# コリジョン(Collision)サンプル
|
|
3
|
+
# 2009.4.12 Cyross Makoto
|
|
4
|
+
|
|
5
|
+
require 'Miyako/miyako'
|
|
6
|
+
|
|
7
|
+
include Miyako
|
|
8
|
+
|
|
9
|
+
size = [32, 32]
|
|
10
|
+
rect = [0, 0] + size
|
|
11
|
+
sprite1 = Sprite.new({:size=>size, :type=>:as})
|
|
12
|
+
sprite1.fill([255,0,0])
|
|
13
|
+
collision1 = Collision.new(rect)
|
|
14
|
+
sprite2 = Sprite.new({:size=>size, :type=>:as})
|
|
15
|
+
sprite2.fill([0,255,0])
|
|
16
|
+
collision2 = Collision.new(rect)
|
|
17
|
+
caution = Shape.text({:font => Font.serif }){ text "collision!" }
|
|
18
|
+
|
|
19
|
+
sprite1.center.move(0, 128)
|
|
20
|
+
sprite2.center
|
|
21
|
+
|
|
22
|
+
amount = 8
|
|
23
|
+
|
|
24
|
+
Miyako.main_loop do
|
|
25
|
+
break if Input.quit_or_escape?
|
|
26
|
+
if Collision.collision?(collision1, sprite1.pos, collision2, sprite2.pos)
|
|
27
|
+
caution.render
|
|
28
|
+
else
|
|
29
|
+
sprite2.move(0, amount)
|
|
30
|
+
end
|
|
31
|
+
sprite1.render
|
|
32
|
+
sprite2.render
|
|
33
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
# コリジョン(Collision・CircleCollision混合)サンプル
|
|
3
|
+
# 2009.4.24 Cyross Makoto
|
|
4
|
+
|
|
5
|
+
require 'Miyako/miyako'
|
|
6
|
+
|
|
7
|
+
include Miyako
|
|
8
|
+
|
|
9
|
+
Screen.fps = 60
|
|
10
|
+
|
|
11
|
+
# Utility.in_bounds?引数生成
|
|
12
|
+
def segments(sprite, amounts, idx)
|
|
13
|
+
[
|
|
14
|
+
[sprite.pos[idx], sprite.pos[idx] + sprite.size[idx] - 1],
|
|
15
|
+
[0, Screen.size[idx]],
|
|
16
|
+
amounts[idx]
|
|
17
|
+
]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# 矩形衝突判定と円形衝突判定との切り替え
|
|
21
|
+
collision_list = [Collision, CircleCollision].cycle
|
|
22
|
+
|
|
23
|
+
# 同時表示スプライト数
|
|
24
|
+
Sprites = 20
|
|
25
|
+
|
|
26
|
+
# スプライトサイズ
|
|
27
|
+
size = [64, 64]
|
|
28
|
+
# スプライト矩形(当たり判定生成用)
|
|
29
|
+
rect = [0, 0] + size
|
|
30
|
+
# 移動量切り替え
|
|
31
|
+
amount = [4, -4]
|
|
32
|
+
|
|
33
|
+
sprites = Array.new(Sprites){|n|
|
|
34
|
+
# スプライトの生成
|
|
35
|
+
sprite = Sprite.new({:size=>size, :type=>:as})
|
|
36
|
+
Drawing.circle(sprite, [size[0]/2, size[1]/2], size[0]/2, [rand(256),rand(256),rand(256)], true)
|
|
37
|
+
sprite.move_to(rand(Screen.w-size[0]), rand(Screen.h-size[1]))
|
|
38
|
+
|
|
39
|
+
# コリジョンの生成
|
|
40
|
+
collision = Collision.new(rect)
|
|
41
|
+
|
|
42
|
+
# :collisioned => 当たり判定した?
|
|
43
|
+
{
|
|
44
|
+
:sprite => sprite,
|
|
45
|
+
:collision => collision,
|
|
46
|
+
:amount => [amount.sample, amount.sample]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# 衝突判定用の組み合わせ行列を作成
|
|
51
|
+
matrix = sprites.combination(2)
|
|
52
|
+
|
|
53
|
+
cautions = {
|
|
54
|
+
Collision => Shape.text({:font => Font.serif }){ text "矩形衝突判定中" },
|
|
55
|
+
CircleCollision => Shape.text({:font => Font.serif }){ text "円形衝突判定中" }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
# 初期の衝突判定方法を設定
|
|
59
|
+
collision_type = collision_list.next
|
|
60
|
+
|
|
61
|
+
# 一気にレンダリング
|
|
62
|
+
Screen.pre_render_array << sprites.map{|m| m[:sprite]}
|
|
63
|
+
|
|
64
|
+
# 判定を切り替えるタイミングを決めるタイマー
|
|
65
|
+
wait = WaitCounter.new(1.0)
|
|
66
|
+
wait.start
|
|
67
|
+
|
|
68
|
+
Miyako.main_loop do
|
|
69
|
+
break if Input.quit_or_escape?
|
|
70
|
+
|
|
71
|
+
# 一定時間ごとに衝突判定方法を切り替え
|
|
72
|
+
if wait.finish?
|
|
73
|
+
collision_type = collision_list.next
|
|
74
|
+
wait.start
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# 衝突判定
|
|
78
|
+
# 衝突していたら方向を反転
|
|
79
|
+
matrix.each{|pair|
|
|
80
|
+
p0 = pair[0]
|
|
81
|
+
p1 = pair[1]
|
|
82
|
+
if collision_type.collision?(p0[:collision],
|
|
83
|
+
p0[:sprite].pos,
|
|
84
|
+
p1[:collision],
|
|
85
|
+
p1[:sprite].pos)
|
|
86
|
+
p0[:amount][0] = -p0[:amount][0]
|
|
87
|
+
p0[:amount][1] = -p0[:amount][1]
|
|
88
|
+
p1[:amount][0] = -p1[:amount][0]
|
|
89
|
+
p1[:amount][1] = -p1[:amount][1]
|
|
90
|
+
end
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
# 移動
|
|
94
|
+
sprites.each{|s|
|
|
95
|
+
# 画面の端に来たら方向転換
|
|
96
|
+
s[:amount][0] = -s[:amount][0] unless Utility.in_bounds?(*segments(s[:sprite], s[:amount], 0))
|
|
97
|
+
s[:amount][1] = -s[:amount][1] unless Utility.in_bounds?(*segments(s[:sprite], s[:amount], 1))
|
|
98
|
+
s[:sprite].move(*s[:amount])
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
# 画面への描画
|
|
102
|
+
Screen.pre_render
|
|
103
|
+
cautions[collision_type].render
|
|
104
|
+
end
|
|
Binary file
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#encoding: UTF-8
|
|
2
|
+
# FixedMap Sample
|
|
3
|
+
# 2009.4.12 Cyross Makoto
|
|
4
|
+
|
|
5
|
+
require 'Miyako/miyako'
|
|
6
|
+
|
|
7
|
+
include Miyako
|
|
8
|
+
|
|
9
|
+
Screen::fps_view = true
|
|
10
|
+
|
|
11
|
+
# Monster Class
|
|
12
|
+
class Monster
|
|
13
|
+
extend Forwardable
|
|
14
|
+
|
|
15
|
+
def initialize(map, name, size, wait, pattern, x, y)
|
|
16
|
+
@spr = Sprite.new({:filename => name, :type => :color_key})
|
|
17
|
+
@spr.ow = size
|
|
18
|
+
@spr.oh = size
|
|
19
|
+
@coll = Collision.new(Rect.new(0, 0, @spr.ow, @spr.oh))
|
|
20
|
+
@cpos = Point.new(x, y)
|
|
21
|
+
ap = { }
|
|
22
|
+
ap[:sprite] = @spr
|
|
23
|
+
ap[:wait] = wait
|
|
24
|
+
ap[:pattern_list] = pattern
|
|
25
|
+
@anim = SpriteAnimation.new(ap)
|
|
26
|
+
@anim.snap(map)
|
|
27
|
+
@anim.left.top.move(x, y)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def start
|
|
31
|
+
@anim.start
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def update(map, events, param)
|
|
35
|
+
@anim.update_animation
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def render
|
|
39
|
+
@anim.render
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def finish
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def dispose
|
|
46
|
+
@anim.dispose
|
|
47
|
+
@spr.dispose
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def_delegators(:@anim, :start, :stop)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
class Slime < Monster
|
|
54
|
+
def initialize(map, x, y)
|
|
55
|
+
super(map, "monster.png", 32, 0.5, [0, 1, 2, 3, 2, 1], x, y)
|
|
56
|
+
@interval = 2
|
|
57
|
+
@interval_x = 0
|
|
58
|
+
@interval_y = 0
|
|
59
|
+
@cnt = 0
|
|
60
|
+
@wait0 = WaitCounter.new(0.1)
|
|
61
|
+
@wait = WaitCounter.new(0.4)
|
|
62
|
+
@types = 5
|
|
63
|
+
# 方向による移動量リスト
|
|
64
|
+
@ary = [[ 0, @spr.oh, 0, @interval, @spr.oh],
|
|
65
|
+
[ @spr.ow, 0, @interval, 0, @spr.ow],
|
|
66
|
+
[-@spr.ow, 0, -@interval, 0, @spr.ow],
|
|
67
|
+
[ 0,-@spr.oh, 0,-@interval, @spr.oh]]
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def update(map, events, param)
|
|
71
|
+
super
|
|
72
|
+
return if @wait.waiting? || @wait0.waiting?
|
|
73
|
+
if @cnt > 0
|
|
74
|
+
@anim.move(@interval_x, @interval_y)
|
|
75
|
+
@cpos.move(@interval_x, @interval_y)
|
|
76
|
+
@cnt -= @interval
|
|
77
|
+
@wait0.start
|
|
78
|
+
return
|
|
79
|
+
end
|
|
80
|
+
val = rand(@types)
|
|
81
|
+
if val == 0
|
|
82
|
+
@interval_x = 0
|
|
83
|
+
@interval_y = 0
|
|
84
|
+
@wait.start
|
|
85
|
+
else
|
|
86
|
+
data = @ary[val-1]
|
|
87
|
+
# スライムが当たっているマップ位置リストを取得
|
|
88
|
+
colls = Utility.product_position(
|
|
89
|
+
@cpos.dup.move(data[0], data[1]), @coll.rect, map.mapchips[0].chip_size.to_a
|
|
90
|
+
)
|
|
91
|
+
# 障害物に当たってない?
|
|
92
|
+
if colls.inject(true){|r, pos| r &= map[0].can_access?(0, :in, @cpos, data[0], data[1]) }
|
|
93
|
+
@interval_x, @interval_y = data[2..3]
|
|
94
|
+
@cnt = data[4]
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
class SlimeEvent
|
|
101
|
+
include MapEvent
|
|
102
|
+
|
|
103
|
+
def init(map, x, y)
|
|
104
|
+
@slime = Slime.new(map, x, y)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def update(map, events, param)
|
|
108
|
+
@slime.update(map, events, param)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def final
|
|
112
|
+
@slime.finish
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def dispose
|
|
116
|
+
@slime.dispose
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def render
|
|
120
|
+
@slime.render
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
em = MapEventManager.new
|
|
125
|
+
em.add(1, SlimeEvent)
|
|
126
|
+
|
|
127
|
+
# main
|
|
128
|
+
mp = MapChipFactory.load("./mapchip.csv")
|
|
129
|
+
@fmap = FixedMap.new(mp, "./map.csv", em)
|
|
130
|
+
|
|
131
|
+
Miyako.main_loop do
|
|
132
|
+
break if Input.quit_or_escape?
|
|
133
|
+
dx, dy = Input.trigger_amount.map{|v| v * 4 }
|
|
134
|
+
dx = 0 unless Utility.in_bounds?([@fmap.rect.x,@fmap.rect.x+@fmap.rect.w-1], [0,Screen.w-1], dx)
|
|
135
|
+
dy = 0 unless Utility.in_bounds?([@fmap.rect.y,@fmap.rect.y+@fmap.rect.h-1], [0,Screen.h-1], dy)
|
|
136
|
+
@fmap.move(dx, dy)
|
|
137
|
+
@fmap.events.each{|ee| ee.each{|e| e.update(@fmap, @fmap.events, nil)}}
|
|
138
|
+
@fmap.render_to(Screen)
|
|
139
|
+
@fmap.events.each{|ee| ee.each{|e| e.render}}
|
|
140
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"Miyako Maplayer",1.5
|
|
2
|
+
7,7
|
|
3
|
+
2
|
|
4
|
+
<0>
|
|
5
|
+
0, 1, 1, 1, 1, 1, 2
|
|
6
|
+
3, 4, 4, 4, 4, 4, 5
|
|
7
|
+
3, 4, 4, 4, 4, 4, 5
|
|
8
|
+
3, 4, 4, 4, 4, 4, 5
|
|
9
|
+
3, 4, 4, 4, 4, 4, 5
|
|
10
|
+
3, 4, 4, 4, 4, 4, 5
|
|
11
|
+
6, 7, 7, 7, 7, 7, 8
|
|
12
|
+
<event>
|
|
13
|
+
0, 0, 0, 0, 0, 0, 0
|
|
14
|
+
0, 0, 0, 0, 0, 1, 0
|
|
15
|
+
0, 0, 0, 0, 0, 0, 0
|
|
16
|
+
0, 0, 0, 1, 0, 0, 0
|
|
17
|
+
0, 0, 0, 0, 0, 0, 0
|
|
18
|
+
0, 0, 1, 0, 0, 0, 0
|
|
19
|
+
0, 0, 0, 0, 0, 0, 0
|