cyross-ruby-miyako 2.0.0

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.
Files changed (125) hide show
  1. data/README +977 -0
  2. data/Rakefile +7 -0
  3. data/img/cursor.png +0 -0
  4. data/img/cursors.png +0 -0
  5. data/img/dice.png +0 -0
  6. data/img/wait_cursor.png +0 -0
  7. data/img/win_base.png +0 -0
  8. data/img/window.png +0 -0
  9. data/install_miyako.rb +75 -0
  10. data/lib/Miyako/API/audio.rb +198 -0
  11. data/lib/Miyako/API/basic_data.rb +431 -0
  12. data/lib/Miyako/API/bitmap.rb +35 -0
  13. data/lib/Miyako/API/choices.rb +308 -0
  14. data/lib/Miyako/API/collision.rb +444 -0
  15. data/lib/Miyako/API/diagram.rb +573 -0
  16. data/lib/Miyako/API/drawing.rb +110 -0
  17. data/lib/Miyako/API/fixedmap.rb +315 -0
  18. data/lib/Miyako/API/font.rb +384 -0
  19. data/lib/Miyako/API/input.rb +440 -0
  20. data/lib/Miyako/API/layout.rb +451 -0
  21. data/lib/Miyako/API/map.rb +403 -0
  22. data/lib/Miyako/API/map_event.rb +198 -0
  23. data/lib/Miyako/API/modules.rb +109 -0
  24. data/lib/Miyako/API/movie.rb +151 -0
  25. data/lib/Miyako/API/parts.rb +154 -0
  26. data/lib/Miyako/API/plane.rb +131 -0
  27. data/lib/Miyako/API/screen.rb +257 -0
  28. data/lib/Miyako/API/shape.rb +362 -0
  29. data/lib/Miyako/API/sprite.rb +338 -0
  30. data/lib/Miyako/API/sprite_animation.rb +461 -0
  31. data/lib/Miyako/API/spriteunit.rb +113 -0
  32. data/lib/Miyako/API/story.rb +224 -0
  33. data/lib/Miyako/API/textbox.rb +496 -0
  34. data/lib/Miyako/API/viewport.rb +435 -0
  35. data/lib/Miyako/API/yuki.rb +779 -0
  36. data/lib/Miyako/EXT/miyako_cairo.rb +60 -0
  37. data/lib/Miyako/EXT/raster_scroll.rb +138 -0
  38. data/lib/Miyako/EXT/slides.rb +136 -0
  39. data/lib/Miyako/miyako.rb +172 -0
  40. data/miyako.png +0 -0
  41. data/miyako_banner.png +0 -0
  42. data/miyako_no_katana/extconf.rb +34 -0
  43. data/miyako_no_katana/miyako_no_katana.c +3301 -0
  44. data/sample/Animation1/m1ku.rb +89 -0
  45. data/sample/Animation1/m1ku_arm_0.png +0 -0
  46. data/sample/Animation1/m1ku_arm_1.png +0 -0
  47. data/sample/Animation1/m1ku_arm_2.png +0 -0
  48. data/sample/Animation1/m1ku_arm_3.png +0 -0
  49. data/sample/Animation1/m1ku_back.jpg +0 -0
  50. data/sample/Animation1/m1ku_body.png +0 -0
  51. data/sample/Animation1/m1ku_eye_0.png +0 -0
  52. data/sample/Animation1/m1ku_eye_1.png +0 -0
  53. data/sample/Animation1/m1ku_eye_2.png +0 -0
  54. data/sample/Animation1/m1ku_eye_3.png +0 -0
  55. data/sample/Animation1/m1ku_hair_front.png +0 -0
  56. data/sample/Animation1/m1ku_hair_rear.png +0 -0
  57. data/sample/Animation1/readme.txt +72 -0
  58. data/sample/Animation2/lex.rb +95 -0
  59. data/sample/Animation2/lex_back.png +0 -0
  60. data/sample/Animation2/lex_body.png +0 -0
  61. data/sample/Animation2/lex_roadroller.png +0 -0
  62. data/sample/Animation2/lex_wheel_0.png +0 -0
  63. data/sample/Animation2/lex_wheel_1.png +0 -0
  64. data/sample/Animation2/lex_wheel_2.png +0 -0
  65. data/sample/Animation2/readme.txt +72 -0
  66. data/sample/Animation2/song_title.png +0 -0
  67. data/sample/Diagram_sample/back.png +0 -0
  68. data/sample/Diagram_sample/chr01.png +0 -0
  69. data/sample/Diagram_sample/chr02.png +0 -0
  70. data/sample/Diagram_sample/cursor.png +0 -0
  71. data/sample/Diagram_sample/diagram_sample_yuki2.rb +283 -0
  72. data/sample/Diagram_sample/readme.txt +87 -0
  73. data/sample/Diagram_sample/wait_cursor.png +0 -0
  74. data/sample/Room3/blue.rb +250 -0
  75. data/sample/Room3/ending.rb +175 -0
  76. data/sample/Room3/green.rb +185 -0
  77. data/sample/Room3/image/akamatsu.png +0 -0
  78. data/sample/Room3/image/aoyama.png +0 -0
  79. data/sample/Room3/image/congra.png +0 -0
  80. data/sample/Room3/image/congratulation.png +0 -0
  81. data/sample/Room3/image/congratulation_bg.png +0 -0
  82. data/sample/Room3/image/cursor.png +0 -0
  83. data/sample/Room3/image/midori.png +0 -0
  84. data/sample/Room3/image/mittsu_no_oheya.png +0 -0
  85. data/sample/Room3/image/mittsu_no_oheya_logo.png +0 -0
  86. data/sample/Room3/image/room_blue.png +0 -0
  87. data/sample/Room3/image/room_green.png +0 -0
  88. data/sample/Room3/image/room_red.png +0 -0
  89. data/sample/Room3/image/start.png +0 -0
  90. data/sample/Room3/image/three_doors.png +0 -0
  91. data/sample/Room3/image/wait_cursor.png +0 -0
  92. data/sample/Room3/main.rb +102 -0
  93. data/sample/Room3/main_component.rb +58 -0
  94. data/sample/Room3/readme.txt +76 -0
  95. data/sample/Room3/red.rb +200 -0
  96. data/sample/Room3/room3.rb +26 -0
  97. data/sample/Room3/title.rb +171 -0
  98. data/sample/fixed_map_test/cursor.png +0 -0
  99. data/sample/fixed_map_test/fixed_map_sample.rb +149 -0
  100. data/sample/fixed_map_test/map.csv +19 -0
  101. data/sample/fixed_map_test/map_01.png +0 -0
  102. data/sample/fixed_map_test/map_sample.rb +121 -0
  103. data/sample/fixed_map_test/mapchip.csv +23 -0
  104. data/sample/fixed_map_test/monster.png +0 -0
  105. data/sample/fixed_map_test/readme.txt +72 -0
  106. data/sample/map_test/chara.rb +50 -0
  107. data/sample/map_test/chr1.png +0 -0
  108. data/sample/map_test/cursor.png +0 -0
  109. data/sample/map_test/main_parts.rb +48 -0
  110. data/sample/map_test/main_scene.rb +137 -0
  111. data/sample/map_test/map.png +0 -0
  112. data/sample/map_test/map2.png +0 -0
  113. data/sample/map_test/map_layer.csv +127 -0
  114. data/sample/map_test/map_manager.rb +92 -0
  115. data/sample/map_test/map_test.rb +23 -0
  116. data/sample/map_test/mapchip.csv +21 -0
  117. data/sample/map_test/oasis.rb +65 -0
  118. data/sample/map_test/readme.txt +87 -0
  119. data/sample/map_test/route.rb +144 -0
  120. data/sample/map_test/sea.png +0 -0
  121. data/sample/map_test/town.rb +68 -0
  122. data/sample/map_test/wait_cursor.png +0 -0
  123. data/sample/map_test/window.png +0 -0
  124. data/win/miyako_no_katana.so +0 -0
  125. metadata +194 -0
