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/miyako_input_audio.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
- =拡張ライブラリmiyako_no_katana
24
- Authors:: サイロス誠
23
+ =miyako_no_katana
24
+ Authors:: Cyross Makoto
25
25
  Version:: 2.1
26
26
  Copyright:: 2007-2008 Cyross Makoto
27
27
  License:: LGPL2.1
@@ -69,8 +69,9 @@ static volatile VALUE sy_ent = Qnil;
69
69
  */
70
70
  static VALUE input_update(VALUE self)
71
71
  {
72
- int i;
72
+ int i, len;
73
73
  VALUE *ptr;
74
+ VALUE keys, e_list, e;
74
75
 
75
76
  VALUE btn = rb_iv_get(self, "@@btn");
76
77
  VALUE mouse = rb_iv_get(self, "@@mouse");
@@ -85,7 +86,7 @@ static VALUE input_update(VALUE self)
85
86
 
86
87
  rb_funcall(cJoystick, id_update_all, 0);
87
88
 
88
- VALUE keys = rb_funcall(pushed, rb_intern("keys"), 0);
89
+ keys = rb_funcall(pushed, rb_intern("keys"), 0);
89
90
  ptr = RARRAY_PTR(keys);
90
91
  for(i=0; i<RARRAY_LEN(keys); i++)
91
92
  {
@@ -101,8 +102,8 @@ static VALUE input_update(VALUE self)
101
102
  rb_hash_aset(drop, sy_middle, Qfalse);
102
103
  rb_hash_aset(drop, sy_right, Qfalse);
103
104
 
104
- VALUE e_list = rb_ary_new();
105
- VALUE e = rb_funcall(cEvent, id_poll, 0);
105
+ e_list = rb_ary_new();
106
+ e = rb_funcall(cEvent, id_poll, 0);
106
107
  while(e != Qnil)
107
108
  {
108
109
  rb_ary_push(e_list, e);
@@ -110,7 +111,7 @@ static VALUE input_update(VALUE self)
110
111
  }
111
112
 
112
113
  ptr = RARRAY_PTR(e_list);
113
- int len = RARRAY_LEN(e_list);
114
+ len = RARRAY_LEN(e_list);
114
115
  for(i=0; i<len; i++)
115
116
  {
116
117
  VALUE e2 = *(ptr + len - i - 1);
@@ -139,10 +140,11 @@ void _miyako_input_update()
139
140
  */
140
141
  static VALUE bgm_update(VALUE self)
141
142
  {
142
- VALUE nua = rb_gv_get("$not_use_audio");
143
+ VALUE nua, pb;
144
+ nua = rb_gv_get("$not_use_audio");
143
145
  if(nua == Qfalse) return Qnil;
144
146
 
145
- VALUE pb = rb_iv_get(self, "@@playin_bgm");
147
+ pb = rb_iv_get(self, "@@playin_bgm");
146
148
  if(pb == Qnil) return Qnil;
147
149
 
148
150
  if(rb_funcall(pb, id_is_playing_wo_loop, 0) == Qfalse &&
@@ -170,17 +172,18 @@ static VALUE bgm_update(VALUE self)
170
172
  */
171
173
  static VALUE se_update(VALUE self)
172
174
  {
173
- VALUE nua = rb_gv_get("$not_use_audio");
175
+ int i;
176
+ VALUE nua, playings, *ptr;
177
+ nua = rb_gv_get("$not_use_audio");
174
178
  if(nua == Qfalse) return Qnil;
175
179
 
176
- VALUE playings = rb_iv_get(self, "@@playings");
177
- VALUE *ptr = RARRAY_PTR(playings);
178
- int i;
180
+ playings = rb_iv_get(self, "@@playings");
181
+ ptr = RARRAY_PTR(playings);
179
182
  for(i=0; i<RARRAY_LEN(playings); i++)
180
183
  {
181
184
  VALUE pl = *(ptr+i);
182
185
 
183
- if(rb_funcall(pl, id_is_playing_wo_loop, 0) == Qfalse &&
186
+ if(rb_funcall(pl, id_is_playing_wo_loop, 0) == Qfalse &&
184
187
  rb_funcall(pl, id_in_the_loop, 0) == Qtrue)
185
188
  {
186
189
  rb_funcall(pl, id_countup, 0);
data/miyako_layout.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
- =拡張ライブラリmiyako_no_katana
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
@@ -92,10 +92,11 @@ VALUE _miyako_layout_y(VALUE self)
92
92
 
93
93
  static VALUE layout_update_layout(VALUE self, VALUE dx, VALUE dy)
94
94
  {
95
- rb_funcall(self, rb_intern("update_layout_position"), 0);
96
- VALUE layout = get_layout(self);
97
- VALUE children = *(RSTRUCT_PTR(*(RSTRUCT_PTR(layout)+3))+1);
98
95
  int i;
96
+ VALUE layout, children;
97
+ rb_funcall(self, rb_intern("update_layout_position"), 0);
98
+ layout = get_layout(self);
99
+ children = *(RSTRUCT_PTR(*(RSTRUCT_PTR(layout)+3))+1);
99
100
  for(i=0; i<RARRAY_LEN(children); i++)
100
101
  {
101
102
  layout_move(*(RARRAY_PTR(children) + i), dx, dy);
@@ -105,6 +106,8 @@ static VALUE layout_update_layout(VALUE self, VALUE dx, VALUE dy)
105
106
 
106
107
  static VALUE layout_move(VALUE self, VALUE dx, VALUE dy)
107
108
  {
109
+ int i;
110
+ VALUE on_move;
108
111
  VALUE *pos = RSTRUCT_PTR(*(RSTRUCT_PTR(get_layout(self))));
109
112
  VALUE *pox = pos+0;
110
113
  VALUE *poy = pos+1;
@@ -113,8 +116,7 @@ static VALUE layout_move(VALUE self, VALUE dx, VALUE dy)
113
116
  *pox = INT2NUM(NUM2INT(tx)+NUM2INT(dx));
114
117
  *poy = INT2NUM(NUM2INT(ty)+NUM2INT(dy));
115
118
  layout_update_layout(self, dx, dy);
116
- VALUE on_move = *(RSTRUCT_PTR(get_layout(self)) + 4);
117
- int i;
119
+ on_move = *(RSTRUCT_PTR(get_layout(self)) + 4);
118
120
  for(i=0; i<RARRAY_LEN(on_move); i++)
119
121
  {
120
122
  rb_funcall(*(RARRAY_PTR(on_move) + i), rb_intern("call"), 5, self, *pox, *poy, dx, dy);
@@ -138,6 +140,8 @@ VALUE _miyako_layout_move(VALUE self, VALUE dx, VALUE dy)
138
140
 
139
141
  static VALUE layout_move_to(VALUE self, VALUE x, VALUE y)
140
142
  {
143
+ int i;
144
+ VALUE on_move, dx, dy;
141
145
  VALUE *pos = RSTRUCT_PTR(*(RSTRUCT_PTR(get_layout(self))));
142
146
  VALUE *pox = pos+0;
143
147
  VALUE *poy = pos+1;
@@ -145,11 +149,10 @@ static VALUE layout_move_to(VALUE self, VALUE x, VALUE y)
145
149
  VALUE ty = *poy;
146
150
  *pox = x;
147
151
  *poy = y;
148
- VALUE dx = INT2NUM((NUM2INT(x))-(NUM2INT(tx)));
149
- VALUE dy = INT2NUM((NUM2INT(y))-(NUM2INT(ty)));
152
+ dx = INT2NUM((NUM2INT(x))-(NUM2INT(tx)));
153
+ dy = INT2NUM((NUM2INT(y))-(NUM2INT(ty)));
150
154
  layout_update_layout(self, dx, dy);
151
- VALUE on_move = *(RSTRUCT_PTR(get_layout(self)) + 4);
152
- int i;
155
+ on_move = *(RSTRUCT_PTR(get_layout(self)) + 4);
153
156
  for(i=0; i<RARRAY_LEN(on_move); i++)
154
157
  {
155
158
  rb_funcall(*(RARRAY_PTR(on_move) + i), rb_intern("call"), 5, self, *pox, *poy, dx, dy);
@@ -173,6 +176,8 @@ VALUE _miyako_layout_move_to(VALUE self, VALUE x, VALUE y)
173
176
 
174
177
  static VALUE layout_relative_move_to(VALUE self, VALUE x, VALUE y)
175
178
  {
179
+ int i;
180
+ VALUE on_move, dx, dy;
176
181
  // bpos = @layout.base.pos
177
182
  // Size.new(bpos.x+x,bpos.y+y)
178
183
  VALUE *pos = RSTRUCT_PTR(*(RSTRUCT_PTR(get_layout(self))));
@@ -187,11 +192,10 @@ static VALUE layout_relative_move_to(VALUE self, VALUE x, VALUE y)
187
192
  *pox = INT2NUM(NUM2INT(x)+NUM2INT(*(bpos+0)));
188
193
  *poy = INT2NUM(NUM2INT(y)+NUM2INT(*(bpos+1)));
189
194
 
190
- VALUE dx = INT2NUM(NUM2INT(*pox)-NUM2INT(tx));
191
- VALUE dy = INT2NUM(NUM2INT(*poy)-NUM2INT(ty));
195
+ dx = INT2NUM(NUM2INT(*pox)-NUM2INT(tx));
196
+ dy = INT2NUM(NUM2INT(*poy)-NUM2INT(ty));
192
197
  layout_update_layout(self, dx, dy);
193
- VALUE on_move = *(RSTRUCT_PTR(get_layout(self)) + 4);
194
- int i;
198
+ on_move = *(RSTRUCT_PTR(get_layout(self)) + 4);
195
199
  for(i=0; i<RARRAY_LEN(on_move); i++)
196
200
  {
197
201
  rb_funcall(*(RARRAY_PTR(on_move) + i), rb_intern("call"), 5, self, *pox, *poy, dx, dy);
@@ -236,11 +240,12 @@ static VALUE layout_delete_snap_child(VALUE self, VALUE spr)
236
240
 
237
241
  static VALUE layout_snap(int argc, VALUE *argv, VALUE self)
238
242
  {
243
+ VALUE layout, *sprite, *base;
239
244
  VALUE spr = Qnil;
240
245
  rb_scan_args(argc, argv, "01", &spr);
241
- VALUE layout = get_layout(self);
242
- VALUE *sprite = RSTRUCT_PTR(*(RSTRUCT_PTR(layout)+3));
243
- VALUE *base = RSTRUCT_PTR(layout)+2;
246
+ layout = get_layout(self);
247
+ sprite = RSTRUCT_PTR(*(RSTRUCT_PTR(layout)+3));
248
+ base = RSTRUCT_PTR(layout)+2;
244
249
  if(spr != Qnil)
245
250
  {
246
251
  if(*sprite != Qnil){ layout_delete_snap_child(*sprite, self); }