ruby-miyako-mswin32 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1115 -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 +87 -0
- data/lib/Miyako/API/audio.rb +584 -0
- data/lib/Miyako/API/basic_data.rb +1026 -0
- data/lib/Miyako/API/bitmap.rb +534 -0
- data/lib/Miyako/API/choices.rb +481 -0
- data/lib/Miyako/API/collision.rb +638 -0
- data/lib/Miyako/API/diagram.rb +586 -0
- data/lib/Miyako/API/drawing.rb +151 -0
- data/lib/Miyako/API/exceptions.rb +105 -0
- data/lib/Miyako/API/fixedmap.rb +462 -0
- data/lib/Miyako/API/font.rb +430 -0
- data/lib/Miyako/API/input.rb +456 -0
- data/lib/Miyako/API/layout.rb +644 -0
- data/lib/Miyako/API/map.rb +583 -0
- data/lib/Miyako/API/map_event.rb +222 -0
- data/lib/Miyako/API/modules.rb +357 -0
- data/lib/Miyako/API/movie.rb +166 -0
- data/lib/Miyako/API/parts.rb +188 -0
- data/lib/Miyako/API/plane.rb +205 -0
- data/lib/Miyako/API/screen.rb +341 -0
- data/lib/Miyako/API/shape.rb +443 -0
- data/lib/Miyako/API/sprite.rb +773 -0
- data/lib/Miyako/API/sprite_animation.rb +494 -0
- data/lib/Miyako/API/sprite_list.rb +1135 -0
- data/lib/Miyako/API/spriteunit.rb +168 -0
- data/lib/Miyako/API/story.rb +350 -0
- data/lib/Miyako/API/textbox.rb +773 -0
- data/lib/Miyako/API/utility.rb +419 -0
- data/lib/Miyako/API/viewport.rb +190 -0
- data/lib/Miyako/API/yuki.rb +1180 -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 +201 -0
- data/lib/Miyako/miyako_no_katana.so +0 -0
- data/lib/Miyako/miyako_require_only.rb +35 -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 +329 -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 +25 -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 +66 -0
- data/sample/collision_test.rb +33 -0
- data/sample/collision_test2.rb +108 -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 +199 -0
@@ -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,66 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# 円コリジョン(CircleCollision)サンプル
|
3
|
+
# 2009.4.26 Cyross Makoto
|
4
|
+
|
5
|
+
require 'Miyako/miyako'
|
6
|
+
|
7
|
+
include Miyako
|
8
|
+
|
9
|
+
Screen.fps = 60
|
10
|
+
|
11
|
+
AMOUNT_MIN = -8
|
12
|
+
AMOUNT_MAX = 8
|
13
|
+
|
14
|
+
# Utility.in_bounds?引数生成
|
15
|
+
def segments(sprite, amounts, idx)
|
16
|
+
[sprite.segment[idx], Screen.segment[idx], amounts[idx]]
|
17
|
+
end
|
18
|
+
|
19
|
+
# 移動量の決定
|
20
|
+
def get_amount
|
21
|
+
range = AMOUNT_MAX - AMOUNT_MIN
|
22
|
+
[[rand(range)+AMOUNT_MIN,
|
23
|
+
rand(range)+AMOUNT_MIN],
|
24
|
+
[rand(range)+AMOUNT_MIN,
|
25
|
+
rand(range)+AMOUNT_MIN]]
|
26
|
+
end
|
27
|
+
|
28
|
+
radius = 32
|
29
|
+
size = [radius*2, radius*2]
|
30
|
+
pos = [radius, radius]
|
31
|
+
sprite1 = Sprite.new({:size=>size, :type=>:as})
|
32
|
+
Drawing.circle(sprite1, pos, radius, [255,0,0], true)
|
33
|
+
collision1 = CircleCollision.new(pos, radius)
|
34
|
+
sprite2 = Sprite.new({:size=>size, :type=>:as})
|
35
|
+
Drawing.circle(sprite2, pos, radius, [0,255,0], true)
|
36
|
+
collision2 = CircleCollision.new(pos, radius)
|
37
|
+
caution = Shape.text({:font => Font.serif }){ text "collision!" }
|
38
|
+
|
39
|
+
sprite1.move_to!(rand(Screen.w-size[0]), rand(Screen.h-size[1]))
|
40
|
+
sprite2.move_to!(rand(Screen.w-size[0]), rand(Screen.h-size[1]))
|
41
|
+
|
42
|
+
amount1, amount2 = get_amount
|
43
|
+
|
44
|
+
Miyako.main_loop do
|
45
|
+
break if Input.quit_or_escape?
|
46
|
+
if collision1.collision?(sprite1.pos, collision2, sprite2.pos)
|
47
|
+
amount1, amount2 = get_amount
|
48
|
+
caution.render
|
49
|
+
end
|
50
|
+
amount1[0] = -amount1[0] unless Utility.in_bounds?(*segments(sprite1, amount1, 0))
|
51
|
+
amount1[1] = -amount1[1] unless Utility.in_bounds?(*segments(sprite1, amount1, 1))
|
52
|
+
amount2[0] = -amount2[0] unless Utility.in_bounds?(*segments(sprite2, amount2, 0))
|
53
|
+
amount2[1] = -amount2[1] unless Utility.in_bounds?(*segments(sprite2, amount2, 1))
|
54
|
+
|
55
|
+
sprite1.move!(*amount1)
|
56
|
+
sprite2.move!(*amount2)
|
57
|
+
|
58
|
+
sprite1.render
|
59
|
+
sprite2.render
|
60
|
+
|
61
|
+
Font.serif.draw_text(Screen,
|
62
|
+
"distance = #{collision1.interval(sprite1.pos, collision2, sprite2.pos)}",
|
63
|
+
0,
|
64
|
+
Screen.h - Font.serif.line_height
|
65
|
+
)
|
66
|
+
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,108 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# コリジョン(Collision・CircleCollision混合)サンプル
|
3
|
+
# 2009.4.26 Cyross Makoto
|
4
|
+
|
5
|
+
require 'Miyako/miyako'
|
6
|
+
|
7
|
+
include Miyako
|
8
|
+
|
9
|
+
AMOUNT_MIN = -8
|
10
|
+
AMOUNT_MAX = 8
|
11
|
+
|
12
|
+
Screen.fps = 60
|
13
|
+
|
14
|
+
# Utility.in_bounds?引数生成
|
15
|
+
def segments(sprite, amounts, idx)
|
16
|
+
[sprite.segment[idx], Screen.segment[idx], amounts[idx]]
|
17
|
+
end
|
18
|
+
|
19
|
+
# 移動量の決定
|
20
|
+
def get_amount_one
|
21
|
+
range = AMOUNT_MAX - AMOUNT_MIN
|
22
|
+
[rand(range)+AMOUNT_MIN, rand(range)+AMOUNT_MIN]
|
23
|
+
end
|
24
|
+
def get_amount
|
25
|
+
range = AMOUNT_MAX - AMOUNT_MIN
|
26
|
+
[get_amount_one, get_amount_one]
|
27
|
+
end
|
28
|
+
|
29
|
+
# 矩形衝突判定と円形衝突判定との切り替え
|
30
|
+
collision_list = [Collision, CircleCollision].cycle
|
31
|
+
|
32
|
+
# 同時表示スプライト数
|
33
|
+
Sprites = 20
|
34
|
+
|
35
|
+
# スプライトサイズ
|
36
|
+
size = [64, 64]
|
37
|
+
# スプライト矩形(当たり判定生成用)
|
38
|
+
rect = [0, 0] + size
|
39
|
+
|
40
|
+
sprites = Array.new(Sprites){|n|
|
41
|
+
# スプライトの生成
|
42
|
+
sprite = Sprite.new({:size=>size, :type=>:as})
|
43
|
+
Drawing.circle(sprite, [size[0]/2, size[1]/2], size[0]/2, [rand(256),rand(256),rand(256)], true)
|
44
|
+
sprite.move_to!(rand(Screen.w-size[0]), rand(Screen.h-size[1]))
|
45
|
+
|
46
|
+
# コリジョンの生成
|
47
|
+
collision = Collision.new(rect)
|
48
|
+
|
49
|
+
# :collisioned => 当たり判定した?
|
50
|
+
{
|
51
|
+
:sprite => sprite,
|
52
|
+
:collision => collision,
|
53
|
+
:amount => get_amount_one
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
# 衝突判定用の組み合わせ行列を作成
|
58
|
+
matrix = sprites.combination(2)
|
59
|
+
|
60
|
+
cautions = {
|
61
|
+
Collision => Shape.text({:font => Font.serif }){ text "矩形衝突判定中" },
|
62
|
+
CircleCollision => Shape.text({:font => Font.serif }){ text "円形衝突判定中" }
|
63
|
+
}
|
64
|
+
|
65
|
+
# 初期の衝突判定方法を設定
|
66
|
+
collision_type = collision_list.next
|
67
|
+
|
68
|
+
# 一気にレンダリング
|
69
|
+
Screen.pre_render_array << sprites.map{|m| m[:sprite]}
|
70
|
+
|
71
|
+
# 判定を切り替えるタイミングを決めるタイマー
|
72
|
+
wait = WaitCounter.new(1.0)
|
73
|
+
wait.start
|
74
|
+
|
75
|
+
Miyako.main_loop do
|
76
|
+
break if Input.quit_or_escape?
|
77
|
+
|
78
|
+
# 一定時間ごとに衝突判定方法を切り替え
|
79
|
+
if wait.finish?
|
80
|
+
collision_type = collision_list.next
|
81
|
+
wait.start
|
82
|
+
end
|
83
|
+
|
84
|
+
# 衝突判定
|
85
|
+
# 衝突していたら方向を反転
|
86
|
+
matrix.each{|pair|
|
87
|
+
p0 = pair[0]
|
88
|
+
p1 = pair[1]
|
89
|
+
if collision_type.collision?(p0[:collision],
|
90
|
+
p0[:sprite].pos,
|
91
|
+
p1[:collision],
|
92
|
+
p1[:sprite].pos)
|
93
|
+
p0[:amount], p1[:amount] = get_amount
|
94
|
+
end
|
95
|
+
}
|
96
|
+
|
97
|
+
# 移動
|
98
|
+
sprites.each{|s|
|
99
|
+
# 画面の端に来たら方向転換
|
100
|
+
s[:amount][0] = -s[:amount][0] unless Utility.in_bounds?(*segments(s[:sprite], s[:amount], 0))
|
101
|
+
s[:amount][1] = -s[:amount][1] unless Utility.in_bounds?(*segments(s[:sprite], s[:amount], 1))
|
102
|
+
s[:sprite].move!(*s[:amount])
|
103
|
+
}
|
104
|
+
|
105
|
+
# 画面への描画
|
106
|
+
Screen.pre_render
|
107
|
+
cautions[collision_type].render
|
108
|
+
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
|
Binary file
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"Miyako Mapchip",1.5
|
2
|
+
"map_01.png"
|
3
|
+
32,32
|
4
|
+
1
|
5
|
+
0,0,32,32
|
6
|
+
0,0,32,32
|
7
|
+
0,0,32,32
|
8
|
+
0,0,32,32
|
9
|
+
0,0,32,32
|
10
|
+
0,0,32,32
|
11
|
+
0,0,32,32
|
12
|
+
0,0,32,32
|
13
|
+
0,0,32,32
|
14
|
+
0,0,0,0,0,0,0,0
|
15
|
+
0,0,0,0,0,0,0,0
|
16
|
+
0,0,0,0,0,0,0,0
|
17
|
+
0,0,0,0,0,0,0,0
|
18
|
+
1,-1,1,-1,-1,1,-1,1
|
19
|
+
0,0,0,0,0,0,0,0
|
20
|
+
0,0,0,0,0,0,0,0
|
21
|
+
0,0,0,0,0,0,0,0
|
22
|
+
0,0,0,0,0,0,0,0
|
23
|
+
"end"
|
Binary file
|
@@ -0,0 +1,72 @@
|
|
1
|
+
*******************************************************************************
|
2
|
+
【 作者名 】 サイロス誠
|
3
|
+
【 ソフト名 】 Miyako v2.0サンプル(固定マップ)
|
4
|
+
【 バージョン 】 2.0
|
5
|
+
【 作成日 】 2009/04/12
|
6
|
+
【 種別 】 フリーウェア
|
7
|
+
【 開発言語 】 Ruby 1.8.9-p0
|
8
|
+
【 ランタイム 】 Miyako v2.0
|
9
|
+
【 対応機種 】 Windows 2000/XP/Vista、Linux
|
10
|
+
【 再配布 】 修正BSDライセンスによる
|
11
|
+
【 転載 】 修正BSDライセンスによる
|
12
|
+
【ホームページ】 http://www.twin.ne.jp/~cyross/Miyako/
|
13
|
+
【 連絡先 】 cyross@po.twin.ne.jp
|
14
|
+
*******************************************************************************
|
15
|
+
|
16
|
+
・概要
|
17
|
+
|
18
|
+
このプログラムは、Miyako v2.0以降に対応する、Miyakoサンプルプログラムです。
|
19
|
+
スクロールしないマップ上で、スライムがうねくねしながら動き回っています。
|
20
|
+
|
21
|
+
・Miyakoについて
|
22
|
+
|
23
|
+
Miyakoに関しては、以下のURLを参考にしてください。
|
24
|
+
http://www.twin.ne.jp/~cyross/Miyako/
|
25
|
+
|
26
|
+
Miyako(Ruby、Ruby/SDL含む)のインストールに関しましては、
|
27
|
+
上記URLを辿って得られるアーカイブされたMiyakoライブラリを
|
28
|
+
展開すると、readme.txtが得られますので、そちらをご参照下さい。
|
29
|
+
|
30
|
+
本サンプルでは、MiyakoがWindows上で動作することを前提にしています。
|
31
|
+
(インストールしたRuby実行環境がActiveRubyであることも前提に
|
32
|
+
しています)
|
33
|
+
|
34
|
+
・起動方法
|
35
|
+
|
36
|
+
エクスプローラーを開き、本サンプルのフォルダ内で、「m1ku.rb」を
|
37
|
+
ダブルクリックします。
|
38
|
+
もしくは、コマンドライン上で動かす場合は、本サンプルのディレクトリに
|
39
|
+
移動して、以下のコマンドを入力します。
|
40
|
+
|
41
|
+
ruby fixed_map_sample.rb
|
42
|
+
|
43
|
+
・免責事項
|
44
|
+
|
45
|
+
本サンプルは無保証です。もし本サンプルを使用することによる不具合・トラブル
|
46
|
+
が起こったとしても、いかなるトラブルに対する責任を負わないことをご了承下さい。
|
47
|
+
|
48
|
+
本サンプルは、修正BSDライセンスに基づいた転載・再配布を許可します。
|
49
|
+
|
50
|
+
・BSDライセンス文
|
51
|
+
|
52
|
+
Copyright (c) 2009, Cyross Makoto
|
53
|
+
|
54
|
+
All rights reserved.
|
55
|
+
|
56
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
57
|
+
|
58
|
+
・Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
59
|
+
・Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
60
|
+
・Neither the name of the Cyross Makoto nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
61
|
+
|
62
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
63
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
64
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
65
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
66
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
67
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
68
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
69
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
70
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
71
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
72
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#キャラクタ管理クラス
|
3
|
+
class PChara # Player Character
|
4
|
+
extend Forwardable
|
5
|
+
attr_accessor :dir
|
6
|
+
attr_reader :collision, :position
|
7
|
+
@@dir2dir = {[0,1]=>0,[-1,0]=>1,[1,0]=>2,[0,-1]=>3}
|
8
|
+
@@dir2dir.default = -1
|
9
|
+
|
10
|
+
def initialize(fname, pw = 0.2)
|
11
|
+
# キャラクタスプライトを作成
|
12
|
+
@spr = Sprite.new({:filename => fname, :type => :color_key})
|
13
|
+
@spr.ow = 32
|
14
|
+
@spr.oh = 32
|
15
|
+
param = Hash.new
|
16
|
+
param[:sprite] = @spr
|
17
|
+
param[:wait] = pw
|
18
|
+
# コリジョン設定
|
19
|
+
@collision = Collision.new(@spr.rect)
|
20
|
+
# キャラクタ位置設定
|
21
|
+
@position = Point.new(0, 0)
|
22
|
+
# キャラパターンを表示
|
23
|
+
@anim = SpriteAnimation.new(param)
|
24
|
+
@anim.centering!
|
25
|
+
@dir = :down
|
26
|
+
end
|
27
|
+
|
28
|
+
# マップの表示座標と実座標とのマージンを設定
|
29
|
+
def margin
|
30
|
+
return Size.new(-@spr.x, -@spr.y)
|
31
|
+
end
|
32
|
+
|
33
|
+
def turn(d)
|
34
|
+
@anim.character = @@dir2dir[d]
|
35
|
+
end
|
36
|
+
|
37
|
+
def start
|
38
|
+
@anim.start
|
39
|
+
end
|
40
|
+
|
41
|
+
def stop
|
42
|
+
@anim.stop
|
43
|
+
end
|
44
|
+
|
45
|
+
def update
|
46
|
+
@anim.update_animation
|
47
|
+
end
|
48
|
+
|
49
|
+
def render
|
50
|
+
@anim.render
|
51
|
+
end
|
52
|
+
|
53
|
+
def size
|
54
|
+
return Size.new(@spr.ow, @spr.oh)
|
55
|
+
end
|
56
|
+
|
57
|
+
def_delegators(:@spr, :dispose, :rect, :ow, :oh, :x, :y)
|
58
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#共通パーツクラス
|
3
|
+
class CommonParts
|
4
|
+
include Singleton
|
5
|
+
|
6
|
+
attr_reader :box, :cbox
|
7
|
+
attr_accessor :executing
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
# create window
|
11
|
+
font = Font.sans_serif
|
12
|
+
font.size = 24
|
13
|
+
|
14
|
+
cfont = Font.sans_serif
|
15
|
+
cfont.size = 16
|
16
|
+
|
17
|
+
wcs = Sprite.new({:file => "wait_cursor.png", :type => :ac})
|
18
|
+
wcs.oh = wcs.w
|
19
|
+
scs = Sprite.new({:file => "cursor.png", :type => :ac})
|
20
|
+
scs.oh = scs.w
|
21
|
+
|
22
|
+
wc = SpriteAnimation.new({:sprite => wcs, :wait => 0.2, :pattern_list => [0, 1, 2, 3, 2, 1]})
|
23
|
+
sc = SpriteAnimation.new({:sprite => scs, :wait => 0.2, :pattern_list => [0, 1, 2, 3, 2, 1]})
|
24
|
+
tb = TextBox.new({:size => [20, 4], :font => font, :wait_cursor => wc, :select_cursor => sc})
|
25
|
+
tb.set_wait_cursor_position{|wc, tbox| wc.right!.bottom! }
|
26
|
+
|
27
|
+
wc = SpriteAnimation.new({:sprite => wcs, :wait => 0.2, :pattern_list => [0, 1, 2, 3, 2, 1]})
|
28
|
+
sc = SpriteAnimation.new({:sprite => scs, :wait => 0.2, :pattern_list => [0, 1, 2, 3, 2, 1]})
|
29
|
+
cb = TextBox.new({:size => [8, 8], :font => cfont, :wait_cursor => wc, :select_cursor => sc})
|
30
|
+
|
31
|
+
bg = Sprite.new({:size=>tb.size, :type=>:ac})
|
32
|
+
bg.fill([0,0,255,64])
|
33
|
+
|
34
|
+
cbg = Sprite.new({:size=>cb.size, :type=>:ac})
|
35
|
+
cbg.fill([0,255,0,64])
|
36
|
+
|
37
|
+
@box = Parts.new(bg.size)
|
38
|
+
@box[:bg] = bg
|
39
|
+
@box[:box] = tb
|
40
|
+
@box.center!.bottom!{|body| wc.oh }
|
41
|
+
|
42
|
+
@cbox = Parts.new(cbg.size)
|
43
|
+
@cbox[:bg] = cbg
|
44
|
+
@cbox[:box] = cb
|
45
|
+
@cbox.right!{|body| 2.percent(body) }.top!{|body| 2.percent(body) }
|
46
|
+
|
47
|
+
@executing = false
|
48
|
+
end
|
49
|
+
|
50
|
+
def start
|
51
|
+
@box.start
|
52
|
+
@cbox.start
|
53
|
+
end
|
54
|
+
|
55
|
+
def stop
|
56
|
+
@box.stop
|
57
|
+
@cbox.stop
|
58
|
+
end
|
59
|
+
|
60
|
+
def reset
|
61
|
+
@box.reset
|
62
|
+
@cbox.reset
|
63
|
+
end
|
64
|
+
|
65
|
+
def update_animation
|
66
|
+
@box.update_animation
|
67
|
+
@cbox.update_animation
|
68
|
+
end
|
69
|
+
end
|