@@ -0,0 +1,149 @@
1
+ #! /usr/bin/ruby
2
+ # FixedMap Sample
3
+ # 2008.11.29 C.Makoto
4
+
5
+ require 'Miyako/miyako'
6
+ #require 'Miyako/idaten_miyako'
7
+
8
+ include Miyako
9
+
10
+ # Monster Class
11
+ class Monster
12
+ extend Forwardable
13
+
14
+ def initialize(map, name, size, wait, pattern, x, y)
15
+ @spr = Sprite.new({:filename => name, :type => :color_key})
16
+ @spr.ow = size
17
+ @spr.oh = size
18
+ @coll= Collision.new(Rect.new(0, 0, @spr.ow, @spr.oh),
19
+ Point.new(@spr.x, @spr.y))
20
+ @coll.amount = Size.new(1, 1)
21
+ ap = { }
22
+ ap[:sprite] = @spr
23
+ ap[:wait] = wait
24
+ ap[:pattern_list] = pattern
25
+ # ap[:position_offset] = [0,2,4,6,8,10,12,14]
26
+ @anim = SpriteAnimation.new(ap)
27
+ @anim.snap(map)
28
+ @anim.left.top.move(x, y)
29
+ end
30
+
31
+ def start
32
+ @anim.start
33
+ end
34
+
35
+ def update(map, events, param)
36
+ @anim.update_animation
37
+ end
38
+
39
+ def render
40
+ @anim.render
41
+ end
42
+
43
+ def finish
44
+ end
45
+
46
+ def dispose
47
+ @anim.dispose
48
+ @spr.dispose
49
+ end
50
+
51
+ def_delegators(:@anim, :start, :stop)
52
+ end
53
+
54
+ class Slime < Monster
55
+ def initialize(map, x, y)
56
+ super(map, "monster.png", 32, 0.5, [0, 1, 2, 3, 2, 1], x, y)
57
+ @pos = Point.new(x, y)
58
+ @interval = 2
59
+ @interval_x = 0
60
+ @interval_y = 0
61
+ @cnt = 0
62
+ @wait0 = WaitCounter.new(0.1)
63
+ @wait = WaitCounter.new(0.4)
64
+ @types = 5
65
+ @ary = [[ 0, 1, 0, @interval, @spr.oh],
66
+ [ 1, 0, @interval, 0, @spr.ow],
67
+ [-1, 0,-@interval, 0, @spr.ow],
68
+ [ 0,-1, 0,-@interval, @spr.oh]]
69
+ end
70
+
71
+ def update(map, events, param)
72
+ super
73
+ return if @wait.waiting? || @wait0.waiting?
74
+ if @cnt > 0
75
+ @anim.move(@interval_x, @interval_y)
76
+ @coll.move(@interval_x, @interval_y)
77
+ @cnt -= @interval
78
+ @wait0.start
79
+ return
80
+ end
81
+ val = rand(@types)
82
+ if val == 0
83
+ @interval_x = 0
84
+ @interval_y = 0
85
+ @wait.start
86
+ else
87
+ data = @ary[val-1]
88
+ @coll.direction = data[0..1]
89
+
90
+ ret = map.get_amount_by_rect(0, @spr.rect, @coll)
91
+
92
+ if (ret.amount[0] | ret.amount[1]) != 0
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
+
129
+ #@a = Sprite.new({:file=>"cursor.png", :type=>:ac })
130
+ #@a.oh = @a.w
131
+ #@a = SpriteAnimation.new({:sprite=>@a, :wait=>0.1, :pattern_list=>[0,1,2,3,2,1] })
132
+ #@a.start
133
+
134
+ mp = MapChipFactory.load("./mapchip.csv")
135
+ @fmap = FixedMap.new(mp, "./map.csv", em)
136
+ #@fmap.set_mapchip_base(0, 4, @a)
137
+ #@fmap.map_layers[0].mapchip_units[4] = @a
138
+
139
+ Miyako.main_loop do
140
+ break if Input.quit_or_escape?
141
+ # @a.update_animation
142
+ dx, dy = Input.trigger_amount.map{|v| v * 4 }
143
+ dx = 0 unless Screen.viewport.in_bounds_x?(@fmap.rect, dx)
144
+ dy = 0 unless Screen.viewport.in_bounds_y?(@fmap.rect, dy)
145
+ @fmap.move(dx, dy)
146
+ @fmap.events.each{|e| e.update(@fmap, @fmap.events, nil)}
147
+ @fmap.render
148
+ @fmap.events.each{|e| e.render}
149
+ 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,121 @@
1
+ #! /usr/bin/ruby
2
+ # FixedMap Sample
3
+ # 2007.12.30 C.Makoto
4
+
5
+ require 'Miyako/miyako'
6
+ require 'Miyako/idaten_miyako'
7
+
8
+ include Miyako
9
+ # Monster Class
10
+ class Monster
11
+ extend Forwardable
12
+
13
+ def initialize(name, size, wait, pattern, x, y)
14
+ @spr = Sprite.new({:filename => name, :type => :color_key})
15
+ @spr.ow = size
16
+ @spr.oh = size
17
+ @spr.move(x, y)
18
+ aparam = Hash.new
19
+ aparam[:sprite] = @spr
20
+ aparam[:wait] = wait
21
+ aparam[:pattern_list] = pattern
22
+ aparam[:position_offset] = [0,2,4,6,8,10,12,14]
23
+ @anim = SpriteAnimation.new(aparam)
24
+ @anim.start
25
+ end
26
+
27
+ def update(map, events, param)
28
+ end
29
+
30
+ def finish
31
+ @spr.dispose
32
+ end
33
+
34
+ def_delegators(:@anim, :start, :stop)
35
+ end
36
+
37
+ class Slime < Monster
38
+ def initialize(x, y)
39
+ super("monster.png", 32, 0.5, [0, 1, 2, 3, 2, 1], x, y)
40
+ @interval = 2
41
+ @interval_x = 0
42
+ @interval_y = 0
43
+ @amount = @spr.oh
44
+ @cnt = 0
45
+ @wait0 = WaitCounter.new(0.1)
46
+ @wait = WaitCounter.new(0.4)
47
+ end
48
+
49
+ def update(map, events, param)
50
+ @anim.update_animation
51
+ return if @wait.waiting? || @wait0.waiting?
52
+ if @cnt > 0
53
+ @spr.move(@interval_x, @interval_y)
54
+ @cnt -= @interval
55
+ @wait0.start
56
+ return
57
+ end
58
+ case rand(5)
59
+ when 0
60
+ @interval_x = 0
61
+ @interval_y = 0
62
+ @wait.start
63
+ when 1
64
+ code = map.getCodeReal(0, @spr.x, @spr.y+@spr.oh)
65
+ if code == -1
66
+ @interval_x = 0
67
+ @interval_y = @interval
68
+ @cnt = @amount
69
+ end
70
+ when 2
71
+ code = map.getCodeReal(0, @spr.x+@spr.ow, @spr.y)
72
+ if code == -1
73
+ @interval_x = @interval
74
+ @interval_y = 0
75
+ @cnt = @amount
76
+ end
77
+ when 3
78
+ code = map.getCodeReal(0, @spr.x-@spr.ow, @spr.y)
79
+ if code == -1
80
+ @interval_x = -@interval
81
+ @interval_y = 0
82
+ @cnt = @amount
83
+ end
84
+ when 4
85
+ code = map.getCodeReal(0, @spr.x, @spr.y-@spr.oh)
86
+ if code == -1
87
+ @interval_x = 0
88
+ @interval_y = -@interval
89
+ @cnt = @amount
90
+ end
91
+ end
92
+ end
93
+ end
94
+
95
+ class SlimeEvent
96
+ include MapEvent
97
+
98
+ def init
99
+ @slime = Slime.new(@event_pos.x, @event_pos.y)
100
+ end
101
+
102
+ def update(map, events, param)
103
+ @slime.update(map, events, param)
104
+ end
105
+
106
+ def final
107
+ @slime.finish
108
+ end
109
+ end
110
+
111
+ MapEvent.add(1, SlimeEvent)
112
+
113
+ # main
114
+
115
+ mp = MapChipFactory.load("./mapchip.csv")
116
+ @fmap = FixedMap.new(mp, "./map.csv")
117
+ @fmap.show
118
+
119
+ Miyako.main_loop do
120
+ break if Input.quit_or_escape?
121
+ end
@@ -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
+ �y ��Җ� �z�@�T�C���X��
3
+ �y �\�t�g�� �z�@Miyako v1.4.4�T���v��(�Œ�}�b�v)
4
+ �y �o�[�W���� �z�@1.0
5
+ �y �쐬�� �z�@2008/01/14
6
+ �y ��� �z�@�t���[�E�F�A
7
+ �y �J������ �z�@Ruby 1.8.6-p111
8
+ �y �����^�C�� �z�@Miyako v1.4.4
9
+ �y �Ή��@�� �z�@Windows 2000/XP/Vista�ALinux
10
+ �y �Ĕz�z �z�@�C��BSD���C�Z���X�ɂ��
11
+ �y �]�� �z�@�C��BSD���C�Z���X�ɂ��
12
+ �y�z�[���y�[�W�z�@http://www.twin.ne.jp/~cyross/Miyako/
13
+ �y �A���� �z�@cyross@po.twin.ne.jp
14
+ *******************************************************************************
15
+
16
+ �E�T�v
17
+
18
+ �@���̃v���O�����́AMiyako v1.4.4�ȍ~�ɑΉ�����AMiyako�T���v���v���O�����ł��B
19
+ �@�X�N���[�����Ȃ��}�b�v��ŁA�X���C�������˂��˂��Ȃ��瓮������Ă��܂��B
20
+
21
+ �EMiyako�ɂ‚���
22
+
23
+ �@Miyako�Ɋւ��ẮA�ȉ���URL���Q�l�ɂ��Ă��������B
24
+ http://www.twin.ne.jp/~cyross/Miyako/
25
+
26
+ �@Miyako(Ruby�ARuby/SDL�܂�)�̃C���X�g�[���Ɋւ��܂��ẮA
27
+ ��LURL��H���ē�����A�[�J�C�u���ꂽMiyako���C�u������
28
+ �W�J����ƁAreadme.txt�������܂��̂ŁA����������Q�Ɖ������B
29
+
30
+ �@�{�T���v���ł́AMiyako��Windows��œ��삷�邱�Ƃ�O��ɂ��Ă��܂��B
31
+ �i�C���X�g�[������Ruby���s�‹���ActiveRuby�ł��邱�Ƃ��O���
32
+ �@���Ă��܂��j
33
+
34
+ �E�N�����@
35
+
36
+ �@�G�N�X�v���[���[���J���A�{�T���v���̃t�H���_���ŁA�um1ku.rb�v��
37
+ �_�u���N���b�N���܂��B
38
+ �@�������́A�R�}���h���C����œ������ꍇ�́A�{�T���v���̃f�B���N�g����
39
+ �ړ����āA�ȉ��̃R�}���h����͂��܂��B
40
+
41
+ �@ruby fixed_map_sample.rb
42
+
43
+ �E�Ɛӎ���
44
+
45
+ �@�{�T���v���͖��ۏ؂ł��B�����{�T���v�����g�p���邱�Ƃɂ��s��E�g���u��
46
+ ���N�������Ƃ��Ă��A�����Ȃ�g���u���ɑ΂���ӔC�𕉂�Ȃ����Ƃ��������������B
47
+
48
+ �@�{�T���v���́A�C��BSD���C�Z���X�Ɋ�Â����]�ځE�Ĕz�z�����‚��܂��B
49
+
50
+ �EBSD���C�Z���X��
51
+
52
+ Copyright (c) 2008, 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
+ �ERedistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
59
+ �ERedistributions 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
+ �ENeither 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,50 @@
1
+ #キャラクタ管理クラス
2
+ class PChara # Player Character
3
+ extend Forwardable
4
+ attr_accessor :dir
5
+ @@amt2dir = {[0,1]=>0,[-1,0]=>1,[1,0]=>2,[0,-1]=>3}
6
+ @@amt2dir.default = -1
7
+
8
+ def initialize(fname, size, pw = 0.2)
9
+ @size = size
10
+ # キャラクタスプライトを作成
11
+ # コリジョンはスプライトのものを共有して使用
12
+ @spr = Sprite.new({:filename => fname, :type => :color_key})
13
+ raise MiyakoError, "Character Size is not aligned by Map Chip Size!" unless (@spr.w % @size[0] == 0 && @spr.h % @size[1] == 0)
14
+ @spr.ow = @size[0]
15
+ @spr.oh = @size[1]
16
+ param = Hash.new
17
+ param[:sprite] = @spr
18
+ param[:wait] = pw
19
+ # キャラパターンを表示
20
+ @anim = SpriteAnimation.new(param)
21
+ @anim.centering
22
+ end
23
+
24
+ # マップの表示座標と実座標とのマージンを設定
25
+ def margin
26
+ return Size.new(-@spr.x, -@spr.y)
27
+ end
28
+
29
+ def turn(d)
30
+ @anim.character(@@amt2dir[d])
31
+ end
32
+
33
+ def start
34
+ @anim.start
35
+ end
36
+
37
+ def stop
38
+ @anim.stop
39
+ end
40
+
41
+ def update
42
+ @anim.update_animation
43
+ end
44
+
45
+ def render
46
+ @anim.render
47
+ end
48
+
49
+ def_delegators(:@spr, :dispose, :rect, :ow, :oh, :x, :y)
50
+ end
Binary file
Binary file
@@ -0,0 +1,48 @@
1
+ #共通パーツクラス
2
+ class CommonParts
3
+ include Singleton
4
+
5
+ attr_reader :box, :cbox
6
+ attr_accessor :executing
7
+
8
+ def initialize
9
+ # create window
10
+ font = Font.sans_serif
11
+ font.size = 24
12
+
13
+ cfont = Font.sans_serif
14
+ cfont.size = 16
15
+
16
+ wc = Sprite.new({:file => "wait_cursor.png", :type => :ac})
17
+ wc.oh = wc.w
18
+
19
+ wc = SpriteAnimation.new({:sprite => wc, :wait => 0.2, :pattern_list => [0, 1, 2, 3, 2, 1]})
20
+ sc = Sprite.new({:file => "cursor.png", :type => :ac})
21
+ sc.oh = sc.w
22
+
23
+ sc = SpriteAnimation.new({:sprite => sc, :wait => 0.2, :pattern_list => [0, 1, 2, 3, 2, 1]})
24
+
25
+ tb = TextBox.new({:size => [20, 4], :font => font, :wait_cursor => wc, :select_cursor => sc})
26
+ tb.pause_type = :out
27
+
28
+ cb = TextBox.new({:size => [8, 8], :font => cfont, :wait_cursor => wc, :select_cursor => sc})
29
+
30
+ bg = Sprite.new({:size=>tb.size, :type=>:ac})
31
+ bg.fill([0,0,255,64])
32
+
33
+ cbg = Sprite.new({:size=>cb.size, :type=>:ac})
34
+ cbg.fill([0,255,0,64])
35
+
36
+ @box = Parts.new(bg.size)
37
+ @box[:bg] = bg
38
+ @box[:box] = tb
39
+ @box.center.bottom{|body| wc.oh }
40
+
41
+ @cbox = Parts.new(cbg.size)
42
+ @cbox[:bg] = cbg
43
+ @cbox[:box] = cb
44
+ @cbox.right{|body| 2.percent(body) }.top{|body| 2.percent(body) }
45
+
46
+ @executing = false
47
+ end
48
+ end
@@ -0,0 +1,137 @@
1
+ class MainScene
2
+ include Story::Scene
3
+
4
+ def init
5
+ @cnt = 0
6
+ @amt = 4
7
+ @a = [0,0]
8
+ @d = [0,1]
9
+
10
+ @map = MapManager.new
11
+ @size = @map.size
12
+ @map.collision.amount = Size.new(@amt, @amt)
13
+ @executing_flags = Array.new(@map.events.length){|n| false}
14
+
15
+ # キャラクタの初期位置を指定([10,10]に位置)
16
+ @chr = PChara.new("./chr1.png", @size)
17
+
18
+ # マップの表示開始位置を移動させる
19
+ # キャラクタのグラフィックを真ん中に表示させるため
20
+ @map.margin.resize(*@chr.margin)
21
+ @map.sync_margin
22
+ # マップの実座標を設定する
23
+ @map.move(@size[0] * 10, @size[1] * 10)
24
+
25
+ @parts = CommonParts.instance
26
+ #Yukiの初期化
27
+ @yuki = Yuki.new
28
+ @yuki.select_textbox(@parts.box[:box])
29
+ @yuki.select_commandbox(@parts.cbox[:box])
30
+ end
31
+
32
+ def setup
33
+ @map.start
34
+ @chr.start
35
+ end
36
+
37
+ def update
38
+ return nil if Input.quit_or_escape?
39
+
40
+ @map.update
41
+ @chr.update
42
+
43
+ # 移動量が残っているときは移動を優先
44
+ if @cnt > 0
45
+ # 移動後のマップの実座標を計算
46
+ @map.move(*@a)
47
+ @cnt = @cnt - @amt
48
+ elsif @yuki.executing?
49
+ @yuki.update
50
+ elsif @executing_flags.none?
51
+ if Input.pushed_any?(:btn1)
52
+ #1ボタンを押したとき、イベントに重なっていればマップイベントを実行、
53
+ #外れていれば、コマンドウィンドウを開く
54
+ event_flags = @map.events.map{|e| e.met?(:collision => @map.collision)}
55
+ if event_flags.none?
56
+ @yuki.start_plot(@yuki.to_plot(self, :command_plot))
57
+ else
58
+ @map.events.zip(event_flags){|ef| ef[0].start(@parts) if ef[1]}
59
+ end
60
+ elsif Input::trigger_any?(:down, :up, :left, :right)
61
+ # 0:down 1:left 2:right 3:up
62
+ @d = Input::trigger_amount
63
+ @d[1] = 0 if @d[0] != 0 && @d[1] != 0 # 移動を横方向優先に
64
+ # コリジョンの移動量を設定
65
+ @map.collision.direction = @d
66
+ #キャラクタの向きを変更
67
+ @chr.turn(@d)
68
+ #マップの移動量を求める
69
+ @a = @map.get_amount(0, @map.size, @map.collision).amount.to_a
70
+ # 方向ボタンを押したときは、1チップサイズ単位で移動する
71
+ # @cntはその移動量(幅と高さでサイズが違う場合アリ)
72
+ @cnt = @a[0] > 0 ? @size[0] : @size[1]
73
+ end
74
+ else
75
+ end
76
+
77
+ @map.events.zip(@executing_flags){|ef|
78
+ if ef[1]
79
+ if Input.pushed_any?(:btn2)
80
+ ef[0].stop
81
+ else
82
+ ef[0].update(nil, nil, nil)
83
+ end
84
+ end
85
+ }
86
+ @executing_flags = @map.events.map{|e| e.executing? }
87
+
88
+ #コマンド選択の結果、イベントが実行されたときは、結果として@nowを返す
89
+ return @now unless @yuki.is_scene?(@yuki.result)
90
+ return @yuki.result || @now
91
+ end
92
+
93
+ def render
94
+ @map.render
95
+ @map.render_event
96
+ @chr.render
97
+ @map.render_event_box
98
+ if @yuki.executing?
99
+ @parts.box.render
100
+ @parts.cbox.render if @yuki.selecting?
101
+ end
102
+ end
103
+
104
+ def command_plot(yuki)
105
+ yuki.command([Yuki::Command.new("話す", "話す", nil, yuki.to_plot(self, :talk)),
106
+ Yuki::Command.new("調べる", "調べる", nil, yuki.to_plot(self, :check))], @now)
107
+ yuki.select_result.call(yuki) if yuki.is_scenario?(yuki.select_result)
108
+ return @now
109
+ end
110
+ #コマンドウィンドウの「調べる」を選んだときの処理
111
+ def check(yuki)
112
+ yuki.text "あなたは、足下を調べた。\n"
113
+ yuki.pause
114
+ yuki.text "しかし、何も無かった。"
115
+ yuki.pause
116
+ yuki.clear
117
+ end
118
+
119
+ #コマンドウィンドウの「話す」を選んだときの処理
120
+ def talk(yuki)
121
+ yuki.text "話をしようとしたが"
122
+ yuki.cr
123
+ yuki.text "あなたの周りには誰もいない。"
124
+ yuki.pause
125
+ yuki.clear
126
+ end
127
+
128
+ def final
129
+ @map.stop
130
+ @chr.stop
131
+ end
132
+
133
+ def dispose
134
+ @map.dispose
135
+ @chr.dispose
136
+ end
137
+ end
Binary file
Binary file