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_sprite2.c
ADDED
@@ -0,0 +1,431 @@
|
|
1
|
+
/*
|
2
|
+
--
|
3
|
+
Miyako v2.1 Extend Library "Miyako no Katana"
|
4
|
+
Copyright (C) 2009 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.1
|
26
|
+
Copyright:: 2007-2009 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 mSpriteArray = Qnil;
|
34
|
+
static VALUE mSpriteBase = Qnil;
|
35
|
+
static VALUE cSpriteList = Qnil;
|
36
|
+
static VALUE nZero = Qnil;
|
37
|
+
static VALUE nOne = Qnil;
|
38
|
+
static volatile ID id_kakko = Qnil;
|
39
|
+
static volatile ID id_start = Qnil;
|
40
|
+
static volatile ID id_stop = Qnil;
|
41
|
+
static volatile ID id_reset = Qnil;
|
42
|
+
static volatile ID id_update_animation = Qnil;
|
43
|
+
static volatile ID id_move = Qnil;
|
44
|
+
static volatile ID id_move_to = Qnil;
|
45
|
+
static volatile ID id_render = Qnil;
|
46
|
+
static volatile ID id_render_to = Qnil;
|
47
|
+
static volatile ID id_sprite_only = Qnil;
|
48
|
+
static volatile int zero = 0;
|
49
|
+
static volatile int one = 1;
|
50
|
+
|
51
|
+
/*
|
52
|
+
:nodoc:
|
53
|
+
*/
|
54
|
+
static VALUE sprite_array_sprite_only(VALUE self)
|
55
|
+
{
|
56
|
+
VALUE array = rb_ary_new();
|
57
|
+
|
58
|
+
int i;
|
59
|
+
VALUE *ptr = RARRAY_PTR(self);
|
60
|
+
for(i=0; i<RARRAY_LEN(self); i++)
|
61
|
+
{
|
62
|
+
VALUE e = *(ptr+i);
|
63
|
+
VALUE c = CLASS_OF(e);
|
64
|
+
if(rb_mod_include_p(c, mSpriteBase) == Qtrue ||
|
65
|
+
rb_mod_include_p(c, mSpriteArray) == Qtrue)
|
66
|
+
rb_ary_push(array, e);
|
67
|
+
}
|
68
|
+
return array;
|
69
|
+
}
|
70
|
+
|
71
|
+
/*
|
72
|
+
:nodoc:
|
73
|
+
*/
|
74
|
+
static void sprite_array_move_inner(VALUE array, ID id, VALUE x, VALUE y)
|
75
|
+
{
|
76
|
+
int i;
|
77
|
+
VALUE *ptr = RARRAY_PTR(array);
|
78
|
+
if(rb_block_given_p() == Qtrue)
|
79
|
+
{
|
80
|
+
for(i=0; i<RARRAY_LEN(array); i++)
|
81
|
+
{
|
82
|
+
VALUE e = *(ptr+i);
|
83
|
+
VALUE ret = rb_yield_values(4, e, INT2NUM(i), x, y);
|
84
|
+
VALUE r1 = rb_funcall(ret, id_kakko, 1, nZero);
|
85
|
+
VALUE r2 = rb_funcall(ret, id_kakko, 1, nOne);
|
86
|
+
rb_funcall(e, id, 2, r1, r2);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
else
|
90
|
+
{
|
91
|
+
for(i=0; i<RARRAY_LEN(array); i++)
|
92
|
+
{
|
93
|
+
rb_funcall(*(ptr+i), id, 2, x, y);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
/*
|
99
|
+
:nodoc:
|
100
|
+
*/
|
101
|
+
static VALUE sprite_array_move(VALUE self, VALUE dx, VALUE dy)
|
102
|
+
{
|
103
|
+
sprite_array_move_inner(sprite_array_sprite_only(self),
|
104
|
+
id_move, dx, dy);
|
105
|
+
|
106
|
+
return self;
|
107
|
+
}
|
108
|
+
|
109
|
+
/*
|
110
|
+
:nodoc:
|
111
|
+
*/
|
112
|
+
static VALUE sprite_array_move_to(VALUE self, VALUE x, VALUE y)
|
113
|
+
{
|
114
|
+
sprite_array_move_inner(sprite_array_sprite_only(self),
|
115
|
+
id_move_to, x, y);
|
116
|
+
|
117
|
+
return self;
|
118
|
+
}
|
119
|
+
|
120
|
+
/*
|
121
|
+
:nodoc:
|
122
|
+
*/
|
123
|
+
static void sprite_array_inner(VALUE array, ID id)
|
124
|
+
{
|
125
|
+
int i;
|
126
|
+
for(i=0; i<RARRAY_LEN(array); i++)
|
127
|
+
{
|
128
|
+
rb_funcall(*(RARRAY_PTR(array)+i), id, 0);
|
129
|
+
}
|
130
|
+
}
|
131
|
+
|
132
|
+
/*
|
133
|
+
:nodoc:
|
134
|
+
*/
|
135
|
+
static VALUE sprite_array_start(VALUE self)
|
136
|
+
{
|
137
|
+
sprite_array_inner(sprite_array_sprite_only(self), id_start);
|
138
|
+
return self;
|
139
|
+
}
|
140
|
+
|
141
|
+
/*
|
142
|
+
:nodoc:
|
143
|
+
*/
|
144
|
+
static VALUE sprite_array_stop(VALUE self)
|
145
|
+
{
|
146
|
+
sprite_array_inner(sprite_array_sprite_only(self), id_stop);
|
147
|
+
return self;
|
148
|
+
}
|
149
|
+
|
150
|
+
/*
|
151
|
+
:nodoc:
|
152
|
+
*/
|
153
|
+
static VALUE sprite_array_reset(VALUE self)
|
154
|
+
{
|
155
|
+
sprite_array_inner(sprite_array_sprite_only(self), id_reset);
|
156
|
+
return self;
|
157
|
+
}
|
158
|
+
|
159
|
+
/*
|
160
|
+
:nodoc:
|
161
|
+
*/
|
162
|
+
static VALUE sprite_array_update_animation(VALUE self)
|
163
|
+
{
|
164
|
+
VALUE array = sprite_array_sprite_only(self);
|
165
|
+
VALUE ret = rb_ary_new();
|
166
|
+
int i;
|
167
|
+
for(i=0; i<RARRAY_LEN(array); i++)
|
168
|
+
{
|
169
|
+
rb_ary_push(ret, rb_funcall(*(RARRAY_PTR(array)+i), id_update_animation, 0));
|
170
|
+
}
|
171
|
+
return ret;
|
172
|
+
}
|
173
|
+
|
174
|
+
/*
|
175
|
+
:nodoc:
|
176
|
+
*/
|
177
|
+
static VALUE sprite_array_render(VALUE self)
|
178
|
+
{
|
179
|
+
sprite_array_inner(sprite_array_sprite_only(self), id_render);
|
180
|
+
return self;
|
181
|
+
}
|
182
|
+
|
183
|
+
/*
|
184
|
+
:nodoc:
|
185
|
+
*/
|
186
|
+
static VALUE sprite_array_render_to(VALUE self, VALUE dst)
|
187
|
+
{
|
188
|
+
VALUE array = sprite_array_sprite_only(self);
|
189
|
+
|
190
|
+
int i;
|
191
|
+
for(i=0; i<RARRAY_LEN(array); i++)
|
192
|
+
{
|
193
|
+
rb_funcall(*(RARRAY_PTR(array)+i), id_render_to, 1, dst);
|
194
|
+
}
|
195
|
+
|
196
|
+
return self;
|
197
|
+
}
|
198
|
+
|
199
|
+
/*
|
200
|
+
:nodoc:
|
201
|
+
*/
|
202
|
+
static VALUE sprite_list_sprite_only(VALUE self)
|
203
|
+
{
|
204
|
+
VALUE hash = rb_hash_new();
|
205
|
+
VALUE names = rb_iv_get(self, "@names");
|
206
|
+
VALUE n2v = rb_iv_get(self, "@n2v");
|
207
|
+
|
208
|
+
int i;
|
209
|
+
VALUE *ptr = RARRAY_PTR(names);
|
210
|
+
for(i=0; i<RARRAY_LEN(names); i++)
|
211
|
+
{
|
212
|
+
VALUE *p2 = RSTRUCT_PTR(rb_hash_lookup(n2v, *(ptr+i)));
|
213
|
+
VALUE n = *(p2+0);
|
214
|
+
VALUE v = *(p2+1);
|
215
|
+
VALUE c = CLASS_OF(v);
|
216
|
+
if(rb_mod_include_p(c, mSpriteBase) == Qtrue ||
|
217
|
+
rb_mod_include_p(c, mSpriteArray) == Qtrue)
|
218
|
+
rb_hash_aset(hash, n, v);
|
219
|
+
}
|
220
|
+
return rb_funcall(cSpriteList, rb_intern("new"), 1, hash);
|
221
|
+
}
|
222
|
+
|
223
|
+
/*
|
224
|
+
:nodoc:
|
225
|
+
*/
|
226
|
+
static void sprite_list_move_inner(VALUE list, ID id, VALUE x, VALUE y)
|
227
|
+
{
|
228
|
+
VALUE names = rb_iv_get(list, "@names");
|
229
|
+
VALUE n2v = rb_iv_get(list, "@n2v");
|
230
|
+
int i;
|
231
|
+
VALUE *ptr = RARRAY_PTR(names);
|
232
|
+
if(rb_block_given_p() == Qtrue)
|
233
|
+
{
|
234
|
+
for(i=0; i<RARRAY_LEN(names); i++)
|
235
|
+
{
|
236
|
+
VALUE e = rb_hash_lookup(n2v, *(ptr+i));
|
237
|
+
VALUE ret = rb_yield_values(4, e, INT2NUM(i), x, y);
|
238
|
+
VALUE r1 = rb_funcall(ret, id_kakko, 1, nZero);
|
239
|
+
VALUE r2 = rb_funcall(ret, id_kakko, 1, nOne);
|
240
|
+
rb_funcall(e, id, 2, r1, r2);
|
241
|
+
}
|
242
|
+
}
|
243
|
+
else
|
244
|
+
{
|
245
|
+
for(i=0; i<RARRAY_LEN(names); i++)
|
246
|
+
{
|
247
|
+
VALUE v = *(RSTRUCT_PTR(rb_hash_lookup(n2v, *(ptr+i)))+1);
|
248
|
+
rb_funcall(v, id, 2, x, y);
|
249
|
+
}
|
250
|
+
}
|
251
|
+
}
|
252
|
+
|
253
|
+
/*
|
254
|
+
:nodoc:
|
255
|
+
*/
|
256
|
+
static VALUE sprite_list_move(VALUE self, VALUE dx, VALUE dy)
|
257
|
+
{
|
258
|
+
sprite_list_move_inner(self, id_move, dx, dy);
|
259
|
+
|
260
|
+
return self;
|
261
|
+
}
|
262
|
+
|
263
|
+
/*
|
264
|
+
:nodoc:
|
265
|
+
*/
|
266
|
+
static VALUE sprite_list_move_to(VALUE self, VALUE x, VALUE y)
|
267
|
+
{
|
268
|
+
sprite_list_move_inner(self, id_move_to, x, y);
|
269
|
+
|
270
|
+
return self;
|
271
|
+
}
|
272
|
+
|
273
|
+
/*
|
274
|
+
:nodoc:
|
275
|
+
*/
|
276
|
+
static VALUE sprite_list_to_ary(VALUE self)
|
277
|
+
{
|
278
|
+
VALUE ret = rb_ary_new();
|
279
|
+
VALUE names = rb_iv_get(self, "@names");
|
280
|
+
VALUE n2v = rb_iv_get(self, "@n2v");
|
281
|
+
|
282
|
+
int i;
|
283
|
+
VALUE *ptr = RARRAY_PTR(names);
|
284
|
+
for(i=0; i<RARRAY_LEN(names); i++)
|
285
|
+
rb_ary_push(ret, rb_hash_lookup(n2v, *(ptr+i)));
|
286
|
+
|
287
|
+
return ret;
|
288
|
+
}
|
289
|
+
|
290
|
+
/*
|
291
|
+
:nodoc:
|
292
|
+
*/
|
293
|
+
static VALUE sprite_list_each(VALUE self)
|
294
|
+
{
|
295
|
+
VALUE array = sprite_list_to_ary(self);
|
296
|
+
|
297
|
+
int i;
|
298
|
+
VALUE *ptr = RARRAY_PTR(array);
|
299
|
+
for(i=0; i<RARRAY_LEN(array); i++)
|
300
|
+
rb_yield_values(1, *(ptr+i));
|
301
|
+
|
302
|
+
return self;
|
303
|
+
}
|
304
|
+
|
305
|
+
/*
|
306
|
+
:nodoc:
|
307
|
+
*/
|
308
|
+
static void sprite_list_inner(VALUE list, ID id)
|
309
|
+
{
|
310
|
+
VALUE array = sprite_list_to_ary(list);
|
311
|
+
int i;
|
312
|
+
for(i=0; i<RARRAY_LEN(array); i++)
|
313
|
+
{
|
314
|
+
VALUE pair = *(RARRAY_PTR(array)+i);
|
315
|
+
rb_funcall(*(RSTRUCT_PTR(pair)+1), id ,0);
|
316
|
+
}
|
317
|
+
}
|
318
|
+
|
319
|
+
/*
|
320
|
+
:nodoc:
|
321
|
+
*/
|
322
|
+
static VALUE sprite_list_start(VALUE self)
|
323
|
+
{
|
324
|
+
sprite_list_inner(self, id_start);
|
325
|
+
return self;
|
326
|
+
}
|
327
|
+
|
328
|
+
/*
|
329
|
+
:nodoc:
|
330
|
+
*/
|
331
|
+
static VALUE sprite_list_stop(VALUE self)
|
332
|
+
{
|
333
|
+
sprite_list_inner(self, id_stop);
|
334
|
+
return self;
|
335
|
+
}
|
336
|
+
|
337
|
+
/*
|
338
|
+
:nodoc:
|
339
|
+
*/
|
340
|
+
static VALUE sprite_list_reset(VALUE self)
|
341
|
+
{
|
342
|
+
sprite_list_inner(self, id_reset);
|
343
|
+
return self;
|
344
|
+
}
|
345
|
+
|
346
|
+
/*
|
347
|
+
:nodoc:
|
348
|
+
*/
|
349
|
+
static VALUE sprite_list_update_animation(VALUE self)
|
350
|
+
{
|
351
|
+
VALUE array = sprite_list_to_ary(self);
|
352
|
+
VALUE ret = rb_ary_new();
|
353
|
+
int i;
|
354
|
+
for(i=0; i<RARRAY_LEN(array); i++)
|
355
|
+
{
|
356
|
+
VALUE pair = *(RARRAY_PTR(array)+i);
|
357
|
+
rb_ary_push(ret, rb_funcall(*(RSTRUCT_PTR(pair)+1), id_update_animation, 0));
|
358
|
+
}
|
359
|
+
return ret;
|
360
|
+
}
|
361
|
+
|
362
|
+
/*
|
363
|
+
:nodoc:
|
364
|
+
*/
|
365
|
+
static VALUE sprite_list_render(VALUE self)
|
366
|
+
{
|
367
|
+
sprite_list_inner(self, id_render);
|
368
|
+
return self;
|
369
|
+
}
|
370
|
+
|
371
|
+
/*
|
372
|
+
:nodoc:
|
373
|
+
*/
|
374
|
+
static VALUE sprite_list_render_to(VALUE self, VALUE dst)
|
375
|
+
{
|
376
|
+
VALUE array = sprite_list_to_ary(self);
|
377
|
+
int i;
|
378
|
+
for(i=0; i<RARRAY_LEN(array); i++)
|
379
|
+
{
|
380
|
+
VALUE pair = *(RARRAY_PTR(array)+i);
|
381
|
+
rb_funcall(*(RSTRUCT_PTR(pair)+1), id_render_to, 1, dst);
|
382
|
+
}
|
383
|
+
|
384
|
+
return self;
|
385
|
+
}
|
386
|
+
|
387
|
+
void Init_miyako_sprite2()
|
388
|
+
{
|
389
|
+
mSDL = rb_define_module("SDL");
|
390
|
+
mMiyako = rb_define_module("Miyako");
|
391
|
+
mSpriteArray = rb_define_module_under(mMiyako, "SpriteArray");
|
392
|
+
mSpriteBase = rb_define_module_under(mMiyako, "SpriteBase");
|
393
|
+
cSpriteList = rb_define_class_under(mMiyako, "SpriteList", rb_cObject);
|
394
|
+
|
395
|
+
id_kakko = rb_intern("[]");
|
396
|
+
id_start = rb_intern("start");
|
397
|
+
id_stop = rb_intern("stop");
|
398
|
+
id_reset = rb_intern("reset");
|
399
|
+
id_update_animation = rb_intern("update_animation");
|
400
|
+
id_move = rb_intern("move!");
|
401
|
+
id_move_to = rb_intern("move_to!");
|
402
|
+
id_render = rb_intern("render");
|
403
|
+
id_render_to = rb_intern("render_to");
|
404
|
+
id_sprite_only = rb_intern("sprite_only");
|
405
|
+
|
406
|
+
zero = 0;
|
407
|
+
nZero = INT2NUM(zero);
|
408
|
+
one = 1;
|
409
|
+
nOne = INT2NUM(one);
|
410
|
+
|
411
|
+
rb_define_method(mSpriteArray, "sprite_only", sprite_array_sprite_only, 0);
|
412
|
+
rb_define_method(mSpriteArray, "start", sprite_array_start, 0);
|
413
|
+
rb_define_method(mSpriteArray, "stop", sprite_array_stop, 0);
|
414
|
+
rb_define_method(mSpriteArray, "reset", sprite_array_reset, 0);
|
415
|
+
rb_define_method(mSpriteArray, "update_animation", sprite_array_update_animation, 0);
|
416
|
+
rb_define_method(mSpriteArray, "move!", sprite_array_move, 2);
|
417
|
+
rb_define_method(mSpriteArray, "move_to!", sprite_array_move_to, 2);
|
418
|
+
rb_define_method(mSpriteArray, "render", sprite_array_render, 0);
|
419
|
+
rb_define_method(mSpriteArray, "render_to", sprite_array_render_to, 1);
|
420
|
+
rb_define_method(cSpriteList, "sprite_only", sprite_list_sprite_only, 0);
|
421
|
+
rb_define_method(cSpriteList, "start", sprite_list_start, 0);
|
422
|
+
rb_define_method(cSpriteList, "stop", sprite_list_stop, 0);
|
423
|
+
rb_define_method(cSpriteList, "reset", sprite_list_reset, 0);
|
424
|
+
rb_define_method(cSpriteList, "update_animation", sprite_list_update_animation, 0);
|
425
|
+
rb_define_method(cSpriteList, "move!", sprite_list_move, 2);
|
426
|
+
rb_define_method(cSpriteList, "move_to!", sprite_list_move_to, 2);
|
427
|
+
rb_define_method(cSpriteList, "to_ary", sprite_list_to_ary, 0);
|
428
|
+
rb_define_method(cSpriteList, "each", sprite_list_each, 0);
|
429
|
+
rb_define_method(cSpriteList, "render", sprite_list_render, 0);
|
430
|
+
rb_define_method(cSpriteList, "render_to", sprite_list_render_to, 1);
|
431
|
+
}
|