ruby-miyako-mswin32 2.1.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 (148) hide show
  1. data/README +1115 -0
  2. data/img/cursor.png +0 -0
  3. data/img/cursors.png +0 -0
  4. data/img/dice.png +0 -0
  5. data/img/wait_cursor.png +0 -0
  6. data/img/win_base.png +0 -0
  7. data/img/window.png +0 -0
  8. data/install_miyako.rb +87 -0
  9. data/lib/Miyako/API/audio.rb +584 -0
  10. data/lib/Miyako/API/basic_data.rb +1026 -0
  11. data/lib/Miyako/API/bitmap.rb +534 -0
  12. data/lib/Miyako/API/choices.rb +481 -0
  13. data/lib/Miyako/API/collision.rb +638 -0
  14. data/lib/Miyako/API/diagram.rb +586 -0
  15. data/lib/Miyako/API/drawing.rb +151 -0
  16. data/lib/Miyako/API/exceptions.rb +105 -0
  17. data/lib/Miyako/API/fixedmap.rb +462 -0
  18. data/lib/Miyako/API/font.rb +430 -0
  19. data/lib/Miyako/API/input.rb +456 -0
  20. data/lib/Miyako/API/layout.rb +644 -0
  21. data/lib/Miyako/API/map.rb +583 -0
  22. data/lib/Miyako/API/map_event.rb +222 -0
  23. data/lib/Miyako/API/modules.rb +357 -0
  24. data/lib/Miyako/API/movie.rb +166 -0
  25. data/lib/Miyako/API/parts.rb +188 -0
  26. data/lib/Miyako/API/plane.rb +205 -0
  27. data/lib/Miyako/API/screen.rb +341 -0
  28. data/lib/Miyako/API/shape.rb +443 -0
  29. data/lib/Miyako/API/sprite.rb +773 -0
  30. data/lib/Miyako/API/sprite_animation.rb +494 -0
  31. data/lib/Miyako/API/sprite_list.rb +1135 -0
  32. data/lib/Miyako/API/spriteunit.rb +168 -0
  33. data/lib/Miyako/API/story.rb +350 -0
  34. data/lib/Miyako/API/textbox.rb +773 -0
  35. data/lib/Miyako/API/utility.rb +419 -0
  36. data/lib/Miyako/API/viewport.rb +190 -0
  37. data/lib/Miyako/API/yuki.rb +1180 -0
  38. data/lib/Miyako/EXT/miyako_cairo.rb +62 -0
  39. data/lib/Miyako/EXT/raster_scroll.rb +138 -0
  40. data/lib/Miyako/EXT/slides.rb +157 -0
  41. data/lib/Miyako/miyako.rb +201 -0
  42. data/lib/Miyako/miyako_no_katana.so +0 -0
  43. data/lib/Miyako/miyako_require_only.rb +35 -0
  44. data/logo/EGSR_logo.png +0 -0
  45. data/logo/EGSR_logo_bg.png +0 -0
  46. data/logo/EGSR_logo_fg.png +0 -0
  47. data/logo/EGSR_title_banner.png +0 -0
  48. data/logo/EGSR_title_logo.png +0 -0
  49. data/logo/miyako.png +0 -0
  50. data/logo/miyako_banner.png +0 -0
  51. data/logo/space.png +0 -0
  52. data/sample/Animation1/m1ku.rb +68 -0
  53. data/sample/Animation1/m1ku_arm_0.png +0 -0
  54. data/sample/Animation1/m1ku_arm_1.png +0 -0
  55. data/sample/Animation1/m1ku_arm_2.png +0 -0
  56. data/sample/Animation1/m1ku_arm_3.png +0 -0
  57. data/sample/Animation1/m1ku_back.jpg +0 -0
  58. data/sample/Animation1/m1ku_body.png +0 -0
  59. data/sample/Animation1/m1ku_eye_0.png +0 -0
  60. data/sample/Animation1/m1ku_eye_1.png +0 -0
  61. data/sample/Animation1/m1ku_eye_2.png +0 -0
  62. data/sample/Animation1/m1ku_eye_3.png +0 -0
  63. data/sample/Animation1/m1ku_hair_front.png +0 -0
  64. data/sample/Animation1/m1ku_hair_rear.png +0 -0
  65. data/sample/Animation1/readme.txt +72 -0
  66. data/sample/Animation2/lex.rb +96 -0
  67. data/sample/Animation2/lex_back.png +0 -0
  68. data/sample/Animation2/lex_body.png +0 -0
  69. data/sample/Animation2/lex_roadroller.png +0 -0
  70. data/sample/Animation2/lex_wheel_0.png +0 -0
  71. data/sample/Animation2/lex_wheel_1.png +0 -0
  72. data/sample/Animation2/lex_wheel_2.png +0 -0
  73. data/sample/Animation2/readme.txt +72 -0
  74. data/sample/Animation2/song_title.png +0 -0
  75. data/sample/Diagram_sample/back.png +0 -0
  76. data/sample/Diagram_sample/chr01.png +0 -0
  77. data/sample/Diagram_sample/chr02.png +0 -0
  78. data/sample/Diagram_sample/cursor.png +0 -0
  79. data/sample/Diagram_sample/diagram_sample_yuki2.rb +329 -0
  80. data/sample/Diagram_sample/readme.txt +90 -0
  81. data/sample/Diagram_sample/wait_cursor.png +0 -0
  82. data/sample/Room3/blue.rb +297 -0
  83. data/sample/Room3/ending.rb +180 -0
  84. data/sample/Room3/green.rb +220 -0
  85. data/sample/Room3/image/akamatsu.png +0 -0
  86. data/sample/Room3/image/aoyama.png +0 -0
  87. data/sample/Room3/image/congra.png +0 -0
  88. data/sample/Room3/image/congratulation.png +0 -0
  89. data/sample/Room3/image/congratulation_bg.png +0 -0
  90. data/sample/Room3/image/cursor.png +0 -0
  91. data/sample/Room3/image/midori.png +0 -0
  92. data/sample/Room3/image/mittsu_no_oheya.png +0 -0
  93. data/sample/Room3/image/mittsu_no_oheya_logo.png +0 -0
  94. data/sample/Room3/image/room_blue.png +0 -0
  95. data/sample/Room3/image/room_green.png +0 -0
  96. data/sample/Room3/image/room_red.png +0 -0
  97. data/sample/Room3/image/start.png +0 -0
  98. data/sample/Room3/image/three_doors.png +0 -0
  99. data/sample/Room3/image/wait_cursor.png +0 -0
  100. data/sample/Room3/main.rb +120 -0
  101. data/sample/Room3/main_component.rb +59 -0
  102. data/sample/Room3/readme.txt +76 -0
  103. data/sample/Room3/red.rb +227 -0
  104. data/sample/Room3/room3.rb +25 -0
  105. data/sample/Room3/title.rb +184 -0
  106. data/sample/ball_action_sample.rb +204 -0
  107. data/sample/blit_rop.rb +70 -0
  108. data/sample/cairo_sample.rb +25 -0
  109. data/sample/circle_collision_test.rb +66 -0
  110. data/sample/collision_test.rb +33 -0
  111. data/sample/collision_test2.rb +108 -0
  112. data/sample/fixed_map_test/cursor.png +0 -0
  113. data/sample/fixed_map_test/fixed_map_sample.rb +140 -0
  114. data/sample/fixed_map_test/map.csv +19 -0
  115. data/sample/fixed_map_test/map_01.png +0 -0
  116. data/sample/fixed_map_test/mapchip.csv +23 -0
  117. data/sample/fixed_map_test/monster.png +0 -0
  118. data/sample/fixed_map_test/readme.txt +72 -0
  119. data/sample/map_test/chara.rb +58 -0
  120. data/sample/map_test/chr1.png +0 -0
  121. data/sample/map_test/cursor.png +0 -0
  122. data/sample/map_test/main_parts.rb +69 -0
  123. data/sample/map_test/main_scene.rb +153 -0
  124. data/sample/map_test/map.png +0 -0
  125. data/sample/map_test/map2.png +0 -0
  126. data/sample/map_test/map_layer.csv +127 -0
  127. data/sample/map_test/map_manager.rb +75 -0
  128. data/sample/map_test/map_test.rb +23 -0
  129. data/sample/map_test/mapchip.csv +21 -0
  130. data/sample/map_test/oasis.rb +71 -0
  131. data/sample/map_test/readme.txt +89 -0
  132. data/sample/map_test/route.rb +157 -0
  133. data/sample/map_test/sea.png +0 -0
  134. data/sample/map_test/town.rb +74 -0
  135. data/sample/map_test/wait_cursor.png +0 -0
  136. data/sample/map_test/window.png +0 -0
  137. data/sample/polygon_test.rb +35 -0
  138. data/sample/rasterscroll.rb +25 -0
  139. data/sample/takahashi.rb +42 -0
  140. data/sample/text.png +0 -0
  141. data/sample/textbox_sample.rb +190 -0
  142. data/sample/transform.rb +54 -0
  143. data/sample/utility_test.rb +73 -0
  144. data/sample/utility_test2.rb +61 -0
  145. data/sample/utility_test3.rb +64 -0
  146. data/sample/utility_test4.rb +73 -0
  147. data/uninstall_miyako.rb +19 -0
  148. metadata +199 -0
