ruby-miyako 2.1.4 → 2.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README +42 -5
- data/lib/Miyako/API/choices.rb +0 -2
- data/lib/Miyako/API/collision.rb +0 -4
- data/lib/Miyako/API/fixedmap.rb +0 -3
- data/lib/Miyako/API/i_yuki.rb +28 -46
- data/lib/Miyako/API/layout.rb +0 -1
- data/lib/Miyako/API/map.rb +0 -2
- data/lib/Miyako/API/map_event.rb +0 -3
- data/lib/Miyako/API/map_struct.rb +0 -2
- data/lib/Miyako/API/parts.rb +0 -11
- data/lib/Miyako/API/screen.rb +3 -4
- data/lib/Miyako/API/shape.rb +27 -27
- data/lib/Miyako/API/sprite.rb +0 -2
- data/lib/Miyako/API/story.rb +0 -2
- data/lib/Miyako/API/textbox.rb +9 -11
- data/lib/Miyako/API/utility.rb +2 -2
- data/lib/Miyako/API/yuki.rb +19 -8
- data/lib/Miyako/miyako.rb +3 -0
- data/miyako_basicdata.c +52 -5
- data/miyako_bitmap.c +351 -342
- data/miyako_collision.c +77 -67
- data/miyako_diagram.c +22 -21
- data/miyako_drawing.c +9 -6
- data/miyako_font.c +63 -53
- data/miyako_hsv.c +428 -436
- data/miyako_input_audio.c +17 -14
- data/miyako_layout.c +23 -18
- data/miyako_no_katana.c +284 -248
- data/miyako_sprite2.c +30 -18
- data/miyako_transform.c +95 -93
- data/miyako_utility.c +9 -18
- data/miyako_yuki.c +10 -6
- data/sample/Diagram_sample/diagram_sample_yuki2.rb +2 -2
- data/sample/Room3/room3.rb +8 -10
- data/sample/ball_action_sample.rb +8 -8
- data/sample/map_test/main_scene.rb +1 -1
- data/sample/map_test/map_test.rb +8 -8
- data/sample/takahashi.rb +14 -14
- data/win/miyako_no_katana.so +0 -0
- metadata +6 -4
data/miyako_sprite2.c
CHANGED
@@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
20
20
|
*/
|
21
21
|
|
22
22
|
/*
|
23
|
-
|
24
|
-
Authors::
|
23
|
+
=miyako_no_katana
|
24
|
+
Authors:: Cyross Makoto
|
25
25
|
Version:: 2.1
|
26
26
|
Copyright:: 2007-2009 Cyross Makoto
|
27
27
|
License:: LGPL2.1
|
@@ -381,12 +381,14 @@ static VALUE sprite_list_move_to(VALUE self, VALUE x, VALUE y)
|
|
381
381
|
*/
|
382
382
|
static VALUE sprite_list_each(VALUE self)
|
383
383
|
{
|
384
|
+
int i;
|
385
|
+
VALUE array, *ptr;
|
386
|
+
|
384
387
|
RETURN_ENUMERATOR(self, 0, 0);
|
385
388
|
|
386
|
-
|
389
|
+
array = rb_iv_get(self, str_list);
|
387
390
|
|
388
|
-
|
389
|
-
VALUE *ptr = RARRAY_PTR(array);
|
391
|
+
ptr = RARRAY_PTR(array);
|
390
392
|
for(i=0; i<RARRAY_LEN(array); i++)
|
391
393
|
rb_yield_values(1, *(ptr+i));
|
392
394
|
|
@@ -398,12 +400,14 @@ static VALUE sprite_list_each(VALUE self)
|
|
398
400
|
*/
|
399
401
|
static VALUE sprite_list_each_pair(VALUE self)
|
400
402
|
{
|
403
|
+
int i;
|
404
|
+
VALUE array, *ptr;
|
405
|
+
|
401
406
|
RETURN_ENUMERATOR(self, 0, 0);
|
402
407
|
|
403
|
-
|
408
|
+
array = rb_iv_get(self, str_list);
|
404
409
|
|
405
|
-
|
406
|
-
VALUE *ptr = RARRAY_PTR(array);
|
410
|
+
ptr = RARRAY_PTR(array);
|
407
411
|
for(i=0; i<RARRAY_LEN(array); i++)
|
408
412
|
{
|
409
413
|
VALUE *sptr = RSTRUCT_PTR(*(ptr+i));
|
@@ -418,12 +422,14 @@ static VALUE sprite_list_each_pair(VALUE self)
|
|
418
422
|
*/
|
419
423
|
static VALUE sprite_list_each_name(VALUE self)
|
420
424
|
{
|
425
|
+
int i;
|
426
|
+
VALUE array, *ptr;
|
427
|
+
|
421
428
|
RETURN_ENUMERATOR(self, 0, 0);
|
422
429
|
|
423
|
-
|
430
|
+
array = rb_iv_get(self, str_list);
|
424
431
|
|
425
|
-
|
426
|
-
VALUE *ptr = RARRAY_PTR(array);
|
432
|
+
ptr = RARRAY_PTR(array);
|
427
433
|
for(i=0; i<RARRAY_LEN(array); i++)
|
428
434
|
rb_yield_values(1, *(RSTRUCT_PTR(*(ptr+i))+0));
|
429
435
|
|
@@ -435,12 +441,14 @@ static VALUE sprite_list_each_name(VALUE self)
|
|
435
441
|
*/
|
436
442
|
static VALUE sprite_list_each_value(VALUE self)
|
437
443
|
{
|
444
|
+
int i;
|
445
|
+
VALUE array, *ptr;
|
446
|
+
|
438
447
|
RETURN_ENUMERATOR(self, 0, 0);
|
439
448
|
|
440
|
-
|
449
|
+
array = rb_iv_get(self, str_list);
|
441
450
|
|
442
|
-
|
443
|
-
VALUE *ptr = RARRAY_PTR(array);
|
451
|
+
ptr = RARRAY_PTR(array);
|
444
452
|
for(i=0; i<RARRAY_LEN(array); i++)
|
445
453
|
rb_yield_values(1, *(RSTRUCT_PTR(*(ptr+i))+1));
|
446
454
|
|
@@ -452,11 +460,13 @@ static VALUE sprite_list_each_value(VALUE self)
|
|
452
460
|
*/
|
453
461
|
static VALUE sprite_list_each_index(VALUE self)
|
454
462
|
{
|
463
|
+
int i;
|
464
|
+
VALUE array;
|
465
|
+
|
455
466
|
RETURN_ENUMERATOR(self, 0, 0);
|
456
467
|
|
457
|
-
|
468
|
+
array = rb_iv_get(self, str_list);
|
458
469
|
|
459
|
-
int i;
|
460
470
|
for(i=0; i<RARRAY_LEN(array); i++)
|
461
471
|
rb_yield_values(1, INT2NUM(i));
|
462
472
|
|
@@ -551,9 +561,11 @@ VALUE _miyako_sprite_list_render(VALUE splist)
|
|
551
561
|
*/
|
552
562
|
static VALUE sprite_list_render_to(VALUE self, VALUE dst)
|
553
563
|
{
|
554
|
-
if(rb_iv_get(self, str_visible) == Qfalse) return self;
|
555
|
-
VALUE array = rb_iv_get(self, str_list);
|
556
564
|
int i;
|
565
|
+
VALUE array;
|
566
|
+
|
567
|
+
if(rb_iv_get(self, str_visible) == Qfalse) return self;
|
568
|
+
array = rb_iv_get(self, str_list);
|
557
569
|
for(i=0; i<RARRAY_LEN(array); i++)
|
558
570
|
{
|
559
571
|
VALUE pair = *(RARRAY_PTR(array)+i);
|
data/miyako_transform.c
CHANGED
@@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
20
20
|
*/
|
21
21
|
|
22
22
|
/*
|
23
|
-
|
24
|
-
Authors::
|
23
|
+
=miyako_no_katana
|
24
|
+
Authors:: Cyross Makoto
|
25
25
|
Version:: 2.0
|
26
26
|
Copyright:: 2007-2008 Cyross Makoto
|
27
27
|
License:: LGPL2.1
|
@@ -48,13 +48,16 @@ static volatile int one = Qnil;
|
|
48
48
|
static GLOBAL_DEFINE_GET_STRUCT(Surface, GetSurface, cSurface, "SDL::Surface");
|
49
49
|
|
50
50
|
/*
|
51
|
-
画像を回転させて貼り付ける
|
52
51
|
*/
|
53
52
|
static VALUE bitmap_miyako_rotate(VALUE self, VALUE vsrc, VALUE vdst, VALUE radian)
|
54
53
|
{
|
55
54
|
MiyakoBitmap src, dst;
|
56
55
|
MiyakoSize size;
|
57
56
|
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
57
|
+
double rad;
|
58
|
+
long isin, icos;
|
59
|
+
int x, y, a1, a2, nx, ny, px, py, pr, pb, qx, qy, qr, qb;
|
60
|
+
Uint32 sr, sg, sb, sa, dr, dg, db, da, *tp, *psrc;
|
58
61
|
|
59
62
|
_miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
|
60
63
|
|
@@ -65,37 +68,34 @@ static VALUE bitmap_miyako_rotate(VALUE self, VALUE vsrc, VALUE vdst, VALUE radi
|
|
65
68
|
|
66
69
|
if(dst.rect.w >= 32768 || dst.rect.h >= 32768){ return Qnil; }
|
67
70
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
Uint32 sr, sg, sb, sa;
|
81
|
-
Uint32 dr, dg, db, da;
|
71
|
+
rad = NUM2DBL(radian) * -1.0;
|
72
|
+
isin = (long)(sin(rad)*4096.0);
|
73
|
+
icos = (long)(cos(rad)*4096.0);
|
74
|
+
|
75
|
+
px = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+7)));
|
76
|
+
py = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+8)));
|
77
|
+
pr = src.rect.w + px;
|
78
|
+
pb = src.rect.h + py;
|
79
|
+
qx = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+7)));
|
80
|
+
qy = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+8)));
|
81
|
+
qr = dst.rect.w + qx;
|
82
|
+
qb = dst.rect.h + qy;
|
82
83
|
|
83
84
|
SDL_LockSurface(src.surface);
|
84
85
|
SDL_LockSurface(dst.surface);
|
85
86
|
|
86
|
-
int x, y;
|
87
87
|
for(y = qy; y < qb; y++)
|
88
88
|
{
|
89
|
-
|
89
|
+
tp = dst.ptr + (dst.rect.y + y - qy) * dst.surface->w + dst.rect.x;
|
90
90
|
for(x = qx; x < qr; x++)
|
91
91
|
{
|
92
|
-
|
92
|
+
nx = (x*icos-y*isin) >> 12;
|
93
93
|
if(nx < px || nx >= pr){ tp++; continue; }
|
94
|
-
|
94
|
+
ny = (x*isin+y*icos) >> 12;
|
95
95
|
if(ny < py || ny >= pb){ tp++; continue; }
|
96
96
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
97
97
|
da = (*tp >> 24) | dst.a255;
|
98
|
-
|
98
|
+
psrc = src.ptr + (src.rect.x + ny - py) * src.surface->w + src.rect.x + nx - px;
|
99
99
|
sa = (*psrc >> 24) | src.a255;
|
100
100
|
if(sa == 0){ tp++; continue; }
|
101
101
|
if(da == 0 || sa == 255)
|
@@ -104,8 +104,8 @@ static VALUE bitmap_miyako_rotate(VALUE self, VALUE vsrc, VALUE vdst, VALUE radi
|
|
104
104
|
tp++;
|
105
105
|
continue;
|
106
106
|
}
|
107
|
-
|
108
|
-
|
107
|
+
a1 = sa + 1;
|
108
|
+
a2 = 256 - sa;
|
109
109
|
dr = *tp & 0xff0000;
|
110
110
|
dg = *tp & 0xff00;
|
111
111
|
db = *tp & 0xff;
|
@@ -121,7 +121,7 @@ static VALUE bitmap_miyako_rotate(VALUE self, VALUE vsrc, VALUE vdst, VALUE radi
|
|
121
121
|
dg = (*tp & dst.fmt->Gmask) >> dst.fmt->Gshift;
|
122
122
|
db = (*tp & dst.fmt->Bmask) >> dst.fmt->Bshift;
|
123
123
|
da = (*tp & dst.fmt->Amask) | dst.a255;
|
124
|
-
|
124
|
+
psrc = src.ptr + (src.rect.x + ny - py) * src.surface->w + src.rect.x + nx - px;
|
125
125
|
sa = (*psrc & src.fmt->Amask) | src.a255;
|
126
126
|
if(sa == 0){ tp++; continue; }
|
127
127
|
if(da == 0 || sa == 255)
|
@@ -130,8 +130,8 @@ static VALUE bitmap_miyako_rotate(VALUE self, VALUE vsrc, VALUE vdst, VALUE radi
|
|
130
130
|
tp++;
|
131
131
|
continue;
|
132
132
|
}
|
133
|
-
|
134
|
-
|
133
|
+
a1 = sa + 1;
|
134
|
+
a2 = 256 - sa;
|
135
135
|
sr = (*psrc & src.fmt->Rmask) >> src.fmt->Rshift;
|
136
136
|
sg = (*psrc & src.fmt->Gmask) >> src.fmt->Gshift;
|
137
137
|
sb = (*psrc & src.fmt->Bmask) >> src.fmt->Bshift;
|
@@ -151,15 +151,17 @@ static VALUE bitmap_miyako_rotate(VALUE self, VALUE vsrc, VALUE vdst, VALUE radi
|
|
151
151
|
}
|
152
152
|
|
153
153
|
/*
|
154
|
-
画像を拡大・縮小・鏡像(ミラー反転)させて貼り付ける
|
155
154
|
*/
|
156
155
|
static VALUE bitmap_miyako_scale(VALUE self, VALUE vsrc, VALUE vdst, VALUE xscale, VALUE yscale)
|
157
156
|
{
|
157
|
+
Uint32 sr, sg, sb, sa;
|
158
|
+
Uint32 dr, dg, db, da;
|
158
159
|
MiyakoBitmap src, dst;
|
159
160
|
MiyakoSize size;
|
160
161
|
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
161
|
-
|
162
|
-
|
162
|
+
double tscx, tscy;
|
163
|
+
int x, y, a1, a2, scx, scy, off_x, off_y, nx, ny, px, py, pr, pb, qx, qy, qr, qb;
|
164
|
+
Uint32 *tp, *psrc;
|
163
165
|
|
164
166
|
_miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
|
165
167
|
|
@@ -169,42 +171,41 @@ static VALUE bitmap_miyako_scale(VALUE self, VALUE vsrc, VALUE vdst, VALUE xscal
|
|
169
171
|
|
170
172
|
if(dst.rect.w >= 32768 || dst.rect.h >= 32768){ return Qnil; }
|
171
173
|
|
172
|
-
|
173
|
-
|
174
|
+
tscx = NUM2DBL(xscale);
|
175
|
+
tscy = NUM2DBL(yscale);
|
174
176
|
|
175
177
|
if(tscx == 0.0 || tscy == 0.0){ return Qnil; }
|
176
178
|
|
177
|
-
|
178
|
-
|
179
|
+
scx = (int)(4096.0 / tscx);
|
180
|
+
scy = (int)(4096.0 / tscy);
|
179
181
|
|
180
|
-
|
181
|
-
|
182
|
+
off_x = scx < 0 ? 1 : 0;
|
183
|
+
off_y = scy < 0 ? 1 : 0;
|
182
184
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
185
|
+
px = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+7)));
|
186
|
+
py = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+8)));
|
187
|
+
pr = src.rect.w + px;
|
188
|
+
pb = src.rect.h + py;
|
189
|
+
qx = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+7)));
|
190
|
+
qy = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+8)));
|
191
|
+
qr = dst.rect.w + qx;
|
192
|
+
qb = dst.rect.h + qy;
|
191
193
|
|
192
194
|
SDL_LockSurface(src.surface);
|
193
195
|
SDL_LockSurface(dst.surface);
|
194
196
|
|
195
|
-
int x, y;
|
196
197
|
for(y = qy; y < qb; y++)
|
197
198
|
{
|
198
|
-
|
199
|
+
tp = dst.ptr + (dst.rect.y + y - qy) * dst.surface->w + dst.rect.x;
|
199
200
|
for(x = qx; x < qr; x++)
|
200
201
|
{
|
201
|
-
|
202
|
+
nx = (x*scx) >> 12 - off_x;
|
202
203
|
if(nx < px || nx >= pr){ tp++; continue; }
|
203
|
-
|
204
|
+
ny = (y*scy) >> 12 - off_y;
|
204
205
|
if(ny < py || ny >= pb){ tp++; continue; }
|
205
206
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
206
207
|
da = (*tp >> 24) | dst.a255;
|
207
|
-
|
208
|
+
psrc = src.ptr + (src.rect.x + ny - py) * src.surface->w + src.rect.x + nx - px;
|
208
209
|
sa = (*psrc >> 24) | src.a255;
|
209
210
|
if(sa == 0){ tp++; continue; }
|
210
211
|
if(da == 0 || sa == 255)
|
@@ -213,8 +214,8 @@ static VALUE bitmap_miyako_scale(VALUE self, VALUE vsrc, VALUE vdst, VALUE xscal
|
|
213
214
|
tp++;
|
214
215
|
continue;
|
215
216
|
}
|
216
|
-
|
217
|
-
|
217
|
+
a1 = sa + 1;
|
218
|
+
a2 = 256 - sa;
|
218
219
|
dr = *tp & 0xff0000;
|
219
220
|
dg = *tp & 0xff00;
|
220
221
|
db = *tp & 0xff;
|
@@ -230,7 +231,7 @@ static VALUE bitmap_miyako_scale(VALUE self, VALUE vsrc, VALUE vdst, VALUE xscal
|
|
230
231
|
dg = (*tp & dst.fmt->Gmask) >> dst.fmt->Gshift;
|
231
232
|
db = (*tp & dst.fmt->Bmask) >> dst.fmt->Bshift;
|
232
233
|
da = (*tp & dst.fmt->Amask) | dst.a255;
|
233
|
-
|
234
|
+
psrc = src.ptr + (src.rect.x + ny - py) * src.surface->w + src.rect.x + nx - px;
|
234
235
|
sa = (*psrc & src.fmt->Amask) | src.a255;
|
235
236
|
if(sa == 0){ tp++; continue; }
|
236
237
|
if(da == 0 || sa == 255)
|
@@ -239,8 +240,8 @@ static VALUE bitmap_miyako_scale(VALUE self, VALUE vsrc, VALUE vdst, VALUE xscal
|
|
239
240
|
tp++;
|
240
241
|
continue;
|
241
242
|
}
|
242
|
-
|
243
|
-
|
243
|
+
a1 = sa + 1;
|
244
|
+
a2 = 256 - sa;
|
244
245
|
sr = (*psrc & src.fmt->Rmask) >> src.fmt->Rshift;
|
245
246
|
sg = (*psrc & src.fmt->Gmask) >> src.fmt->Gshift;
|
246
247
|
sb = (*psrc & src.fmt->Bmask) >> src.fmt->Bshift;
|
@@ -260,58 +261,58 @@ static VALUE bitmap_miyako_scale(VALUE self, VALUE vsrc, VALUE vdst, VALUE xscal
|
|
260
261
|
}
|
261
262
|
|
262
263
|
/*
|
263
|
-
===回転・拡大・縮小・鏡像用インナーメソッド
|
264
264
|
*/
|
265
265
|
static void transform_inner(MiyakoBitmap *src, MiyakoBitmap *dst, VALUE radian, VALUE xscale, VALUE yscale)
|
266
266
|
{
|
267
|
-
if(dst->rect.w >= 32768 || dst->rect.h >= 32768) return;
|
268
|
-
|
269
267
|
MiyakoSize size;
|
268
|
+
double rad, tscx, tscy;
|
269
|
+
long isin, icos;
|
270
|
+
int x, y, a1, a2, scx, scy, off_x, off_y, nx, ny, px, py, pr, pb, qx, qy, qr, qb;
|
271
|
+
Uint32 sr, sg, sb, sa, dr, dg, db, da, *tp, *psrc;
|
272
|
+
|
273
|
+
if(dst->rect.w >= 32768 || dst->rect.h >= 32768) return;
|
270
274
|
|
271
275
|
if(_miyako_init_rect(src, dst, &size) == 0) return;
|
272
276
|
|
273
|
-
|
274
|
-
|
275
|
-
|
277
|
+
rad = NUM2DBL(radian) * -1.0;
|
278
|
+
isin = (long)(sin(rad)*4096.0);
|
279
|
+
icos = (long)(cos(rad)*4096.0);
|
276
280
|
|
277
|
-
|
278
|
-
|
281
|
+
tscx = NUM2DBL(xscale);
|
282
|
+
tscy = NUM2DBL(yscale);
|
279
283
|
|
280
284
|
if(tscx == 0.0 || tscy == 0.0) return;
|
281
285
|
|
282
|
-
|
283
|
-
|
286
|
+
scx = (int)(4096.0 / tscx);
|
287
|
+
scy = (int)(4096.0 / tscy);
|
284
288
|
|
285
|
-
|
286
|
-
|
289
|
+
off_x = scx < 0 ? 1 : 0;
|
290
|
+
off_y = scy < 0 ? 1 : 0;
|
287
291
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
Uint32 sr, sg, sb, sa;
|
297
|
-
Uint32 dr, dg, db, da;
|
292
|
+
px = -(NUM2INT(*(RSTRUCT_PTR(src->unit)+7)));
|
293
|
+
py = -(NUM2INT(*(RSTRUCT_PTR(src->unit)+8)));
|
294
|
+
pr = src->rect.w + px;
|
295
|
+
pb = src->rect.h + py;
|
296
|
+
qx = -(NUM2INT(*(RSTRUCT_PTR(dst->unit)+7)));
|
297
|
+
qy = -(NUM2INT(*(RSTRUCT_PTR(dst->unit)+8)));
|
298
|
+
qr = dst->rect.w + qx;
|
299
|
+
qb = dst->rect.h + qy;
|
298
300
|
|
299
301
|
SDL_LockSurface(src->surface);
|
300
302
|
SDL_LockSurface(dst->surface);
|
301
303
|
|
302
|
-
int x, y;
|
303
304
|
for(y = qy; y < qb; y++)
|
304
305
|
{
|
305
|
-
|
306
|
+
tp = dst->ptr + (dst->rect.y + y - qy) * dst->surface->w + dst->rect.x;
|
306
307
|
for(x = qx; x < qr; x++)
|
307
308
|
{
|
308
|
-
|
309
|
+
nx = (((x*icos-y*isin) >> 12) * scx) >> 12 - off_x;
|
309
310
|
if(nx < px || nx >= pr){ tp++; continue; }
|
310
|
-
|
311
|
+
ny = (((x*isin+y*icos) >> 12) * scy) >> 12 - off_y;
|
311
312
|
if(ny < py || ny >= pb){ tp++; continue; }
|
312
313
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
313
314
|
da = (*tp >> 24) | dst->a255;
|
314
|
-
|
315
|
+
psrc = src->ptr + (src->rect.x + ny - py) * src->surface->w + src->rect.x + nx - px;
|
315
316
|
sa = (*psrc >> 24) | src->a255;
|
316
317
|
if(sa == 0){ tp++; continue; }
|
317
318
|
if(da == 0 || sa == 255)
|
@@ -320,8 +321,8 @@ static void transform_inner(MiyakoBitmap *src, MiyakoBitmap *dst, VALUE radian,
|
|
320
321
|
tp++;
|
321
322
|
continue;
|
322
323
|
}
|
323
|
-
|
324
|
-
|
324
|
+
a1 = sa + 1;
|
325
|
+
a2 = 256 - sa;
|
325
326
|
dr = *tp & 0xff0000;
|
326
327
|
dg = *tp & 0xff00;
|
327
328
|
db = *tp & 0xff;
|
@@ -337,7 +338,7 @@ static void transform_inner(MiyakoBitmap *src, MiyakoBitmap *dst, VALUE radian,
|
|
337
338
|
dg = (*tp & dst->fmt->Gmask) >> dst->fmt->Gshift;
|
338
339
|
db = (*tp & dst->fmt->Bmask) >> dst->fmt->Bshift;
|
339
340
|
da = (*tp & dst->fmt->Amask) | dst->a255;
|
340
|
-
|
341
|
+
psrc = src->ptr + (src->rect.x + ny - py) * src->surface->w + src->rect.x + nx - px;
|
341
342
|
sa = (*psrc & src->fmt->Amask) | src->a255;
|
342
343
|
if(sa == 0){ tp++; continue; }
|
343
344
|
if(da == 0 || sa == 255)
|
@@ -346,8 +347,8 @@ static void transform_inner(MiyakoBitmap *src, MiyakoBitmap *dst, VALUE radian,
|
|
346
347
|
tp++;
|
347
348
|
continue;
|
348
349
|
}
|
349
|
-
|
350
|
-
|
350
|
+
a1 = sa + 1;
|
351
|
+
a2 = 256 - sa;
|
351
352
|
sr = (*psrc & src->fmt->Rmask) >> src->fmt->Rshift;
|
352
353
|
sg = (*psrc & src->fmt->Gmask) >> src->fmt->Gshift;
|
353
354
|
sb = (*psrc & src->fmt->Bmask) >> src->fmt->Bshift;
|
@@ -365,7 +366,6 @@ static void transform_inner(MiyakoBitmap *src, MiyakoBitmap *dst, VALUE radian,
|
|
365
366
|
}
|
366
367
|
|
367
368
|
/*
|
368
|
-
画像を変形(回転・拡大・縮小・鏡像)させて貼り付ける
|
369
369
|
*/
|
370
370
|
static VALUE bitmap_miyako_transform(VALUE self, VALUE vsrc, VALUE vdst, VALUE radian, VALUE xscale, VALUE yscale)
|
371
371
|
{
|
@@ -381,14 +381,15 @@ static VALUE bitmap_miyako_transform(VALUE self, VALUE vsrc, VALUE vdst, VALUE r
|
|
381
381
|
}
|
382
382
|
|
383
383
|
/*
|
384
|
-
インスタンスの内容を画面に描画する(回転/拡大/縮小/鏡像付き)
|
385
384
|
*/
|
386
385
|
static VALUE sprite_render_transform(VALUE self, VALUE radian, VALUE xscale, VALUE yscale)
|
387
386
|
{
|
387
|
+
MiyakoBitmap src, dst;
|
388
|
+
SDL_Surface *scr;
|
389
|
+
|
388
390
|
VALUE visible = rb_iv_get(self, "@visible");
|
389
391
|
if(visible == Qfalse) return self;
|
390
|
-
|
391
|
-
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
392
|
+
scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
392
393
|
|
393
394
|
_miyako_setup_unit_2(self, mScreen, scr, &src, &dst, Qnil, Qnil, 1);
|
394
395
|
|
@@ -399,14 +400,15 @@ static VALUE sprite_render_transform(VALUE self, VALUE radian, VALUE xscale, VAL
|
|
399
400
|
}
|
400
401
|
|
401
402
|
/*
|
402
|
-
インスタンスの内容を画面に描画する(回転/拡大/縮小/鏡像付き)
|
403
403
|
*/
|
404
404
|
static VALUE sprite_render_to_sprite_transform(VALUE self, VALUE vdst, VALUE radian, VALUE xscale, VALUE yscale)
|
405
405
|
{
|
406
|
+
MiyakoBitmap src, dst;
|
407
|
+
SDL_Surface *scr;
|
408
|
+
|
406
409
|
VALUE visible = rb_iv_get(self, "@visible");
|
407
410
|
if(visible == Qfalse) return self;
|
408
|
-
|
409
|
-
SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
411
|
+
scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
|
410
412
|
|
411
413
|
_miyako_setup_unit_2(self, vdst, scr, &src, &dst, Qnil, Qnil, 1);
|
412
414
|
|
data/miyako_utility.c
CHANGED
@@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
20
20
|
*/
|
21
21
|
|
22
22
|
/*
|
23
|
-
|
24
|
-
Authors::
|
23
|
+
=miyako_no_katana
|
24
|
+
Authors:: Cyross Makoto
|
25
25
|
Version:: 2.0
|
26
26
|
Copyright:: 2007-2008 Cyross Makoto
|
27
27
|
License:: LGPL2.1
|
@@ -39,13 +39,15 @@ static GLOBAL_DEFINE_GET_STRUCT(Surface, GetSurface, cSurface, "SDL::Surface");
|
|
39
39
|
|
40
40
|
void _miyako_setup_unit(VALUE unit, SDL_Surface *screen, MiyakoBitmap *mb, VALUE x, VALUE y)
|
41
41
|
{
|
42
|
+
VALUE *mb_p;
|
43
|
+
|
42
44
|
mb->unit = unit;
|
43
45
|
if(rb_obj_is_kind_of(mb->unit, sSpriteUnit) == Qfalse){
|
44
46
|
mb->unit = rb_funcall(mb->unit, rb_intern("to_unit"), 0);
|
45
47
|
if(mb->unit == Qnil){ rb_raise(eMiyakoError, "Source instance has not SpriteUnit!"); }
|
46
48
|
}
|
47
49
|
|
48
|
-
|
50
|
+
mb_p = RSTRUCT_PTR(mb->unit);
|
49
51
|
|
50
52
|
mb->rect.x = NUM2INT(*(mb_p + 1));
|
51
53
|
mb->rect.y = NUM2INT(*(mb_p + 2));
|
@@ -89,6 +91,8 @@ void _miyako_setup_unit_2(VALUE unit_s, VALUE unit_d,
|
|
89
91
|
MiyakoBitmap *mb_s, MiyakoBitmap *mb_d,
|
90
92
|
VALUE x, VALUE y)
|
91
93
|
{
|
94
|
+
VALUE *ms_p, *md_p;
|
95
|
+
|
92
96
|
mb_s->unit = unit_s;
|
93
97
|
if(rb_obj_is_kind_of(mb_s->unit, sSpriteUnit) == Qfalse){
|
94
98
|
mb_s->unit = rb_funcall(mb_s->unit, rb_intern("to_unit"), 0);
|
@@ -105,8 +109,8 @@ void _miyako_setup_unit_2(VALUE unit_s, VALUE unit_d,
|
|
105
109
|
mb_s->ptr = (Uint32 *)(mb_s->surface->pixels);
|
106
110
|
mb_s->fmt = mb_s->surface->format;
|
107
111
|
|
108
|
-
|
109
|
-
|
112
|
+
ms_p = RSTRUCT_PTR(mb_s->unit);
|
113
|
+
md_p = RSTRUCT_PTR(mb_d->unit);
|
110
114
|
|
111
115
|
mb_s->rect.x = NUM2INT(*(ms_p + 1));
|
112
116
|
mb_s->rect.y = NUM2INT(*(ms_p + 2));
|
@@ -184,14 +188,9 @@ int _miyako_init_rect(MiyakoBitmap *src, MiyakoBitmap *dst, MiyakoSize *size)
|
|
184
188
|
int dw = dst->rect.w;
|
185
189
|
int dh = dst->rect.h;
|
186
190
|
|
187
|
-
// ox(oy)が画像のw(h)以上の時は転送不可
|
188
|
-
|
189
191
|
if(src->rect.x >= src->surface->w || src->rect.y >= src->surface->h) return 0;
|
190
192
|
if(dst->rect.x >= dst->surface->w || dst->rect.y >= dst->surface->h) return 0;
|
191
193
|
|
192
|
-
// ox(oy)がマイナスの時は、ow(oh)を減らしておいて、ox, oyをゼロにしておく
|
193
|
-
// 0以下になったら転送不可
|
194
|
-
|
195
194
|
if(src->rect.x < 0){
|
196
195
|
sw += src->rect.x;
|
197
196
|
src->rect.x = 0;
|
@@ -213,9 +212,6 @@ int _miyako_init_rect(MiyakoBitmap *src, MiyakoBitmap *dst, MiyakoSize *size)
|
|
213
212
|
if(dh <= 0) return 0;
|
214
213
|
}
|
215
214
|
|
216
|
-
// ox(oy)+ow(oh)が、w(h)を越える場合は、ow(oh)を減らしておく
|
217
|
-
// 0以下になったら転送不可
|
218
|
-
|
219
215
|
if(src->rect.x + sw > src->surface->w)
|
220
216
|
{
|
221
217
|
sw += (src->surface->w - src->rect.x - sw);
|
@@ -237,14 +233,9 @@ int _miyako_init_rect(MiyakoBitmap *src, MiyakoBitmap *dst, MiyakoSize *size)
|
|
237
233
|
if(dh <= 0) return 0;
|
238
234
|
}
|
239
235
|
|
240
|
-
// ox(oy)が画像のw(h)以上、-w(-h)以下の時は転送不可
|
241
|
-
|
242
236
|
if(src->x >= dw || src->x <= -dw) return 0;
|
243
237
|
if(src->y >= dh || src->y <= -dh) return 0;
|
244
238
|
|
245
|
-
// x(y)がマイナスの時は、ow(oh)を減らしておいて、x, yをゼロにしておく
|
246
|
-
// 0以下になったら転送不可
|
247
|
-
|
248
239
|
if(src->x < 0){
|
249
240
|
dw += src->x;
|
250
241
|
src->x = 0;
|
data/miyako_yuki.c
CHANGED
@@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
20
20
|
*/
|
21
21
|
|
22
22
|
/*
|
23
|
-
|
24
|
-
Authors::
|
23
|
+
=miyako_no_katana
|
24
|
+
Authors:: Cyross Makoto
|
25
25
|
Version:: 2.1
|
26
26
|
Copyright:: 2007-2009 Cyross Makoto
|
27
27
|
License:: LGPL2.1
|
@@ -73,8 +73,9 @@ static VALUE yuki_is_exec(VALUE self)
|
|
73
73
|
*/
|
74
74
|
static VALUE yuki_ua(VALUE self)
|
75
75
|
{
|
76
|
+
VALUE over_yuki;
|
76
77
|
_miyako_sprite_list_update_animation(rb_iv_get(self, str_visibles));
|
77
|
-
|
78
|
+
over_yuki = rb_iv_get(self, str_o_yuki);
|
78
79
|
if(over_yuki == Qnil) return self;
|
79
80
|
if(yuki_is_exec(self) == Qtrue){
|
80
81
|
yuki_ua(over_yuki);
|
@@ -87,10 +88,11 @@ static VALUE yuki_ua(VALUE self)
|
|
87
88
|
*/
|
88
89
|
static VALUE yuki_render(VALUE self)
|
89
90
|
{
|
91
|
+
VALUE over_yuki;
|
90
92
|
if(rb_iv_get(self, str_visible) == Qtrue){
|
91
93
|
_miyako_sprite_list_render(rb_iv_get(self, str_visibles));
|
92
94
|
}
|
93
|
-
|
95
|
+
over_yuki = rb_iv_get(self, str_o_yuki);
|
94
96
|
if(over_yuki == Qnil) return self;
|
95
97
|
if(yuki_is_exec(self) == Qtrue){
|
96
98
|
yuki_render(over_yuki);
|
@@ -103,10 +105,11 @@ static VALUE yuki_render(VALUE self)
|
|
103
105
|
*/
|
104
106
|
static VALUE yuki_render_to(VALUE self, VALUE dst)
|
105
107
|
{
|
108
|
+
VALUE over_yuki;
|
106
109
|
if(rb_iv_get(self, str_visible) == Qtrue){
|
107
110
|
_miyako_sprite_list_render_to(rb_iv_get(self, str_visibles), dst);
|
108
111
|
}
|
109
|
-
|
112
|
+
over_yuki = rb_iv_get(self, str_o_yuki);
|
110
113
|
if(over_yuki == Qnil) return self;
|
111
114
|
if(yuki_is_exec(self) == Qtrue){
|
112
115
|
yuki_render_to(over_yuki, dst);
|
@@ -143,11 +146,12 @@ static VALUE iyuki_post_process(VALUE self)
|
|
143
146
|
*/
|
144
147
|
static VALUE iyuki_update(VALUE self)
|
145
148
|
{
|
149
|
+
VALUE amt;
|
146
150
|
rb_funcall(self, id_update_inner, 1, self);
|
147
151
|
rb_iv_set(self, "@pause_release", Qfalse);
|
148
152
|
rb_iv_set(self, "@select_ok", Qfalse);
|
149
153
|
rb_iv_set(self, "@select_cansel", Qfalse);
|
150
|
-
|
154
|
+
amt = rb_iv_get(self, "@select_amount");
|
151
155
|
*(RARRAY_PTR(amt)+0) = nZero;
|
152
156
|
*(RARRAY_PTR(amt)+1) = nZero;
|
153
157
|
return self;
|
@@ -221,7 +221,7 @@ class MainScene
|
|
221
221
|
ws = Sprite.new(:file=>"wait_cursor.png", :type=>:ac)
|
222
222
|
ws.oh = ws.ow
|
223
223
|
ws = SpriteAnimation.new(:sprite=>ws, :wait=>0.2, :pattern_list=>[0,1,2,3,2,1])
|
224
|
-
|
224
|
+
@ws = ws
|
225
225
|
cs = Sprite.new(:file=>"cursor.png", :type=>:ac)
|
226
226
|
cs.oh = cs.ow
|
227
227
|
cs = SpriteAnimation.new(:sprite=>cs, :wait=>0.2, :pattern_list=>[0,1,2,3,2,1])
|
@@ -238,7 +238,7 @@ class MainScene
|
|
238
238
|
@parts[:box].centering!
|
239
239
|
@parts.center!.bottom!{ TEXTBOX_BOTTOM }
|
240
240
|
|
241
|
-
@yuki =
|
241
|
+
@yuki = ScenarioEngine.new
|
242
242
|
@yuki.update_text = self.method(:update_text)
|
243
243
|
|
244
244
|
@imgs = {}
|