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,60 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # Miyako Extension Cairo-Miyako interface
3
+ =begin
4
+ Miyako Extention Library v2.0
5
+ Copyright (C) 2007-2008 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
+ require 'cairo'
24
+ rescue
25
+ begin
26
+ require 'rubygems'
27
+ require 'cairo'
28
+ rescue
29
+ raise Miyako::MiyakoError, "Sorry, Cairo-Miyako Interface has rcairo."
30
+ end
31
+ end
32
+
33
+ module Miyako
34
+ #==MiyakoのSpriteクラスのインスタンスとCairoのImageSurfaceクラスのインスタンスとの相互変換モジュール
35
+ #要rcairo1.8以降
36
+ module MiyakoCairo
37
+ #===SpriteインスタンスをCairoのImageSurfaceに変換
38
+ #変換したCairo::ImageSurfaceインスタンスは、32ビット(Cairo::Format::ARGB32)の画像を持つ
39
+ #_sprite_:: 変換元Spriteインスタンス
40
+ #返却値:: 変換したCairo::ImageSurfaceインスタンス
41
+ def MiyakoCairo.to_cairo_surface(sprite)
42
+ return Cairo::ImageSurface.new(sprite.bitmap.pixels, Cairo::Format::ARGB32, sprite.w, sprite.h, sprite.w * 4)
43
+ end
44
+
45
+ #===CairoのImageSurfaceをSpriteインスタンスに変換
46
+ #変換したSpriteインスタンスは、:acタイプ(但し元画像がCairo::Format::RGB24の時は:asタイプ)の画像を持つ
47
+ #_surface_:: 変換元Cairo::ImageSurfaceインスタンス
48
+ #返却値:: 変換したSpriteインスタンス
49
+ def MiyakoCairo.to_sprite(surface)
50
+ # エンディアン判別
51
+ if [1].pack("V*") == [1].pack("L*") # リトルエンディアン?
52
+ bitmap = SDL::Surface.new_from(surface.data, surface.width, surface.height, 32, surface.stride, 0xff0000, 0xff00, 0xff, 0xff000000)
53
+ else # ビッグエンディアン
54
+ bitmap = SDL::Surface.new_from(surface.data, surface.width, surface.height, 32, surface.stride, 0xff00, 0xff0000, 0xff000000, 0xff)
55
+ end
56
+ return Sprite.new(:bitmap => bitmap, :type => :as) if surface.format == Cairo::Format::RGB24
57
+ return Sprite.new(:bitmap => bitmap, :type => :ac)
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,138 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # Miyako Extension Raster Scroll
3
+ =begin
4
+ Miyako Extention Library v2.0
5
+ Copyright (C) 2007-2008 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,136 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # Miyako Extension
3
+ =begin
4
+ Miyako Extention Library v2.0
5
+ Copyright (C) 2007-2008 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
+ #ブロックを渡すと、スライド,画面側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
113
+ #ブロックの引数は、|スライド側SpriteUnit,画面側SpriteUnit|となる。
114
+ #返却値:: 自分自身を返す
115
+ def render(&block)
116
+ @body.render(&block)
117
+ return self
118
+ end
119
+
120
+ #===スライドを画像に描画する
121
+ #ブロックを渡すと、スライド,画像側のSpriteUnitを更新して、それを実際の転送に反映させることが出来る。
122
+ #ブロックの引数は、|スライド側SpriteUnit,画像側SpriteUnit|となる。
123
+ #_dst_:: 描画先画像(Spriteクラスインスタンスなど)
124
+ #返却値:: 自分自身を返す
125
+ def render_to(dst, &block)
126
+ @body.render(dst, &block)
127
+ return self
128
+ end
129
+
130
+ #===@bodyに登録したオブジェクトとは別に作成していたインスタンスを解放する
131
+ def dispose
132
+ end
133
+
134
+ def_delegators(:@body, :remove, :each, :start, :stop, :reset, :update, :update_animation)
135
+ end
136
+ end
@@ -0,0 +1,172 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ #=コンテンツ作成ライブラリMiyako2.0
4
+ #
5
+ #Authors:: サイロス誠
6
+ #Version:: 2.0.0
7
+ #Copyright:: 2007-2008 Cyross Makoto
8
+ #License:: LGPL2.1
9
+ #
10
+ =begin
11
+ Miyako v2.0
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.8.7'
30
+ puts 'Sorry. Miyako needs Ruby 1.8.7 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'
43
+ require 'kconv'
44
+ require 'jcode' if RUBY_VERSION < '1.9.0'
45
+ require 'rbconfig'
46
+
47
+ $KCODE = 'u' if RUBY_VERSION < '1.9.0'
48
+
49
+
50
+ #デバッグモードの設定
51
+ $miyako_debug_mode ||= false
52
+
53
+ #サウンド機能を使わないときは、miyako.rbをロードする前に
54
+ #$not_use_audio変数にtrueを割り当てる
55
+ $not_use_audio ||= false
56
+ if $not_use_audio
57
+ SDL.init(SDL::INIT_VIDEO | SDL::INIT_JOYSTICK)
58
+ else
59
+ SDL.init(SDL::INIT_VIDEO | SDL::INIT_AUDIO | SDL::INIT_JOYSTICK)
60
+ end
61
+
62
+ Thread.abort_on_exception = true
63
+
64
+ #==Miyako基幹モジュール
65
+ module Miyako
66
+
67
+ #===アプリケーション実行中に演奏する音楽のサンプリングレートを指定する
68
+ #単位はHz(周波数)
69
+ #規定値は44100
70
+ #音声ファイルを扱うときは、すべての音声ファイルを同じサンプリングレートに統一する必要がある
71
+ $sampling_seq ||= 44100
72
+
73
+ #サウンド機能を使うときのバッファサイズを設定する(バイト単位)
74
+ #デフォルトは4096バイト
75
+ $sound_buffer_size ||= 4096
76
+
77
+ SDL::TTF.init
78
+ SDL::Mixer.open($sampling_seq, SDL::Mixer::DEFAULT_FORMAT, 2, $sound_buffer_size) unless $not_use_audio
79
+
80
+ #===Miyakoのバージョン番号を出力する
81
+ #返却値:: バージョン番号を示す文字列
82
+ def Miyako::version
83
+ return "2.0.0"
84
+ end
85
+
86
+ #==Miyakoの例外クラス
87
+ class MiyakoError < Exception
88
+ end
89
+
90
+ osn = Config::CONFIG["target_os"].downcase
91
+ @@osName = "other"
92
+ case osn
93
+ when /mswin|mingw|cygwin|bccwin/
94
+ @@osName = "win"
95
+ when /linux/
96
+ @@osName = "linux"
97
+ when /darwin/
98
+ @@osName = "mac_osx"
99
+ end
100
+
101
+ #===実行しているOSの名前を取得する
102
+ #(Windows 9x/Me/Xp/Vista, Cygwin/MinGW) : "win"
103
+ #(Linux) : "linux"
104
+ #(Mac OS X) : "mac_osx"
105
+ #(other) : "other"
106
+ #返却値:: OS名
107
+ def Miyako::getOSName
108
+ return @@osName
109
+ end
110
+
111
+ #===ウィンドウのタイトルを設定する
112
+ #_title_:: 設定する文字列
113
+ def Miyako::setTitle(title)
114
+ str = title
115
+ case @@osName
116
+ when "win"
117
+ str = title.to_s().tosjis()
118
+ when "mac_osx"
119
+ str = Iconv.conv("UTF-8-MAC", "UTF-8", title.to_s().toutf8())
120
+ when "linux"
121
+ str = title.to_s().toeuc()
122
+ end
123
+ SDL::WM.setCaption(str, "")
124
+ end
125
+ end
126
+
127
+ require 'Miyako/API/yuki'
128
+ require 'Miyako/API/basic_data'
129
+ require 'Miyako/API/modules'
130
+ require 'Miyako/API/font'
131
+ require 'Miyako/API/viewport'
132
+ require 'Miyako/API/layout'
133
+ require 'Miyako/API/bitmap'
134
+ require 'Miyako/API/drawing'
135
+ require 'Miyako/API/spriteunit'
136
+ require 'Miyako/API/sprite_animation'
137
+ require 'Miyako/API/sprite'
138
+ require 'Miyako/API/collision'
139
+ require 'Miyako/API/screen'
140
+ require 'Miyako/API/shape'
141
+ require 'Miyako/API/plane'
142
+ require 'Miyako/API/input'
143
+ require 'Miyako/API/audio'
144
+ require 'Miyako/API/movie'
145
+ require 'Miyako/API/parts'
146
+ require 'Miyako/API/choices'
147
+ require 'Miyako/API/textbox'
148
+ require 'Miyako/API/map'
149
+ require 'Miyako/API/fixedmap'
150
+ require 'Miyako/API/map_event'
151
+ require 'Miyako/API/story'
152
+ require 'Miyako/API/diagram'
153
+
154
+ module Miyako
155
+ #===Miyakoのメインループ
156
+ #ブロックを受け取り、そのブロックを評価する
157
+ #ブロック評価前に<i>Input::update</i>と<i>Screen::clear</i>、評価後に<i>Screen::render</i>を呼び出す
158
+ #
159
+ #ブロックを渡さないと例外が発生する
160
+ def Miyako.main_loop
161
+ raise MiyakoError, "Miyako.main_loop needs brock!" unless block_given?
162
+ loop do
163
+ Input::update
164
+ Screen::clear
165
+ yield
166
+ Screen::render
167
+ sleep 0.01
168
+ end
169
+ end
170
+ end
171
+
172
+ require 'Miyako/miyako_no_katana'
data/miyako.png ADDED
Binary file
data/miyako_banner.png ADDED
Binary file
@@ -0,0 +1,34 @@
1
+ require 'mkmf'
2
+
3
+ if /mswin32/ =~ CONFIG["arch"]
4
+ have_library("SDL")
5
+ else
6
+ sdl_config = with_config('sdl-config', 'sdl-config')
7
+
8
+ $CFLAGS += ' ' + `#{sdl_config} --cflags`.chomp
9
+ $LOCAL_LIBS += ' ' + `#{sdl_config} --libs`.chomp
10
+
11
+ if /-Dmain=SDL_main/ =~ $CFLAGS then
12
+ def try_func(func, libs, headers = nil, &b)
13
+ headers = cpp_include(headers)
14
+ try_link(<<"SRC", libs, &b) or try_link(<<"SRC", libs, &b)
15
+ #{headers}
16
+ /*top*/
17
+ int main(int argc,char** argv) { return 0; }
18
+ int t() { #{func}(); return 0; }
19
+ SRC
20
+ #{COMMON_HEADERS}
21
+ #{headers}
22
+ /*top*/
23
+ int main(int argc,char** argv) { return 0; }
24
+ int t() { void ((*volatile p)()); p = (void ((*)()))#{func}; return 0; }
25
+ SRC
26
+ end
27
+ end
28
+ end
29
+
30
+ if enable_config("static-libs",false) then
31
+ have_library("SDL")
32
+ end
33
+
34
+ create_makefile('miyako_no_katana')