@@ -0,0 +1,62 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # Miyako Extension Cairo-Miyako interface
3
+ =begin
4
+ Miyako Extention Library v2.1
5
+ Copyright (C) 2007-2009 Cyross Makoto
6
+
7
+ This library is free software; you can redistribute it and/or
8
+ modify it under the terms of the GNU Lesser General Public
9
+ License as published by the Free Software Foundation; either
10
+ version 2.1 of the License, or (at your option) any later version.
11
+
12
+ This library is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ Lesser General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Lesser General Public
18
+ License along with this library; if not, write to the Free Software
19
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ =end
21
+
22
+ begin
23
+ loaded = false
24
+ require 'cairo'
25
+ rescue LoadError
26
+ begin
27
+ require 'rubygems'
28
+ require 'cairo'
29
+ loaded = true
30
+ rescue LoadError
31
+ raise Miyako::MiyakoError, "Sorry, Cairo-Miyako Interface has rcairo." unless loaded
32
+ end
33
+ end
34
+
35
+ module Miyako
36
+ #==MiyakoのSpriteクラスのインスタンスとCairoのImageSurfaceクラスのインスタンスとの相互変換モジュール
37
+ #要rcairo1.8以降
38
+ module MiyakoCairo
39
+ #===SpriteインスタンスをCairoのImageSurfaceに変換
40
+ #変換したCairo::ImageSurfaceインスタンスは、32ビット(Cairo::Format::ARGB32)の画像を持つ
41
+ #_sprite_:: 変換元Spriteインスタンス
42
+ #返却値:: 変換したCairo::ImageSurfaceインスタンス
43
+ def MiyakoCairo.to_cairo_surface(sprite)
44
+ return Cairo::ImageSurface.new(sprite.bitmap.pixels, Cairo::Format::ARGB32, sprite.w, sprite.h, sprite.w * 4)
45
+ end
46
+
47
+ #===CairoのImageSurfaceをSpriteインスタンスに変換
48
+ #変換したSpriteインスタンスは、:acタイプ(但し元画像がCairo::Format::RGB24の時は:asタイプ)の画像を持つ
49
+ #_surface_:: 変換元Cairo::ImageSurfaceインスタンス
50
+ #返却値:: 変換したSpriteインスタンス
51
+ def MiyakoCairo.to_sprite(surface)
52
+ # エンディアン判別
53
+ if [1].pack("V*") == [1].pack("L*") # リトルエンディアン?
54
+ bitmap = SDL::Surface.new_from(surface.data, surface.width, surface.height, 32, surface.stride, 0xff0000, 0xff00, 0xff, 0xff000000)
55
+ else # ビッグエンディアン
56
+ bitmap = SDL::Surface.new_from(surface.data, surface.width, surface.height, 32, surface.stride, 0xff00, 0xff0000, 0xff000000, 0xff)
57
+ end
58
+ return Sprite.new(:bitmap => bitmap, :type => :as) if surface.format == Cairo::Format::RGB24
59
+ return Sprite.new(:bitmap => bitmap, :type => :ac)
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,138 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # Miyako Extension Raster Scroll
3
+ =begin
4
+ Miyako Extention Library v2.1
5
+ Copyright (C) 2007-2009 Cyross Makoto
6
+
7
+ This library is free software; you can redistribute it and/or
8
+ modify it under the terms of the GNU Lesser General Public
9
+ License as published by the Free Software Foundation; either
10
+ version 2.1 of the License, or (at your option) any later version.
11
+
12
+ This library is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ Lesser General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Lesser General Public
18
+ License along with this library; if not, write to the Free Software
19
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ =end
21
+
22
+ module Miyako
23
+ #==ラスタスクロール実行クラス
24
+ #波の様に揺れる(疑似)ラスタスクロールを行うクラス
25
+ #波はサイン波で構成される
26
+ class RasterScroll
27
+ #===インスタンスを作成する
28
+ #ラスタスクロール対象のスプライトを登録する
29
+ #_sspr_:: ラスタスクロール対象スプライト
30
+ #返却値:: 作成したインスタンス
31
+ def initialize(sspr)
32
+ @src = sspr
33
+ @lines = 0
34
+ @h = @src.h
35
+ @size = 0
36
+ @sangle = 0
37
+ @dangle = 0
38
+ @fade_out = false
39
+ @fo_size = 0
40
+ @effecting = false
41
+ end
42
+
43
+ #===ラスタスクロールを開始する
44
+ #ラスタスクロール実行用に設定する引数は以下の通り
45
+ #:lines -> ライン数(:lines=>3を指定すると、3ラインずつラスタスクロールを行う)。デフォルトは1(ライン)
46
+ #:size -> 最大振幅数(:size=>20を指定すると、最大20ピクセルの高さの波となる)。デフォルトは4(ピクセル)
47
+ #:start_angle -> 開始角度(一番上のラインでの振幅角度(ラジアンではなく角度なのに注意!))。デフォルトは0(度)
48
+ #:distance -> 角度の変化量(ラインごとの角度の変化量。:distance=>1のときは、1度ずつ変化させる)。デフォルトは1(度)
49
+ #:wait -> 変化させる間隔(WaitCounterクラスのインスタンス)。デフォルトは0.1秒間隔
50
+ #_params_:: ラスタスクロール情報引数
51
+ #返却値:: 自分自身を返す
52
+ def start(params)
53
+ @lines = params[:lines] || 1
54
+ @size = params[:size] || 4
55
+ @sangle = params[:start_angle] || 0
56
+ @dangle = params[:distance] || 1
57
+ @wait = params[:wait] || WaitCounter.new(0.1)
58
+ @h = @h / @lines
59
+ @fade_out = false
60
+ @fo_size = 0
61
+ @effecting = true
62
+ @wait.start
63
+ return self
64
+ end
65
+
66
+ #===ラスタスクロール処理を更新する
67
+ #返却値:: 自分自身を返す
68
+ def update
69
+ return self unless @effecting
70
+ if @wait.finish?
71
+ @sangle = (@sangle + @dangle) % 360
72
+ @wait.start
73
+ if @fade_out
74
+ return self unless @fo_wait.finish?
75
+ @size = @size - @fo_size
76
+ @fo_wait.start
77
+ if @size <= 0
78
+ @effecting = false
79
+ @fade_out = false
80
+ end
81
+ end
82
+ end
83
+ return self
84
+ end
85
+
86
+ #===ラスタスクロールの実行状態を問い合わせる
87
+ #返却値:: ラスタスクロール中の時はtrueを返す
88
+ def effecting?
89
+ return @effecting
90
+ end
91
+
92
+ #===ラスタスクロールの実行状態を問い合わせる
93
+ #返却値:: ラスタスクロール中の時はtrueを返す
94
+ def fade_out?
95
+ return @fade_out
96
+ end
97
+
98
+ #===ラスタスクロールを停止する
99
+ def stop
100
+ @wait.stop
101
+ @fo_size.stop if @fo_size
102
+ @effecting = false
103
+ @fade_out = false
104
+ end
105
+
106
+ #===ラスタスクロールを画面に描画する
107
+ def render
108
+ angle = @sangle
109
+ @h.times{|y|
110
+ rsx = @size * Math.sin(angle)
111
+ @src.render{|src, dst| src.x += rsx; src.y += y * @lines; src.oy += y * @lines; src.oh = @lines }
112
+ angle = angle + @dangle
113
+ }
114
+ end
115
+
116
+ #===ラスタスクロールを画像に描画する
117
+ #_dst_:: 描画先画像
118
+ def render_to(dst)
119
+ @angle = @sangle
120
+ @h.times{|y|
121
+ rsx = @size * Math.sin(@angle)
122
+ @src.render_to(dst){|src, dst| src.x += rsx; src.y += y * @lines; src.oy += y * @lines; src.oh = @lines }
123
+ @angle = @angle + @dangle
124
+ }
125
+ end
126
+
127
+ #===ラスタスクロールをフェードアウトさせる
128
+ #引数fwに与えられた間隔で振幅が減っていき(減る量は引数fsで与えられた値)、振幅がゼロになると終了する
129
+ #_fs_:: フェードアウトの変化量
130
+ #_fw_:: フェードアウトの変化を待つカウント(WaitCounterクラスインスタンス)
131
+ def fade_out(fs, fw)
132
+ @fo_size = fs
133
+ @fo_wait = fw
134
+ @fo_wait.start
135
+ @fade_out = true
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,157 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # Miyako Extension
3
+ =begin
4
+ Miyako Extention Library v2.1
5
+ Copyright (C) 2007-2009 Cyross Makoto
6
+
7
+ This library is free software; you can redistribute it and/or
8
+ modify it under the terms of the GNU Lesser General Public
9
+ License as published by the Free Software Foundation; either
10
+ version 2.1 of the License, or (at your option) any later version.
11
+
12
+ This library is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ Lesser General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Lesser General Public
18
+ License along with this library; if not, write to the Free Software
19
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ =end
21
+
22
+ module Miyako
23
+ #==スライドを構成するモジュール
24
+ #Mixinして使用する
25
+ #使用するには、initializeメソッドの定義内で、init_slideメソッドを呼び出す必要がある
26
+ #ただし、インスタンス変数として、@bodyを予約済み
27
+ module Slide
28
+ include Layout
29
+ extend Forwardable
30
+
31
+ @@templates = { }
32
+
33
+ #===スライドを作成する
34
+ #スライド本体は、Partsクラスのインスタンス
35
+ #_params_:: あとで書く
36
+ def Slide.create(params = {})
37
+ tmp = params.dup
38
+ tmp[:size] ||= Size.new(640, 480)
39
+ tmp[:type] ||= :ac
40
+ tmp[:color] ||= Color[:white]
41
+ return Parts.new(tmp[:size]).tap{|obj| obj[:___base___] = Sprite.new(tmp).fill(tmp[:color])}
42
+ end
43
+
44
+ @@templates["320x240"] = {:size=>Size.new(320,240)}
45
+ @@templates["640x480"] = {}
46
+ @@templates["800x600"] = {:size=>Size.new(800,600)}
47
+ @@templates["white"] = {:color=>[255,255,255,255]}
48
+ @@templates["gray"] = {:color=>[128,128,128,255]}
49
+ @@templates["black"] = {:color=>[0,0,0,255]}
50
+ @@templates["half-white"] = {:color=>[255,255,255,128]}
51
+
52
+ #===スライドをテンプレート文字列から作成する
53
+ #スライドを所定の名称で生成する。利用できるのは以下の7種類
54
+ #"320x240" 大きさは320x240ピクセル、背景は白色
55
+ #"640x480" 大きさは640x480ピクセル、背景は白色(デフォルトのテンプレート)
56
+ #"800x600" 大きさは800x600ピクセル、背景は白色
57
+ #"white" "640x480"と同一
58
+ #"gray" 大きさは640x480ピクセル、背景は灰色([128,128,128,255])
59
+ #"black" 大きさは640x480ピクセル、背景は黒色([0,0,0,255])
60
+ #"half-white" 背景が半分透明な"white"([255,255,255,128])
61
+ #_sym_:: テンプレートに対応した文字列
62
+ #返却値:: 生成したスライド(Partsクラスインスタンス)
63
+ def Slide.[](sym = "640x480")
64
+ return Slide.create(@@templates[sym])
65
+ end
66
+
67
+ #===スライドのテンプレートを追加する
68
+ #指定できるテンプレートの内容は、Sprite.newメソッドの引数がそのまま使える(Hashクラスインスタンスとして渡す)
69
+ #また、追加として、:colorパラメータを使って塗りつぶす色を指定することが出来る。
70
+ #(例):color=>Color[:red]
71
+ #_sym_:: テンプレート名
72
+ #_params_:: 生成時のパラメータ
73
+ def Slide.[]=(sym, params)
74
+ @@templates[sym] = params
75
+ end
76
+
77
+ #===スライド情報を初期化する
78
+ #(例)init_slide(Slide.create(:size=>Size.new(320,240), :color=>[255,0,0]))
79
+ #(例)init_slide(Slide["640x480"]))
80
+ #_template_:: 元となるPartsクラスインスタンス(Slide.createメソッドで作成もしくはSlide.[]で取得できるテンプレートスライド)
81
+ def init_slide(template)
82
+ init_layout
83
+ @body = template
84
+ set_layout_size(*(@body.size))
85
+ @body.snap(self)
86
+ end
87
+
88
+ def piece
89
+ return self
90
+ end
91
+
92
+ private :piece
93
+
94
+ #===名前に対応したパーツを取得する
95
+ #_title_:: 取得したいパーツに対応したシンボル
96
+ #返却値:: シンボルに対応したパーツ
97
+ def [](title)
98
+ return @body[title]
99
+ end
100
+
101
+ #===パーツに名前を割り付けて設定する
102
+ #_title_:: 取得したいパーツに対応したシンボル
103
+ #_objs_:: (1)シンボルに対応させるパーツ(スライドにスナップする)
104
+ #(2)パーツと、スナップさせるパーツの名前(シンボル)
105
+ #返却値:: 自分自身を返す
106
+ def []=(title, objs)
107
+ @body[title] = objs
108
+ return self
109
+ end
110
+
111
+ #===スライドを画面に描画する
112
+ #単純にslide_renderメソッドを呼び出し、結果を返すだけのテンプレートメソッド
113
+ #このメソッドを記述し直すことにより、柔軟なrenderを行える
114
+ #ブロックを渡すと、スライド,画面側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
115
+ #ブロックの引数は、|スライド側SpriteUnit,画面側SpriteUnit|となる。
116
+ #返却値:: 自分自身を返す
117
+ def render(&block)
118
+ return slide_render(&block)
119
+ end
120
+
121
+ #===スライドを画像に描画する
122
+ #単純にslide_render_toメソッドを呼び出し、結果を返すだけのテンプレートメソッド
123
+ #このメソッドを記述し直すことにより、柔軟なrenderを行える
124
+ #ブロックを渡すと、スライド,画像側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
125
+ #ブロックの引数は、|スライド側SpriteUnit,画像側SpriteUnit|となる。
126
+ #_dst_:: 描画先画像(Spriteクラスインスタンスなど)
127
+ #返却値:: 自分自身を返す
128
+ def render_to(dst, &block)
129
+ return slide_render_to(dst, &block)
130
+ end
131
+
132
+ #===スライドを画面に描画する
133
+ #ブロックを渡すと、スライド,画面側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
134
+ #ブロックの引数は、|スライド側SpriteUnit,画面側SpriteUnit|となる。
135
+ #返却値:: 自分自身を返す
136
+ def slide_render(&block)
137
+ @body.render(&block)
138
+ return self
139
+ end
140
+
141
+ #===スライドを画像に描画する
142
+ #ブロックを渡すと、スライド,画像側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
143
+ #ブロックの引数は、|スライド側SpriteUnit,画像側SpriteUnit|となる。
144
+ #_dst_:: 描画先画像(Spriteクラスインスタンスなど)
145
+ #返却値:: 自分自身を返す
146
+ def slide_render_to(dst, &block)
147
+ @body.render(dst, &block)
148
+ return self
149
+ end
150
+
151
+ #===@bodyに登録したオブジェクトとは別に作成していたインスタンスを解放する
152
+ def dispose
153
+ end
154
+
155
+ def_delegators(:@body, :remove, :each, :start, :stop, :reset, :update, :update_animation)
156
+ end
157
+ end
@@ -0,0 +1,201 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ #=コンテンツ作成ライブラリMiyako2.1
4
+ #
5
+ #Authors:: サイロス誠
6
+ #Version:: 2.1.0
7
+ #Copyright:: 2007-2009 Cyross Makoto
8
+ #License:: LGPL2.1
9
+ #
10
+ =begin
11
+ Miyako v2.1
12
+ Copyright (C) 2007-2008 Cyross Makoto
13
+
14
+ This library is free software; you can redistribute it and/or
15
+ modify it under the terms of the GNU Lesser General Public
16
+ License as published by the Free Software Foundation; either
17
+ version 2.1 of the License, or (at your option) any later version.
18
+
19
+ This library is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22
+ Lesser General Public License for more details.
23
+
24
+ You should have received a copy of the GNU Lesser General Public
25
+ License along with this library; if not, write to the Free Software
26
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
+ =end
28
+
29
+ if RUBY_VERSION < '1.9.1'
30
+ puts 'Sorry. Miyako needs Ruby 1.9.1 or above...'
31
+ exit
32
+ end
33
+
34
+ require 'sdl'
35
+
36
+ if SDL::VERSION < '2.0'
37
+ puts 'Sorry. Miyako needs Ruby/SDL 2.0.0 or above...'
38
+ exit
39
+ end
40
+
41
+ require 'forwardable'
42
+ require 'iconv' if RUBY_VERSION < '1.9.0'
43
+ require 'kconv'
44
+ require 'rbconfig'
45
+
46
+ #画面などの初期設定を自動的に行うかどうかの設定。デフォルトはtrue
47
+ $miyako_auto_open = true if $miyako_auto_open.nil?
48
+
49
+ #デバッグモードの設定。デバッグモードにするときはtrueを渡す。デフォルトはfalse
50
+ $miyako_debug_mode ||= false
51
+
52
+ #openGLを使う? openGLを使用するときはtrueを設定する。デフォルトはfalse
53
+ $miyako_use_opengl ||= false
54
+
55
+ #サウンド機能を使わないときは、miyako.rbをロードする前に
56
+ #$not_use_audio変数にtrueを割り当てる
57
+ $not_use_audio ||= false
58
+
59
+ Thread.abort_on_exception = true
60
+
61
+ #==Miyako基幹モジュール
62
+ module Miyako
63
+ VERSION = "2.1.0"
64
+
65
+ #===アプリケーション実行中に演奏する音楽のサンプリングレートを指定する
66
+ #単位はHz(周波数)
67
+ #規定値は44100
68
+ #音声ファイルを扱うときは、すべての音声ファイルを同じサンプリングレートに統一する必要がある
69
+ $sampling_seq ||= 44100
70
+
71
+ #サウンド機能を使うときのバッファサイズを設定する(バイト単位)
72
+ #デフォルトは4096バイト
73
+ $sound_buffer_size ||= 4096
74
+
75
+ #===Miyakoのバージョン番号を出力する
76
+ #返却値:: バージョン番号を示す文字列
77
+ def Miyako::version
78
+ return VERSION
79
+ end
80
+
81
+ osn = Config::CONFIG["target_os"].downcase
82
+ @@osName = "other"
83
+ case osn
84
+ when /mswin|mingw|cygwin|bccwin/
85
+ @@osName = "win"
86
+ when /linux/
87
+ @@osName = "linux"
88
+ when /darwin/
89
+ @@osName = "mac_osx"
90
+ end
91
+
92
+ #===実行しているOSの名前を取得する
93
+ #(Windows 9x/Me/Xp/Vista, Cygwin/MinGW) : "win"
94
+ #(Linux) : "linux"
95
+ #(Mac OS X) : "mac_osx"
96
+ #(other) : "other"
97
+ #返却値:: OS名
98
+ def Miyako::getOSName
99
+ return @@osName
100
+ end
101
+
102
+ #===ウィンドウのタイトルを設定する
103
+ #_title_:: 設定する文字列
104
+ def Miyako::setTitle(title)
105
+ str = title
106
+ case @@osName
107
+ when "win"
108
+ str = title.to_s().encode(Encoding::SJIS)
109
+ when "mac_osx"
110
+ str = title.to_s().encode(Encoding::UTF_8)
111
+ when "linux"
112
+ str = title.to_s().encode(Encoding::EUCJP)
113
+ end
114
+ SDL::WM.setCaption(str, "")
115
+ end
116
+ end
117
+
118
+ require 'Miyako/API/exceptions'
119
+ require 'Miyako/API/utility'
120
+ require 'Miyako/API/basic_data'
121
+ require 'Miyako/API/modules'
122
+ require 'Miyako/API/yuki'
123
+ require 'Miyako/API/font'
124
+ require 'Miyako/API/viewport'
125
+ require 'Miyako/API/layout'
126
+ require 'Miyako/API/bitmap'
127
+ require 'Miyako/API/drawing'
128
+ require 'Miyako/API/spriteunit'
129
+ require 'Miyako/API/sprite_animation'
130
+ require 'Miyako/API/sprite'
131
+ require 'Miyako/API/sprite_list'
132
+ require 'Miyako/API/collision'
133
+ require 'Miyako/API/screen'
134
+ require 'Miyako/API/shape'
135
+ require 'Miyako/API/plane'
136
+ require 'Miyako/API/input'
137
+ require 'Miyako/API/audio'
138
+ require 'Miyako/API/movie'
139
+ require 'Miyako/API/parts'
140
+ require 'Miyako/API/choices'
141
+ require 'Miyako/API/textbox'
142
+ require 'Miyako/API/map'
143
+ require 'Miyako/API/fixedmap'
144
+ require 'Miyako/API/map_event'
145
+ require 'Miyako/API/story'
146
+ require 'Miyako/API/diagram'
147
+
148
+ module Miyako
149
+ @@initialized = false
150
+
151
+ #===Miyakoのメインループ
152
+ #ブロックを受け取り、そのブロックを評価する
153
+ #ブロック評価前に<i>Audio::update</i>と<i>Input::update</i>、<i>Screen::clear</i>、評価後に<i>Screen::render</i>を呼び出す
154
+ #
155
+ #ブロックを渡さないと例外が発生する
156
+ def Miyako.main_loop
157
+ raise MiyakoError, "Miyako.main_loop needs brock!" unless block_given?
158
+ loop do
159
+ Audio.update
160
+ Input.update
161
+ Screen.clear
162
+ yield
163
+ Screen.render
164
+ end
165
+ end
166
+
167
+ #===SDLの初期化
168
+ def Miyako.init
169
+ raise MiyakoError, "Already initialized!" if @@initialized
170
+ if $not_use_audio
171
+ SDL.init(SDL::INIT_VIDEO | SDL::INIT_JOYSTICK)
172
+ else
173
+ SDL.init(SDL::INIT_VIDEO | SDL::INIT_AUDIO | SDL::INIT_JOYSTICK)
174
+ end
175
+ @@initialized = true
176
+ end
177
+
178
+ #===Miyako(SDL)が初期化された?
179
+ def Miyako.initialized?
180
+ @@initialized
181
+ end
182
+
183
+ #===Miyakoの初期化
184
+ #画面初期化や音声初期化などのメソッドを呼び出す。
185
+ #グローバル変数$miyako_auto_openがtrueのときは最初に自動的に呼び出される。
186
+ #ユーティリティメソッドを使うだけならば、$miyako_auto_open=falseを設定して、後々Miyako.openを呼び出す。
187
+ #_screen_:: 別のプロセスで生成されたSDL::Screenクラスのインスタンス。省略時はnil
188
+ #_buf_size_:: Audioモジュールで使用するバッファサイズ。単位はバイト。省略時は4096
189
+ #_seq_:: Audioモジュールで使用する音声の再生サンプル周波数。省略時は44100(44.1kHz)
190
+ def Miyako.open(screen = nil, buf_size = 4096, seq = 44100)
191
+ Miyako.init
192
+ Screen.init(screen)
193
+ Font.init
194
+ Audio.init(buf_size, seq)
195
+ Input.init
196
+ end
197
+ end
198
+
199
+ require 'Miyako/miyako_no_katana'
200
+
201
+ Miyako.open(nil, $sound_buffer_size, $sampling_seq) if $miyako_auto_open
Binary file
@@ -0,0 +1,35 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ #=コンテンツ作成ライブラリMiyako2.1
4
+ #
5
+ #Authors:: サイロス誠
6
+ #Version:: 2.1.0
7
+ #Copyright:: 2007-2009 Cyross Makoto
8
+ #License:: LGPL2.1
9
+ #
10
+ =begin
11
+ Miyako v2.1
12
+ Copyright (C) 2007-2008 Cyross Makoto
13
+
14
+ This library is free software; you can redistribute it and/or
15
+ modify it under the terms of the GNU Lesser General Public
16
+ License as published by the Free Software Foundation; either
17
+ version 2.1 of the License, or (at your option) any later version.
18
+
19
+ This library is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22
+ Lesser General Public License for more details.
23
+
24
+ You should have received a copy of the GNU Lesser General Public
25
+ License along with this library; if not, write to the Free Software
26
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
+ =end
28
+
29
+ # 初期化を行わずにrequire 'Miyako/miyako'のみ行う
30
+
31
+ $miyako_auto_open = false
32
+
33
+ require 'Miyako/miyako'
34
+
35
+ $miyako_auto_open = nil
Binary file
Binary file
Binary file
Binary file
Binary file
data/logo/miyako.png ADDED
Binary file
Binary file
data/logo/space.png ADDED
Binary file
@@ -0,0 +1,68 @@
1
+ #! /usr/bin/ruby
2
+ # M1ku sample for Miyako v2.0
3
+ # 2008.11.30 Cyross Makoto
4
+
5
+ require 'Miyako/miyako'
6
+ include Miyako
7
+
8
+ #Screen.fps_view = true
9
+
10
+ def create_arm(num)
11
+ spr = Sprite.new(:file=>sprintf("m1ku_arm_#{num}.png"), :type=>:ck)
12
+ spr.move_to!(30, 70)
13
+ return spr
14
+ end
15
+
16
+ def create_eye(num)
17
+ spr = Sprite.new(:file=>sprintf("m1ku_eye_#{num}.png"), :type=>:ck)
18
+ spr.move_to!(356, 114)
19
+ return spr
20
+ end
21
+
22
+ back = Sprite.new(:file=>"m1ku_back.jpg", :type=>:as)
23
+ backs = SpriteAnimation.new(:sprite=>Array.new(12){|n| back.to_sprite{|sprite| Bitmap.hue(sprite, sprite, 30 * n) }}, :wait => 0.1).start
24
+
25
+ body = Sprite.new(:file=>"m1ku_body.png", :type=>:ck)
26
+ body.move_to!(200, 64)
27
+
28
+ hair_f = Sprite.new(:file=>"m1ku_hair_front.png", :type=>:ck)
29
+ hair_f.move_to!(200, 24)
30
+
31
+ hair_r = Sprite.new(:file=>"m1ku_hair_rear.png", :type=>:ck)
32
+ hair_r.move_to!(200, 24)
33
+
34
+ arms = Array.new
35
+ (0..3).each{|n| arms.push(create_arm(n)) }
36
+ arm_anim_param = {
37
+ :sprite=> arms,
38
+ :wait => 0.1,
39
+ :pattern_list => [0, 1, 2, 3, 2, 1]
40
+ }
41
+ arm_anim = SpriteAnimation.new(arm_anim_param)
42
+ arm_anim.start
43
+
44
+ eyes = Array.new
45
+ (0..3).each{|n| eyes.push(create_eye(n)) }
46
+ eye_anim_param = {
47
+ :sprite => eyes,
48
+ :wait => [4.5, 0.1, 0.1, 0.1, 0.1, 0.1],
49
+ :pattern_list => [0, 1, 2, 3, 2, 1]
50
+ }
51
+ eye_anim = SpriteAnimation.new(eye_anim_param)
52
+ eye_anim.start
53
+
54
+ damt = 30
55
+
56
+ # Main Routine
57
+ Miyako.main_loop do
58
+ break if Input.quit_or_escape?
59
+ backs.render
60
+ backs.update_animation
61
+ hair_r.render
62
+ arm_anim.update_animation
63
+ arm_anim.render
64
+ body.render
65
+ eye_anim.update_animation
66
+ eye_anim.render
67
+ hair_f.render
68
+ end
Binary file
Binary file
Binary file