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.
- data/README +977 -0
- data/Rakefile +7 -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 +75 -0
- data/lib/Miyako/API/audio.rb +198 -0
- data/lib/Miyako/API/basic_data.rb +431 -0
- data/lib/Miyako/API/bitmap.rb +35 -0
- data/lib/Miyako/API/choices.rb +308 -0
- data/lib/Miyako/API/collision.rb +444 -0
- data/lib/Miyako/API/diagram.rb +573 -0
- data/lib/Miyako/API/drawing.rb +110 -0
- data/lib/Miyako/API/fixedmap.rb +315 -0
- data/lib/Miyako/API/font.rb +384 -0
- data/lib/Miyako/API/input.rb +440 -0
- data/lib/Miyako/API/layout.rb +451 -0
- data/lib/Miyako/API/map.rb +403 -0
- data/lib/Miyako/API/map_event.rb +198 -0
- data/lib/Miyako/API/modules.rb +109 -0
- data/lib/Miyako/API/movie.rb +151 -0
- data/lib/Miyako/API/parts.rb +154 -0
- data/lib/Miyako/API/plane.rb +131 -0
- data/lib/Miyako/API/screen.rb +257 -0
- data/lib/Miyako/API/shape.rb +362 -0
- data/lib/Miyako/API/sprite.rb +338 -0
- data/lib/Miyako/API/sprite_animation.rb +461 -0
- data/lib/Miyako/API/spriteunit.rb +113 -0
- data/lib/Miyako/API/story.rb +224 -0
- data/lib/Miyako/API/textbox.rb +496 -0
- data/lib/Miyako/API/viewport.rb +435 -0
- data/lib/Miyako/API/yuki.rb +779 -0
- data/lib/Miyako/EXT/miyako_cairo.rb +60 -0
- data/lib/Miyako/EXT/raster_scroll.rb +138 -0
- data/lib/Miyako/EXT/slides.rb +136 -0
- data/lib/Miyako/miyako.rb +172 -0
- data/miyako.png +0 -0
- data/miyako_banner.png +0 -0
- data/miyako_no_katana/extconf.rb +34 -0
- data/miyako_no_katana/miyako_no_katana.c +3301 -0
- data/sample/Animation1/m1ku.rb +89 -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 +95 -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 +283 -0
- data/sample/Diagram_sample/readme.txt +87 -0
- data/sample/Diagram_sample/wait_cursor.png +0 -0
- data/sample/Room3/blue.rb +250 -0
- data/sample/Room3/ending.rb +175 -0
- data/sample/Room3/green.rb +185 -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 +102 -0
- data/sample/Room3/main_component.rb +58 -0
- data/sample/Room3/readme.txt +76 -0
- data/sample/Room3/red.rb +200 -0
- data/sample/Room3/room3.rb +26 -0
- data/sample/Room3/title.rb +171 -0
- data/sample/fixed_map_test/cursor.png +0 -0
- data/sample/fixed_map_test/fixed_map_sample.rb +149 -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/map_sample.rb +121 -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 +50 -0
- data/sample/map_test/chr1.png +0 -0
- data/sample/map_test/cursor.png +0 -0
- data/sample/map_test/main_parts.rb +48 -0
- data/sample/map_test/main_scene.rb +137 -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 +92 -0
- data/sample/map_test/map_test.rb +23 -0
- data/sample/map_test/mapchip.csv +21 -0
- data/sample/map_test/oasis.rb +65 -0
- data/sample/map_test/readme.txt +87 -0
- data/sample/map_test/route.rb +144 -0
- data/sample/map_test/sea.png +0 -0
- data/sample/map_test/town.rb +68 -0
- data/sample/map_test/wait_cursor.png +0 -0
- data/sample/map_test/window.png +0 -0
- data/win/miyako_no_katana.so +0 -0
- metadata +194 -0
@@ -0,0 +1,431 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
=begin
|
3
|
+
--
|
4
|
+
Miyako 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
|
+
++
|
21
|
+
=end
|
22
|
+
|
23
|
+
module Miyako
|
24
|
+
#==位置情報のための構造体クラス
|
25
|
+
#位置変更メソッドを追加
|
26
|
+
class PointStruct < Struct
|
27
|
+
#===位置を変更する(変化量を指定)
|
28
|
+
#_dx_:: 移動量(x方向)。単位はピクセル
|
29
|
+
#_dy_:: 移動量(y方向)。単位はピクセル
|
30
|
+
#返却値:: 自分自身を返す
|
31
|
+
def move(dx, dy)
|
32
|
+
self[0]+=dx
|
33
|
+
self[1]+=dy
|
34
|
+
return self
|
35
|
+
end
|
36
|
+
|
37
|
+
#===位置を変更する(位置指定)
|
38
|
+
#_x_:: 移動先位置(x方向)。単位はピクセル
|
39
|
+
#_y_:: 移動先位置(y方向)。単位はピクセル
|
40
|
+
#返却値:: 自分自身を返す
|
41
|
+
def move_to(x, y)
|
42
|
+
self[0]=x
|
43
|
+
self[1]=y
|
44
|
+
return self
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
#==サイズ情報のための構造体クラス
|
49
|
+
#サイズ変更メソッドを追加
|
50
|
+
class SizeStruct < Struct
|
51
|
+
#===サイズを変更する(変化量を指定)
|
52
|
+
#_w_:: 幅変更。単位はピクセル
|
53
|
+
#_h_:: 高さ変更。単位はピクセル
|
54
|
+
#返却値:: 自分自身を返す
|
55
|
+
def resize(w, h)
|
56
|
+
self[0]=w
|
57
|
+
self[1]=h
|
58
|
+
return self
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
#==矩形情報のための構造体クラス
|
63
|
+
#矩形変更メソッドを追加
|
64
|
+
class RectStruct < Struct
|
65
|
+
#===位置を変更する(変化量を指定)
|
66
|
+
#_dx_:: 移動量(x方向)。単位はピクセル
|
67
|
+
#_dy_:: 移動量(y方向)。単位はピクセル
|
68
|
+
#返却値:: 自分自身を返す
|
69
|
+
def move(dx, dy)
|
70
|
+
self[0]+=dx
|
71
|
+
self[1]+=dy
|
72
|
+
return self
|
73
|
+
end
|
74
|
+
|
75
|
+
#===位置を変更する(位置指定)
|
76
|
+
#_x_:: 移動先位置(x方向)。単位はピクセル
|
77
|
+
#_y_:: 移動先位置(y方向)。単位はピクセル
|
78
|
+
#返却値:: 自分自身を返す
|
79
|
+
def move_to(x, y)
|
80
|
+
self[0]=x
|
81
|
+
self[1]=y
|
82
|
+
return self
|
83
|
+
end
|
84
|
+
|
85
|
+
#===サイズを変更する(変化量を指定)
|
86
|
+
#_w_:: 幅変更。単位はピクセル
|
87
|
+
#_h_:: 高さ変更。単位はピクセル
|
88
|
+
#返却値:: 自分自身を返す
|
89
|
+
def resize(w, h)
|
90
|
+
self[2]=w
|
91
|
+
self[3]=h
|
92
|
+
return self
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
#==Square構造体用クラス
|
97
|
+
#位置変更メソッドを追加
|
98
|
+
class SquareStruct < Struct
|
99
|
+
#===位置を変更する(変化量を指定)
|
100
|
+
#_dx_:: 移動量(x方向)。単位はピクセル
|
101
|
+
#_dy_:: 移動量(y方向)。単位はピクセル
|
102
|
+
#返却値:: 自分自身を返す
|
103
|
+
def move(dx, dy)
|
104
|
+
self[0]+=dx
|
105
|
+
self[1]+=dy
|
106
|
+
self[2]+=dx
|
107
|
+
self[3]+=dy
|
108
|
+
return self
|
109
|
+
end
|
110
|
+
|
111
|
+
#===位置を変更する(位置指定)
|
112
|
+
#_x_:: 移動先位置(x方向)。単位はピクセル
|
113
|
+
#_y_:: 移動先位置(y方向)。単位はピクセル
|
114
|
+
#返却値:: 自分自身を返す
|
115
|
+
def move_to(x, y)
|
116
|
+
w = self[2] - self[0]
|
117
|
+
h = self[3] - self[1]
|
118
|
+
self[0]=x
|
119
|
+
self[1]=y
|
120
|
+
self[2]=x+w
|
121
|
+
self[3]=y+h
|
122
|
+
return self
|
123
|
+
end
|
124
|
+
|
125
|
+
#===サイズを変更する(変化量を指定)
|
126
|
+
#_w_:: 幅変更。単位はピクセル
|
127
|
+
#_h_:: 高さ変更。単位はピクセル
|
128
|
+
#返却値:: 自分自身を返す
|
129
|
+
def resize(w, h)
|
130
|
+
raise MiyakoError, "Illegal size! w:#{w} h:#{h}" if (w < 0 || h < 0)
|
131
|
+
self[2]=self[0] + w - 1
|
132
|
+
self[3]=self[1] + h - 1
|
133
|
+
return self
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
#==座標などを構成するために使用する構造体
|
138
|
+
#_x_:: X座標の値
|
139
|
+
#_y_:: Y座標の値
|
140
|
+
Point = PointStruct.new(:x, :y)
|
141
|
+
|
142
|
+
#==サイズなどを構成するために使用する構造体
|
143
|
+
#_w_:: 横幅
|
144
|
+
#_h_:: 高さ
|
145
|
+
Size = SizeStruct.new(:w, :h)
|
146
|
+
|
147
|
+
#==矩形などを構成するために使用する構造体
|
148
|
+
#_x_:: X座標の値
|
149
|
+
#_y_:: Y座標の値
|
150
|
+
#_w_:: 横幅
|
151
|
+
#_h_:: 高さ
|
152
|
+
Rect = RectStruct.new(:x, :y, :w, :h)
|
153
|
+
|
154
|
+
#==矩形などを構成するために使用する構造体
|
155
|
+
#_left_:: 左上X座標の値
|
156
|
+
#_top_:: 左上Y座標の値
|
157
|
+
#_right_:: 右下X座標の値
|
158
|
+
#_bottom_:: 右下Y座標の値
|
159
|
+
Square = SquareStruct.new(:left, :top, :right, :bottom)
|
160
|
+
|
161
|
+
#==色を管理するクラス
|
162
|
+
#
|
163
|
+
#色情報は、[r(赤),g(緑),b(青),a(透明度)]、[r,g,b,a(透明度)]の2種類の配列
|
164
|
+
#
|
165
|
+
#それぞれの要素の値は0〜255の範囲
|
166
|
+
#
|
167
|
+
#4要素必要な色情報に3要素の配列を渡すと、自動的に4要素目(値は255)が挿入される
|
168
|
+
#
|
169
|
+
#(注)本クラスで採用する透明度と、画像が持つ透明度とは別物
|
170
|
+
class Color
|
171
|
+
@@symbol2color = {:black => [ 0, 0, 0, 255],
|
172
|
+
:white => [255,255,255, 255],
|
173
|
+
:blue => [ 0, 0,255, 255],
|
174
|
+
:green => [ 0,255, 0, 255],
|
175
|
+
:red => [255, 0, 0, 255],
|
176
|
+
:cyan => [ 0,255,255, 255],
|
177
|
+
:purple => [255, 0,255, 255],
|
178
|
+
:yellow => [255,255, 0, 255],
|
179
|
+
:light_gray => [200,200,200, 255],
|
180
|
+
:half_gray => [128,128,128, 255],
|
181
|
+
:half_blue => [ 0, 0,128, 255],
|
182
|
+
:half_green => [ 0,128, 0, 255],
|
183
|
+
:half_red => [128, 0, 0, 255],
|
184
|
+
:half_cyan => [ 0,128,128, 255],
|
185
|
+
:half_purple => [128, 0,128, 255],
|
186
|
+
:half_yellow => [128,128, 0, 255],
|
187
|
+
:dark_gray => [ 80, 80, 80, 255],
|
188
|
+
:dark_blue => [ 0, 0, 80, 255],
|
189
|
+
:dark_green => [ 0, 80, 0, 255],
|
190
|
+
:dark_red => [ 80, 0, 0, 255],
|
191
|
+
:dark_cyan => [ 0, 80, 80, 255],
|
192
|
+
:dark_purple => [ 80, 0, 80, 255],
|
193
|
+
:dark_yellow => [ 80, 80, 0, 255]}
|
194
|
+
@@symbol2color.default = nil
|
195
|
+
|
196
|
+
#===シンボルから色情報を取得する
|
197
|
+
#_name_::色に対応したシンボル(以下の一覧参照)。存在しないシンボルを渡したときはエラーを返す
|
198
|
+
#返却値::シンボルに対応した4要素の配列
|
199
|
+
#
|
200
|
+
#シンボル:: 色配列([赤,緑,青,透明度])
|
201
|
+
#:black:: [ 0, 0, 0, 255]
|
202
|
+
#:white:: [255,255,255, 255]
|
203
|
+
#:blue:: [ 0, 0,255, 255]
|
204
|
+
#:green:: [ 0,255, 0, 255]
|
205
|
+
#:red:: [255, 0, 0, 255]
|
206
|
+
#:cyan:: [ 0,255,255, 255]
|
207
|
+
#:purple:: [255, 0,255, 255]
|
208
|
+
#:yellow:: [255,255, 0, 255]
|
209
|
+
#:light_gray:: [200,200,200, 255]
|
210
|
+
#:half_gray:: [128,128,128, 255]
|
211
|
+
#:half_blue:: [ 0, 0,128, 255]
|
212
|
+
#:half_green:: [ 0,128, 0, 255]
|
213
|
+
#:half_red:: [128, 0, 0, 255]
|
214
|
+
#:half_cyan:: [ 0,128,128, 255]
|
215
|
+
#:half_purple:: [128, 0,128, 255]
|
216
|
+
#:half_yellow:: [128,128, 0, 255]
|
217
|
+
#:dark_gray:: [ 80, 80, 80, 255]
|
218
|
+
#:dark_blue:: [ 0, 0, 80, 255]
|
219
|
+
#:dark_green:: [ 0, 80, 0, 255]
|
220
|
+
#:dark_red:: [ 80, 0, 0, 255]
|
221
|
+
#:dark_cyan:: [ 0, 80, 80, 255]
|
222
|
+
#:dark_purple:: [ 80, 0, 80, 255]
|
223
|
+
#:dark_yellow:: [ 80, 80, 0, 255]
|
224
|
+
def Color.[](name, alpha = nil)
|
225
|
+
c = (@@symbol2color[name.to_sym] or raise MiyakoError, "Illegal Color Name! : #{name}")
|
226
|
+
c[3] = alpha if alpha
|
227
|
+
return c
|
228
|
+
end
|
229
|
+
|
230
|
+
#===Color.[]メソッドで使用できるシンボルと色情報との対を登録する
|
231
|
+
#_name_:: 色に対応させるシンボル
|
232
|
+
#_value_:: 色情報を示す3〜4要素の配列。3要素のときは4要素目を自動的に追加する
|
233
|
+
def Color.[]=(name, value)
|
234
|
+
@@symbol2color[name.to_sym] = value
|
235
|
+
@@symbol2color[name.to_sym] << 255 if value.length == 3
|
236
|
+
end
|
237
|
+
|
238
|
+
#===様々な形式のデータを色情報に変換する
|
239
|
+
#_v_::変換対象のインスタンス。変換可能な内容は以下の一覧参照
|
240
|
+
#_alpha_::透明度。デフォルトはnil
|
241
|
+
#
|
242
|
+
#インスタンス:: 書式
|
243
|
+
#配列:: 最低3要素の数値の配列
|
244
|
+
#文字列:: ”#RRGGBB"で示す16進数の文字列、もしくは"red"、"black"など。使える文字列はColor.[]で使えるシンボルに対応
|
245
|
+
#数値:: 32bitの値を8bitずつ割り当て(aaaaaaaarrrrrrrrggggggggbbbbbbbb)
|
246
|
+
#シンボル:: Color.[]と同じ
|
247
|
+
def Color::to_rgb(v, alpha = nil)
|
248
|
+
c = (v.to_miyako_color or raise MiyakoError, "Illegal parameter")
|
249
|
+
c[3] = alpha if alpha
|
250
|
+
return c
|
251
|
+
end
|
252
|
+
|
253
|
+
#===色情報をColor.[]メソッドで使用できるシンボルと色情報との対を登録する
|
254
|
+
#_cc_:: 色情報(シンボル、文字列)
|
255
|
+
#_value_:: 色情報を示す3〜4要素の配列。3要素のときは4要素目を自動的に追加する
|
256
|
+
def Color::to_s(cc)
|
257
|
+
c = to_rgb(cc)
|
258
|
+
return "[#{c[0]},#{c[1]},#{c[2]},#{c[3]}]"
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
#タイマーを管理するクラス
|
263
|
+
class WaitCounter
|
264
|
+
SECOND2TICK = 1000
|
265
|
+
|
266
|
+
#WaitCounterインスタンス固有の名前
|
267
|
+
#デフォルトはインスタンスIDを文字列化したもの
|
268
|
+
attr_accessor :name
|
269
|
+
|
270
|
+
def WaitCounter.get_second_to_tick(s) #:nodoc:
|
271
|
+
return (SECOND2TICK * s).to_i
|
272
|
+
end
|
273
|
+
|
274
|
+
#===インスタンスを生成する
|
275
|
+
#_seconds_:: タイマーとして設定する秒数(実数で指定可能)
|
276
|
+
#_name_:: インスタンス固有の名称。デフォルトはnil
|
277
|
+
#(nilを渡した場合、インスタンスIDを文字列化したものが名称になる)
|
278
|
+
#返却値:: 生成されたインスタンス
|
279
|
+
def initialize(seconds, name=nil)
|
280
|
+
@seconds = seconds
|
281
|
+
@name = name ? name : __id__.to_s
|
282
|
+
@wait = WaitCounter.get_second_to_tick(@seconds)
|
283
|
+
@st = 0
|
284
|
+
@counting = false
|
285
|
+
end
|
286
|
+
|
287
|
+
#===設定されているウェイトの長さを求める
|
288
|
+
#ウェイトの長さをミリセカンド単位で取得する
|
289
|
+
#返却値:: ウェイトの長さ
|
290
|
+
def length
|
291
|
+
return @wait
|
292
|
+
end
|
293
|
+
|
294
|
+
#===残りウェイトの長さを求める
|
295
|
+
#タイマー実行中のときウェイトの長さをミリセカンド単位で取得する
|
296
|
+
#返却値:: 残りウェイトの長さ(実行していない時はウェイトの長さ)
|
297
|
+
def remind
|
298
|
+
return @wait unless @counting
|
299
|
+
cnt = SDL.getTicks - @st
|
300
|
+
return @wait < cnt ? 0 : @wait - cnt
|
301
|
+
end
|
302
|
+
|
303
|
+
#===タイマー処理を開始する
|
304
|
+
#返却値:: 自分自身を返す
|
305
|
+
def start
|
306
|
+
@st = SDL.getTicks
|
307
|
+
@counting = true
|
308
|
+
return self
|
309
|
+
end
|
310
|
+
|
311
|
+
#===タイマー処理を停止する
|
312
|
+
#一旦タイマーを停止すると、復帰できない(一時停止ではない)
|
313
|
+
#返却値:: 自分自身を返す
|
314
|
+
def stop
|
315
|
+
@counting = false
|
316
|
+
@st = 0
|
317
|
+
return self
|
318
|
+
end
|
319
|
+
|
320
|
+
def wait_inner(f) #:nodoc:
|
321
|
+
return !f unless @counting
|
322
|
+
t = SDL.getTicks
|
323
|
+
return f unless (t - @st) >= @wait
|
324
|
+
@counting = false
|
325
|
+
return !f
|
326
|
+
end
|
327
|
+
|
328
|
+
private :wait_inner
|
329
|
+
|
330
|
+
#===タイマー処理中かを返す
|
331
|
+
#タイマー処理中ならばtrue、停止中ならばfalseを返す
|
332
|
+
#返却値:: タイマー処理中かどうかを示すフラグ
|
333
|
+
def waiting?
|
334
|
+
return wait_inner(true)
|
335
|
+
end
|
336
|
+
|
337
|
+
#===タイマー処理が終了したかを返す
|
338
|
+
#タイマー処理が終了したらtrue、処理中ならfalseを返す
|
339
|
+
#返却値:: タイマー処理が終わったかどうかを示すフラグ
|
340
|
+
def finish?
|
341
|
+
return wait_inner(false)
|
342
|
+
end
|
343
|
+
|
344
|
+
def wait #:nodoc:
|
345
|
+
st = SDL.getTicks
|
346
|
+
t = SDL.getTicks
|
347
|
+
until (t - st) >= @wait do
|
348
|
+
t = SDL.getTicks
|
349
|
+
end
|
350
|
+
return self
|
351
|
+
end
|
352
|
+
|
353
|
+
#===インスタンスないで所持している領域を開放する
|
354
|
+
#(現段階ではダミー)
|
355
|
+
def dispose
|
356
|
+
end
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
# for duck typing
|
361
|
+
class Object
|
362
|
+
def to_miyako_color #:nodoc:
|
363
|
+
raise Miyako::MiyakoError, "Illegal color parameter class!"
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
class String
|
368
|
+
def to_miyako_color #:nodoc:
|
369
|
+
case self
|
370
|
+
when /\A\[\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\,\s*(\d+)\s*\]\z/
|
371
|
+
#4要素の配列形式
|
372
|
+
return [$1.to_i, $2.to_i, $3.to_i, $4.to_i]
|
373
|
+
when /\A\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\z/
|
374
|
+
#4個の数列形式
|
375
|
+
return [$1.to_i, $2.to_i, $3.to_i, $4.to_i]
|
376
|
+
when /\A\#([\da-fA-F]{8})\z/
|
377
|
+
#HTML形式(#RRGGBBAA)
|
378
|
+
return [$1[0,2].hex, $1[2,2].hex, $1[4,2].hex, $1[6,2].hex]
|
379
|
+
when /\A\[\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\]\z/
|
380
|
+
#3要素の配列形式
|
381
|
+
return [$1.to_i, $2.to_i, $3.to_i, 255]
|
382
|
+
when /\A\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\z/
|
383
|
+
#3個の数列方式
|
384
|
+
[$1.to_i, $2.to_i, $3.to_i, 255]
|
385
|
+
when /\A\#([\da-fA-F]{6})\z/
|
386
|
+
#HTML形式(#RRGGBB)
|
387
|
+
return [$1[0,2].hex, $1[2,2].hex, $1[4,2].hex, 255]
|
388
|
+
else return self.to_sym.to_miyako_color
|
389
|
+
end
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
393
|
+
class Symbol
|
394
|
+
def to_miyako_color #:nodoc:
|
395
|
+
return Miyako::Color[self]
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
class Integer
|
400
|
+
def to_miyako_color #:nodoc:
|
401
|
+
return [(self >> 16) & 0xff, (self >> 8) & 0xff, self & 0xff, (self >> 24) & 0xff]
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
class Array
|
406
|
+
def to_miyako_color #:nodoc:
|
407
|
+
raise Miyako::MiyakoError, "Color Array needs more than 3 elements : #{self.length} elements" if self.length < 3
|
408
|
+
return (self[0,3] << 255) if self.length == 3
|
409
|
+
return self[0,4]
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
413
|
+
=begin rdoc
|
414
|
+
==1個のインスタンスでイテレータを実装できるモジュール
|
415
|
+
=end
|
416
|
+
module SingleEnumerable
|
417
|
+
include Enumerable
|
418
|
+
|
419
|
+
#===ブロックの処理を実行する
|
420
|
+
#返却値:: 自分自身を返す
|
421
|
+
def each
|
422
|
+
yield self
|
423
|
+
return self
|
424
|
+
end
|
425
|
+
|
426
|
+
#===sizeメソッドと同様
|
427
|
+
#返却値:: sizeメソッドと同様
|
428
|
+
def length
|
429
|
+
return 1
|
430
|
+
end
|
431
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
=begin
|
3
|
+
--
|
4
|
+
Miyako 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
|
+
++
|
21
|
+
=end
|
22
|
+
|
23
|
+
# ビットマップ関連クラス群
|
24
|
+
module Miyako
|
25
|
+
#==ビットマップ(画像)管理クラス
|
26
|
+
#SDLのSurfaceクラスインスタンスを管理するクラス
|
27
|
+
class Bitmap
|
28
|
+
def Bitmap.create(w, h, flag=SDL::HWSURFACE | SDL::SRCCOLORKEY | SDL::SRCALPHA) #:nodoc:
|
29
|
+
return SDL::Surface.new(flag, w, h, $miyako_bpp, Screen.screen.Rmask, Screen.screen.Gmask, Screen.screen.Bmask, Screen.screen.Amask)
|
30
|
+
end
|
31
|
+
def Bitmap.load(filename) #:nodoc:
|
32
|
+
return SDL::Surface.load(filename)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|