ruby-miyako 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1115 -0
- data/Rakefile +7 -0
- data/defines.h +144 -0
- data/extconf.rb +44 -0
- data/extern.h +29 -0
- data/img/cursor.png +0 -0
- data/img/cursors.png +0 -0
- data/img/dice.png +0 -0
- data/img/wait_cursor.png +0 -0
- data/img/win_base.png +0 -0
- data/img/window.png +0 -0
- data/install_miyako.rb +87 -0
- data/lib/Miyako/API/audio.rb +584 -0
- data/lib/Miyako/API/basic_data.rb +1026 -0
- data/lib/Miyako/API/bitmap.rb +534 -0
- data/lib/Miyako/API/choices.rb +481 -0
- data/lib/Miyako/API/collision.rb +638 -0
- data/lib/Miyako/API/diagram.rb +586 -0
- data/lib/Miyako/API/drawing.rb +151 -0
- data/lib/Miyako/API/exceptions.rb +105 -0
- data/lib/Miyako/API/fixedmap.rb +462 -0
- data/lib/Miyako/API/font.rb +430 -0
- data/lib/Miyako/API/input.rb +456 -0
- data/lib/Miyako/API/layout.rb +644 -0
- data/lib/Miyako/API/map.rb +583 -0
- data/lib/Miyako/API/map_event.rb +222 -0
- data/lib/Miyako/API/modules.rb +357 -0
- data/lib/Miyako/API/movie.rb +166 -0
- data/lib/Miyako/API/parts.rb +188 -0
- data/lib/Miyako/API/plane.rb +205 -0
- data/lib/Miyako/API/screen.rb +341 -0
- data/lib/Miyako/API/shape.rb +443 -0
- data/lib/Miyako/API/sprite.rb +773 -0
- data/lib/Miyako/API/sprite_animation.rb +494 -0
- data/lib/Miyako/API/sprite_list.rb +1135 -0
- data/lib/Miyako/API/spriteunit.rb +168 -0
- data/lib/Miyako/API/story.rb +350 -0
- data/lib/Miyako/API/textbox.rb +773 -0
- data/lib/Miyako/API/utility.rb +419 -0
- data/lib/Miyako/API/viewport.rb +190 -0
- data/lib/Miyako/API/yuki.rb +1180 -0
- data/lib/Miyako/EXT/miyako_cairo.rb +62 -0
- data/lib/Miyako/EXT/raster_scroll.rb +138 -0
- data/lib/Miyako/EXT/slides.rb +157 -0
- data/lib/Miyako/miyako.rb +201 -0
- data/lib/Miyako/miyako_require_only.rb +35 -0
- data/logo/EGSR_logo.png +0 -0
- data/logo/EGSR_logo_bg.png +0 -0
- data/logo/EGSR_logo_fg.png +0 -0
- data/logo/EGSR_title_banner.png +0 -0
- data/logo/EGSR_title_logo.png +0 -0
- data/logo/miyako.png +0 -0
- data/logo/miyako_banner.png +0 -0
- data/logo/space.png +0 -0
- data/miyako_basicdata.c +484 -0
- data/miyako_bitmap.c +1225 -0
- data/miyako_collision.c +403 -0
- data/miyako_drawing.c +187 -0
- data/miyako_font.c +334 -0
- data/miyako_hsv.c +830 -0
- data/miyako_input_audio.c +254 -0
- data/miyako_layout.c +191 -0
- data/miyako_no_katana.c +1086 -0
- data/miyako_sprite2.c +431 -0
- data/miyako_transform.c +438 -0
- data/miyako_utility.c +288 -0
- data/sample/Animation1/m1ku.rb +68 -0
- data/sample/Animation1/m1ku_arm_0.png +0 -0
- data/sample/Animation1/m1ku_arm_1.png +0 -0
- data/sample/Animation1/m1ku_arm_2.png +0 -0
- data/sample/Animation1/m1ku_arm_3.png +0 -0
- data/sample/Animation1/m1ku_back.jpg +0 -0
- data/sample/Animation1/m1ku_body.png +0 -0
- data/sample/Animation1/m1ku_eye_0.png +0 -0
- data/sample/Animation1/m1ku_eye_1.png +0 -0
- data/sample/Animation1/m1ku_eye_2.png +0 -0
- data/sample/Animation1/m1ku_eye_3.png +0 -0
- data/sample/Animation1/m1ku_hair_front.png +0 -0
- data/sample/Animation1/m1ku_hair_rear.png +0 -0
- data/sample/Animation1/readme.txt +72 -0
- data/sample/Animation2/lex.rb +96 -0
- data/sample/Animation2/lex_back.png +0 -0
- data/sample/Animation2/lex_body.png +0 -0
- data/sample/Animation2/lex_roadroller.png +0 -0
- data/sample/Animation2/lex_wheel_0.png +0 -0
- data/sample/Animation2/lex_wheel_1.png +0 -0
- data/sample/Animation2/lex_wheel_2.png +0 -0
- data/sample/Animation2/readme.txt +72 -0
- data/sample/Animation2/song_title.png +0 -0
- data/sample/Diagram_sample/back.png +0 -0
- data/sample/Diagram_sample/chr01.png +0 -0
- data/sample/Diagram_sample/chr02.png +0 -0
- data/sample/Diagram_sample/cursor.png +0 -0
- data/sample/Diagram_sample/diagram_sample_yuki2.rb +329 -0
- data/sample/Diagram_sample/readme.txt +90 -0
- data/sample/Diagram_sample/wait_cursor.png +0 -0
- data/sample/Room3/blue.rb +297 -0
- data/sample/Room3/ending.rb +180 -0
- data/sample/Room3/green.rb +220 -0
- data/sample/Room3/image/akamatsu.png +0 -0
- data/sample/Room3/image/aoyama.png +0 -0
- data/sample/Room3/image/congra.png +0 -0
- data/sample/Room3/image/congratulation.png +0 -0
- data/sample/Room3/image/congratulation_bg.png +0 -0
- data/sample/Room3/image/cursor.png +0 -0
- data/sample/Room3/image/midori.png +0 -0
- data/sample/Room3/image/mittsu_no_oheya.png +0 -0
- data/sample/Room3/image/mittsu_no_oheya_logo.png +0 -0
- data/sample/Room3/image/room_blue.png +0 -0
- data/sample/Room3/image/room_green.png +0 -0
- data/sample/Room3/image/room_red.png +0 -0
- data/sample/Room3/image/start.png +0 -0
- data/sample/Room3/image/three_doors.png +0 -0
- data/sample/Room3/image/wait_cursor.png +0 -0
- data/sample/Room3/main.rb +120 -0
- data/sample/Room3/main_component.rb +59 -0
- data/sample/Room3/readme.txt +76 -0
- data/sample/Room3/red.rb +227 -0
- data/sample/Room3/room3.rb +25 -0
- data/sample/Room3/title.rb +184 -0
- data/sample/ball_action_sample.rb +204 -0
- data/sample/blit_rop.rb +70 -0
- data/sample/cairo_sample.rb +25 -0
- data/sample/circle_collision_test.rb +66 -0
- data/sample/collision_test.rb +33 -0
- data/sample/collision_test2.rb +108 -0
- data/sample/fixed_map_test/cursor.png +0 -0
- data/sample/fixed_map_test/fixed_map_sample.rb +140 -0
- data/sample/fixed_map_test/map.csv +19 -0
- data/sample/fixed_map_test/map_01.png +0 -0
- data/sample/fixed_map_test/mapchip.csv +23 -0
- data/sample/fixed_map_test/monster.png +0 -0
- data/sample/fixed_map_test/readme.txt +72 -0
- data/sample/map_test/chara.rb +58 -0
- data/sample/map_test/chr1.png +0 -0
- data/sample/map_test/cursor.png +0 -0
- data/sample/map_test/main_parts.rb +69 -0
- data/sample/map_test/main_scene.rb +153 -0
- data/sample/map_test/map.png +0 -0
- data/sample/map_test/map2.png +0 -0
- data/sample/map_test/map_layer.csv +127 -0
- data/sample/map_test/map_manager.rb +75 -0
- data/sample/map_test/map_test.rb +23 -0
- data/sample/map_test/mapchip.csv +21 -0
- data/sample/map_test/oasis.rb +71 -0
- data/sample/map_test/readme.txt +89 -0
- data/sample/map_test/route.rb +157 -0
- data/sample/map_test/sea.png +0 -0
- data/sample/map_test/town.rb +74 -0
- data/sample/map_test/wait_cursor.png +0 -0
- data/sample/map_test/window.png +0 -0
- data/sample/polygon_test.rb +35 -0
- data/sample/rasterscroll.rb +25 -0
- data/sample/takahashi.rb +42 -0
- data/sample/text.png +0 -0
- data/sample/textbox_sample.rb +192 -0
- data/sample/transform.rb +54 -0
- data/sample/utility_test.rb +73 -0
- data/sample/utility_test2.rb +61 -0
- data/sample/utility_test3.rb +64 -0
- data/sample/utility_test4.rb +73 -0
- data/uninstall_miyako.rb +19 -0
- data/win/miyako_no_katana.so +0 -0
- metadata +216 -0
data/miyako_utility.c
ADDED
@@ -0,0 +1,288 @@
|
|
1
|
+
/*
|
2
|
+
--
|
3
|
+
Miyako v2.0 Extend Library "Miyako no Katana"
|
4
|
+
Copyright (C) 2008 Cyross Makoto
|
5
|
+
|
6
|
+
This library is free software; you can redistribute it and/or
|
7
|
+
modify it under the terms of the GNU Lesser General Public
|
8
|
+
License as published by the Free Software Foundation; either
|
9
|
+
version 2.1 of the License, or (at your option) any later version.
|
10
|
+
|
11
|
+
This library is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
Lesser General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU Lesser General Public
|
17
|
+
License along with this library; if not, write to the Free Software
|
18
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19
|
+
++
|
20
|
+
*/
|
21
|
+
|
22
|
+
/*
|
23
|
+
=拡張ライブラリmiyako_no_katana
|
24
|
+
Authors:: サイロス誠
|
25
|
+
Version:: 2.0
|
26
|
+
Copyright:: 2007-2008 Cyross Makoto
|
27
|
+
License:: LGPL2.1
|
28
|
+
*/
|
29
|
+
#include "defines.h"
|
30
|
+
|
31
|
+
static VALUE mSDL = Qnil;
|
32
|
+
static VALUE mMiyako = Qnil;
|
33
|
+
static VALUE eMiyakoError = Qnil;
|
34
|
+
static VALUE cSurface = Qnil;
|
35
|
+
static VALUE sSpriteUnit = Qnil;
|
36
|
+
|
37
|
+
// from rubysdl_video.c
|
38
|
+
static GLOBAL_DEFINE_GET_STRUCT(Surface, GetSurface, cSurface, "SDL::Surface");
|
39
|
+
|
40
|
+
void _miyako_yield_unit_1(MiyakoBitmap *src)
|
41
|
+
{
|
42
|
+
if(rb_block_given_p() == Qtrue){ src->unit = rb_obj_dup(src->unit); rb_yield(src->unit); }
|
43
|
+
}
|
44
|
+
|
45
|
+
void _miyako_yield_unit_2(MiyakoBitmap *src, MiyakoBitmap *dst)
|
46
|
+
{
|
47
|
+
if(rb_block_given_p() == Qtrue)
|
48
|
+
{
|
49
|
+
src->unit = rb_obj_dup(src->unit);
|
50
|
+
dst->unit = rb_obj_dup(dst->unit);
|
51
|
+
rb_yield_values(2, src->unit, dst->unit);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
void _miyako_setup_unit(VALUE unit, SDL_Surface *screen, MiyakoBitmap *mb, VALUE x, VALUE y, int use_yield)
|
56
|
+
{
|
57
|
+
mb->unit = unit;
|
58
|
+
if(rb_obj_is_kind_of(mb->unit, sSpriteUnit) == Qfalse){
|
59
|
+
mb->unit = rb_funcall(mb->unit, rb_intern("to_unit"), 0);
|
60
|
+
if(mb->unit == Qnil){ rb_raise(eMiyakoError, "Source instance has not SpriteUnit!"); }
|
61
|
+
}
|
62
|
+
|
63
|
+
if(use_yield) _miyako_yield_unit_1(mb);
|
64
|
+
|
65
|
+
mb->rect.x = NUM2INT(*(RSTRUCT_PTR(mb->unit) + 1));
|
66
|
+
mb->rect.y = NUM2INT(*(RSTRUCT_PTR(mb->unit) + 2));
|
67
|
+
mb->rect.w = NUM2INT(*(RSTRUCT_PTR(mb->unit) + 3));
|
68
|
+
mb->rect.h = NUM2INT(*(RSTRUCT_PTR(mb->unit) + 4));
|
69
|
+
|
70
|
+
mb->surface = GetSurface(*(RSTRUCT_PTR(mb->unit)))->surface;
|
71
|
+
mb->ptr = (Uint32 *)(mb->surface->pixels);
|
72
|
+
mb->fmt = mb->surface->format;
|
73
|
+
|
74
|
+
// adjust clip_rect
|
75
|
+
if(mb->surface == screen)
|
76
|
+
{
|
77
|
+
SDL_Rect *crect = &(mb->surface->clip_rect);
|
78
|
+
mb->rect.x += crect->x;
|
79
|
+
if(mb->rect.x < 0){
|
80
|
+
mb->rect.w += mb->rect.x;
|
81
|
+
mb->rect.x = 0;
|
82
|
+
}
|
83
|
+
mb->rect.y += crect->y;
|
84
|
+
if(mb->rect.y < 0){
|
85
|
+
mb->rect.h += mb->rect.y;
|
86
|
+
mb->rect.y = 0;
|
87
|
+
}
|
88
|
+
if(mb->rect.w > crect->w) mb->rect.w = crect->w;
|
89
|
+
if(mb->rect.h > crect->h) mb->rect.h = crect->h;
|
90
|
+
if(mb->rect.x + mb->rect.w > mb->surface->w)
|
91
|
+
mb->rect.w = mb->surface->w - mb->rect.x;
|
92
|
+
if(mb->rect.y + mb->rect.h > mb->surface->h)
|
93
|
+
mb->rect.h = mb->surface->h - mb->rect.y;
|
94
|
+
}
|
95
|
+
|
96
|
+
mb->a255 = (mb->surface == screen) ? 0xff : 0;
|
97
|
+
|
98
|
+
mb->x = (x == Qnil ? NUM2INT(*(RSTRUCT_PTR(mb->unit) + 5)) : NUM2INT(x));
|
99
|
+
mb->y = (y == Qnil ? NUM2INT(*(RSTRUCT_PTR(mb->unit) + 6)) : NUM2INT(y));
|
100
|
+
}
|
101
|
+
|
102
|
+
void _miyako_setup_unit_2(VALUE unit_s, VALUE unit_d,
|
103
|
+
SDL_Surface *screen,
|
104
|
+
MiyakoBitmap *mb_s, MiyakoBitmap *mb_d,
|
105
|
+
VALUE x, VALUE y, int use_yield)
|
106
|
+
{
|
107
|
+
mb_s->unit = unit_s;
|
108
|
+
if(rb_obj_is_kind_of(mb_s->unit, sSpriteUnit) == Qfalse){
|
109
|
+
mb_s->unit = rb_funcall(mb_s->unit, rb_intern("to_unit"), 0);
|
110
|
+
if(mb_s->unit == Qnil){ rb_raise(eMiyakoError, "Source instance has not SpriteUnit!"); }
|
111
|
+
}
|
112
|
+
|
113
|
+
mb_d->unit = unit_d;
|
114
|
+
if(rb_obj_is_kind_of(mb_d->unit, sSpriteUnit) == Qfalse){
|
115
|
+
mb_d->unit = rb_funcall(mb_d->unit, rb_intern("to_unit"), 0);
|
116
|
+
if(mb_d->unit == Qnil){ rb_raise(eMiyakoError, "Source instance has not SpriteUnit!"); }
|
117
|
+
}
|
118
|
+
|
119
|
+
if(use_yield) _miyako_yield_unit_2(mb_s, mb_d);
|
120
|
+
|
121
|
+
mb_s->surface = GetSurface(*(RSTRUCT_PTR(mb_s->unit)))->surface;
|
122
|
+
mb_s->ptr = (Uint32 *)(mb_s->surface->pixels);
|
123
|
+
mb_s->fmt = mb_s->surface->format;
|
124
|
+
|
125
|
+
mb_s->rect.x = NUM2INT(*(RSTRUCT_PTR(mb_s->unit) + 1));
|
126
|
+
mb_s->rect.y = NUM2INT(*(RSTRUCT_PTR(mb_s->unit) + 2));
|
127
|
+
mb_s->rect.w = NUM2INT(*(RSTRUCT_PTR(mb_s->unit) + 3));
|
128
|
+
mb_s->rect.h = NUM2INT(*(RSTRUCT_PTR(mb_s->unit) + 4));
|
129
|
+
|
130
|
+
// adjust clip_rect
|
131
|
+
if(mb_s->surface == screen)
|
132
|
+
{
|
133
|
+
SDL_Rect *crect = &(mb_s->surface->clip_rect);
|
134
|
+
mb_s->rect.x += crect->x;
|
135
|
+
if(mb_s->rect.x < 0){
|
136
|
+
mb_s->rect.w += mb_s->rect.x;
|
137
|
+
mb_s->rect.x = 0;
|
138
|
+
}
|
139
|
+
mb_s->rect.y += crect->y;
|
140
|
+
if(mb_s->rect.y < 0){
|
141
|
+
mb_s->rect.h += mb_s->rect.y;
|
142
|
+
mb_s->rect.y = 0;
|
143
|
+
}
|
144
|
+
if(mb_s->rect.w > crect->w) mb_s->rect.w = crect->w;
|
145
|
+
if(mb_s->rect.h > crect->h) mb_s->rect.h = crect->h;
|
146
|
+
if(mb_s->rect.x + mb_s->rect.w > mb_s->surface->w)
|
147
|
+
mb_s->rect.w = mb_s->surface->w - mb_s->rect.x;
|
148
|
+
if(mb_s->rect.y + mb_s->rect.h > mb_s->surface->h)
|
149
|
+
mb_s->rect.h = mb_s->surface->h - mb_s->rect.y;
|
150
|
+
}
|
151
|
+
|
152
|
+
mb_s->a255 = (mb_s->surface == screen) ? 0xff : 0;
|
153
|
+
|
154
|
+
mb_s->x = (x == Qnil ? NUM2INT(*(RSTRUCT_PTR(mb_s->unit) + 5)) : NUM2INT(x));
|
155
|
+
mb_s->y = (y == Qnil ? NUM2INT(*(RSTRUCT_PTR(mb_s->unit) + 6)) : NUM2INT(y));
|
156
|
+
|
157
|
+
mb_d->surface = GetSurface(*(RSTRUCT_PTR(mb_d->unit)))->surface;
|
158
|
+
mb_d->ptr = (Uint32 *)(mb_d->surface->pixels);
|
159
|
+
mb_d->fmt = mb_d->surface->format;
|
160
|
+
|
161
|
+
mb_d->rect.x = NUM2INT(*(RSTRUCT_PTR(mb_d->unit) + 1));
|
162
|
+
mb_d->rect.y = NUM2INT(*(RSTRUCT_PTR(mb_d->unit) + 2));
|
163
|
+
mb_d->rect.w = NUM2INT(*(RSTRUCT_PTR(mb_d->unit) + 3));
|
164
|
+
mb_d->rect.h = NUM2INT(*(RSTRUCT_PTR(mb_d->unit) + 4));
|
165
|
+
|
166
|
+
// adjust clip_rect
|
167
|
+
if(mb_d->surface == screen)
|
168
|
+
{
|
169
|
+
SDL_Rect *crect = &(mb_d->surface->clip_rect);
|
170
|
+
mb_d->rect.x += crect->x;
|
171
|
+
if(mb_d->rect.x < 0){
|
172
|
+
mb_d->rect.w += mb_d->rect.x;
|
173
|
+
mb_d->rect.x = 0;
|
174
|
+
}
|
175
|
+
mb_d->rect.y += crect->y;
|
176
|
+
if(mb_d->rect.y < 0){
|
177
|
+
mb_d->rect.h += mb_d->rect.y;
|
178
|
+
mb_d->rect.y = 0;
|
179
|
+
}
|
180
|
+
if(mb_d->rect.w > crect->w) mb_d->rect.w = crect->w;
|
181
|
+
if(mb_d->rect.h > crect->h) mb_d->rect.h = crect->h;
|
182
|
+
if(mb_d->rect.x + mb_d->rect.w > mb_d->surface->w)
|
183
|
+
mb_d->rect.w = mb_d->surface->w - mb_d->rect.x;
|
184
|
+
if(mb_d->rect.y + mb_d->rect.h > mb_d->surface->h)
|
185
|
+
mb_d->rect.h = mb_d->surface->h - mb_d->rect.y;
|
186
|
+
}
|
187
|
+
|
188
|
+
mb_d->a255 = (mb_d->surface == screen) ? 0xff : 0;
|
189
|
+
|
190
|
+
mb_d->x = NUM2INT(*(RSTRUCT_PTR(mb_d->unit) + 5));
|
191
|
+
mb_d->y = NUM2INT(*(RSTRUCT_PTR(mb_d->unit) + 6));
|
192
|
+
}
|
193
|
+
|
194
|
+
int _miyako_init_rect(MiyakoBitmap *src, MiyakoBitmap *dst, MiyakoSize *size)
|
195
|
+
{
|
196
|
+
int sw = src->rect.w;
|
197
|
+
int sh = src->rect.h;
|
198
|
+
int dw = dst->rect.w;
|
199
|
+
int dh = dst->rect.h;
|
200
|
+
|
201
|
+
// ox(oy)が画像のw(h)以上の時は転送不可
|
202
|
+
|
203
|
+
if(src->rect.x >= src->surface->w || src->rect.y >= src->surface->h) return 0;
|
204
|
+
if(dst->rect.x >= dst->surface->w || dst->rect.y >= dst->surface->h) return 0;
|
205
|
+
|
206
|
+
// ox(oy)がマイナスの時は、ow(oh)を減らしておいて、ox, oyをゼロにしておく
|
207
|
+
// 0以下になったら転送不可
|
208
|
+
|
209
|
+
if(src->rect.x < 0){
|
210
|
+
sw += src->rect.x;
|
211
|
+
src->rect.x = 0;
|
212
|
+
if(sw <= 0) return 0;
|
213
|
+
}
|
214
|
+
if(src->rect.y < 0){
|
215
|
+
sh += src->rect.y;
|
216
|
+
src->rect.y = 0;
|
217
|
+
if(sh <= 0) return 0;
|
218
|
+
}
|
219
|
+
if(dst->rect.x < 0){
|
220
|
+
dw += dst->rect.x;
|
221
|
+
dst->rect.x = 0;
|
222
|
+
if(dw <= 0) return 0;
|
223
|
+
}
|
224
|
+
if(dst->rect.y < 0){
|
225
|
+
dh += dst->rect.y;
|
226
|
+
dst->rect.y = 0;
|
227
|
+
if(dh <= 0) return 0;
|
228
|
+
}
|
229
|
+
|
230
|
+
// ox(oy)+ow(oh)が、w(h)を越える場合は、ow(oh)を減らしておく
|
231
|
+
// 0以下になったら転送不可
|
232
|
+
|
233
|
+
if(src->rect.x + sw > src->surface->w)
|
234
|
+
{
|
235
|
+
sw += (src->surface->w - src->rect.x - sw);
|
236
|
+
if(sw <= 0) return 0;
|
237
|
+
}
|
238
|
+
if(src->rect.y + sh > src->surface->h)
|
239
|
+
{
|
240
|
+
sh += (src->surface->h - src->rect.y - sh);
|
241
|
+
if(sh <= 0) return 0;
|
242
|
+
}
|
243
|
+
if(dst->rect.x + dw > dst->surface->w)
|
244
|
+
{
|
245
|
+
dw += (dst->surface->w - dst->rect.x - dw);
|
246
|
+
if(dw <= 0) return 0;
|
247
|
+
}
|
248
|
+
if(dst->rect.y + dh > dst->surface->h)
|
249
|
+
{
|
250
|
+
dh += (dst->surface->h - dst->rect.y - dh);
|
251
|
+
if(dh <= 0) return 0;
|
252
|
+
}
|
253
|
+
|
254
|
+
// ox(oy)が画像のw(h)以上、-w(-h)以下の時は転送不可
|
255
|
+
|
256
|
+
if(src->x >= dw || src->x <= -dw) return 0;
|
257
|
+
if(src->y >= dh || src->y <= -dh) return 0;
|
258
|
+
|
259
|
+
// x(y)がマイナスの時は、ow(oh)を減らしておいて、x, yをゼロにしておく
|
260
|
+
// 0以下になったら転送不可
|
261
|
+
|
262
|
+
if(src->x < 0){
|
263
|
+
dw += src->x;
|
264
|
+
src->x = 0;
|
265
|
+
}
|
266
|
+
else{ dw -= src->x; }
|
267
|
+
if(dw <= 0) return 0;
|
268
|
+
if(src->y < 0){
|
269
|
+
dh += src->y;
|
270
|
+
src->y = 0;
|
271
|
+
}
|
272
|
+
else{ dh -= src->y; }
|
273
|
+
if(dh <= 0) return 0;
|
274
|
+
|
275
|
+
size->w = (dw > sw ? sw : dw);
|
276
|
+
size->h = (dh > sh ? sh : dh);
|
277
|
+
|
278
|
+
return 1;
|
279
|
+
}
|
280
|
+
|
281
|
+
void Init_miyako_utility()
|
282
|
+
{
|
283
|
+
mSDL = rb_define_module("SDL");
|
284
|
+
mMiyako = rb_define_module("Miyako");
|
285
|
+
eMiyakoError = rb_define_class_under(mMiyako, "MiyakoError", rb_eException);
|
286
|
+
cSurface = rb_define_class_under(mSDL, "Surface", rb_cObject);
|
287
|
+
sSpriteUnit = rb_define_class_under(mMiyako, "SpriteUnitBase", rb_cStruct);
|
288
|
+
}
|
@@ -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
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,72 @@
|
|
1
|
+
*******************************************************************************
|
2
|
+
�y ��Җ� �z�@�T�C���X��
|
3
|
+
�y �\�t�g�� �z�@Miyako v2.0�T���v��(�A�j���[�V�����P)
|
4
|
+
�y �o�[�W���� �z�@2.0
|
5
|
+
�y �쐬�� �z�@2009/04/13
|
6
|
+
�y ��� �z�@�t���[�E�F�A
|
7
|
+
�y �J������ �z�@Ruby 1.9.1-p0
|
8
|
+
�y �����^�C�� �z�@Miyako v2.0
|
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 v2.0�ȍ~�ɑΉ�����AMiyako�T���v���v���O�����ł��B
|
19
|
+
�@�ǂ����Ō������Ƃ���悤�Ȗ����悤�ȃL�����N�^�[���A����l�M��U���Ă��܂��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 m1ku.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,96 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#! /usr/bin/ruby
|
3
|
+
# Lex sample for Miyako v2.0
|
4
|
+
# 2008.11.24 Cyross Makoto
|
5
|
+
|
6
|
+
require 'Miyako/miyako'
|
7
|
+
|
8
|
+
include Miyako
|
9
|
+
|
10
|
+
def create_wheel(num)
|
11
|
+
spr = Sprite.new({:file=>sprintf("lex_wheel_#{num}.png"), :type=>:ck})
|
12
|
+
spr.move_to!(317, 331)
|
13
|
+
return spr
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
back = Plane.new({:file=>sprintf("lex_back.png"), :type=>:as})
|
18
|
+
back_timer = WaitCounter.new(0.1)
|
19
|
+
|
20
|
+
title = Sprite.new({:file=>sprintf("song_title.png"), :type=>:ck})
|
21
|
+
pos = Screen.h
|
22
|
+
upper = 24
|
23
|
+
x = 24
|
24
|
+
title.move_to!(x, pos)
|
25
|
+
title_timer = WaitCounter.new(2)
|
26
|
+
interval = 8
|
27
|
+
mode = 0
|
28
|
+
|
29
|
+
len_body = Sprite.new({:file=>sprintf("lex_body.png"), :type=>:ck})
|
30
|
+
len_body.move_to!(425, 219)
|
31
|
+
|
32
|
+
len_anim_param = {
|
33
|
+
:sprite => len_body,
|
34
|
+
:wait => 0.1,
|
35
|
+
:move_offset => [[0,0], [0,-1], [0,0], [0,1]]
|
36
|
+
}
|
37
|
+
len_anim = SpriteAnimation.new(len_anim_param)
|
38
|
+
len_anim.start
|
39
|
+
|
40
|
+
road_roller = Sprite.new({:file=>sprintf("lex_roadroller.png"), :type=>:ck})
|
41
|
+
road_roller.move_to!(310, 180)
|
42
|
+
|
43
|
+
rr_anim_param = {
|
44
|
+
:sprite => road_roller,
|
45
|
+
:wait => 0.1,
|
46
|
+
:move_offset => [[0,0], [0,1], [0,0], [0,-1]]
|
47
|
+
}
|
48
|
+
rr_anim = SpriteAnimation.new(rr_anim_param)
|
49
|
+
rr_anim.start
|
50
|
+
|
51
|
+
wheels = Array.new
|
52
|
+
(0..2).each{|n| wheels.push(create_wheel(n)) }
|
53
|
+
wheel_anim_param = {
|
54
|
+
:sprite => wheels,
|
55
|
+
:wait => 0.1,
|
56
|
+
:pattern_list => [0, 1, 2, 1]
|
57
|
+
}
|
58
|
+
wheel_anim = SpriteAnimation.new(wheel_anim_param)
|
59
|
+
wheel_anim.start
|
60
|
+
|
61
|
+
back_timer.start
|
62
|
+
title_timer.start
|
63
|
+
Miyako.main_loop do
|
64
|
+
break if Input.quit_or_escape?
|
65
|
+
len_anim.update_animation
|
66
|
+
rr_anim.update_animation
|
67
|
+
wheel_anim.update_animation
|
68
|
+
if back_timer.finish?
|
69
|
+
back.move!(-2, 0)
|
70
|
+
back_timer.start
|
71
|
+
end
|
72
|
+
if title_timer.finish?
|
73
|
+
case mode
|
74
|
+
when 0
|
75
|
+
mode = 1
|
76
|
+
title_timer = WaitCounter.new(0.1)
|
77
|
+
title_timer.start
|
78
|
+
when 1
|
79
|
+
pos -= interval
|
80
|
+
if pos <= upper
|
81
|
+
pos = upper
|
82
|
+
mode = 2
|
83
|
+
else
|
84
|
+
title_timer.start
|
85
|
+
end
|
86
|
+
title.move_to!(x, pos)
|
87
|
+
when 2
|
88
|
+
# no operation
|
89
|
+
end
|
90
|
+
end
|
91
|
+
back.render
|
92
|
+
wheel_anim.render
|
93
|
+
len_anim.render
|
94
|
+
rr_anim.render
|
95
|
+
title.render if mode > 0
|
96
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,72 @@
|
|
1
|
+
*******************************************************************************
|
2
|
+
�y ��Җ� �z�@�T�C���X��
|
3
|
+
�y �\�t�g�� �z�@Miyako v2.0�T���v��(�A�j���[�V�����Q)
|
4
|
+
�y �o�[�W���� �z�@2.0
|
5
|
+
�y �쐬�� �z�@2009/04/13
|
6
|
+
�y ��� �z�@�t���[�E�F�A
|
7
|
+
�y �J������ �z�@Ruby 1.9.1-p0
|
8
|
+
�y �����^�C�� �z�@Miyako v2.0
|
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 v2.0�ȍ~�ɑΉ�����AMiyako�T���v���v���O�����ł��B
|
19
|
+
�@�ǂ����Ō������Ƃ���悤�Ȗ����悤�ȃL�����N�^�[���A���[�h���[���[���^�]���Ă��܂��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 lex.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.
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|