ruby-miyako 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/README +275 -20
  2. data/extern.h +21 -1
  3. data/install_miyako.rb +5 -3
  4. data/lib/Miyako/API/audio.rb +11 -6
  5. data/lib/Miyako/API/basic_data.rb +0 -985
  6. data/lib/Miyako/API/bitmap.rb +19 -22
  7. data/lib/Miyako/API/choices.rb +203 -69
  8. data/lib/Miyako/API/collision.rb +451 -9
  9. data/lib/Miyako/API/color.rb +177 -0
  10. data/lib/Miyako/API/diagram.rb +18 -20
  11. data/lib/Miyako/API/fixedmap.rb +207 -73
  12. data/lib/Miyako/API/font.rb +111 -18
  13. data/lib/Miyako/API/i_yuki.rb +1201 -0
  14. data/lib/Miyako/API/input.rb +65 -0
  15. data/lib/Miyako/API/layout.rb +41 -29
  16. data/lib/Miyako/API/map.rb +202 -157
  17. data/lib/Miyako/API/map_event.rb +86 -19
  18. data/lib/Miyako/API/map_struct.rb +268 -0
  19. data/lib/Miyako/API/modules.rb +136 -37
  20. data/lib/Miyako/API/movie.rb +8 -8
  21. data/lib/Miyako/API/parts.rb +63 -20
  22. data/lib/Miyako/API/plane.rb +4 -4
  23. data/lib/Miyako/API/screen.rb +16 -8
  24. data/lib/Miyako/API/sprite.rb +290 -23
  25. data/lib/Miyako/API/sprite_animation.rb +23 -11
  26. data/lib/Miyako/API/sprite_list.rb +406 -183
  27. data/lib/Miyako/API/story.rb +4 -65
  28. data/lib/Miyako/API/struct_point.rb +157 -0
  29. data/lib/Miyako/API/struct_rect.rb +233 -0
  30. data/lib/Miyako/API/struct_segment.rb +641 -0
  31. data/lib/Miyako/API/struct_size.rb +158 -0
  32. data/lib/Miyako/API/struct_square.rb +253 -0
  33. data/lib/Miyako/API/textbox.rb +49 -35
  34. data/lib/Miyako/API/viewport.rb +5 -5
  35. data/lib/Miyako/API/wait_counter.rb +350 -0
  36. data/lib/Miyako/API/yuki.rb +95 -60
  37. data/lib/Miyako/EXT/raster_scroll.rb +30 -8
  38. data/lib/Miyako/EXT/slides.rb +6 -6
  39. data/lib/Miyako/miyako.rb +25 -11
  40. data/lib/miyako.rb +28 -0
  41. data/lib/miyako_require_only.rb +35 -0
  42. data/miyako_basicdata.c +201 -17
  43. data/miyako_collision.c +315 -6
  44. data/miyako_diagram.c +331 -0
  45. data/miyako_drawing.c +26 -7
  46. data/miyako_font.c +259 -129
  47. data/miyako_input_audio.c +24 -14
  48. data/miyako_layout.c +106 -8
  49. data/miyako_no_katana.c +398 -171
  50. data/miyako_sprite2.c +275 -38
  51. data/miyako_transform.c +113 -107
  52. data/miyako_utility.c +34 -48
  53. data/miyako_yuki.c +241 -0
  54. data/sample/Diagram_sample/diagram_sample_yuki2.rb +30 -30
  55. data/sample/Room3/blue.rb +19 -19
  56. data/sample/Room3/green.rb +9 -9
  57. data/sample/Room3/main.rb +12 -12
  58. data/sample/Room3/red.rb +12 -12
  59. data/sample/Room3/title.rb +15 -10
  60. data/sample/collision_test2.rb +2 -1
  61. data/sample/fixed_map_test/fixed_map_sample.rb +7 -6
  62. data/sample/map_test/main_scene.rb +12 -10
  63. data/sample/map_test/map_manager.rb +14 -13
  64. data/sample/rasterscroll.rb +5 -5
  65. data/sample/takahashi.rb +3 -3
  66. data/sample/textbox_sample.rb +7 -6
  67. data/sample/transform.rb +2 -1
  68. data/uninstall_miyako.rb +4 -1
  69. data/win/miyako_no_katana.so +0 -0
  70. metadata +15 -4
  71. data/lib/Miyako/EXT/miyako_cairo.rb +0 -62
  72. data/sample/cairo_sample.rb +0 -25
data/miyako_layout.c CHANGED
@@ -40,14 +40,60 @@ static volatile ID id_render = Qnil;
40
40
  static volatile ID id_to_a = Qnil;
41
41
  static volatile int zero = Qnil;
42
42
  static volatile int one = Qnil;
43
+ static const char *str_lo = "@layout";
43
44
 
44
45
  static VALUE layout_snap(int argc, VALUE *argv, VALUE self);
45
46
  static VALUE layout_move(VALUE self, VALUE dx, VALUE dy);
46
47
 
48
+ static VALUE get_layout(VALUE self)
49
+ {
50
+ return rb_iv_get(self, str_lo);
51
+ }
52
+
53
+ static VALUE layout_pos(VALUE self)
54
+ {
55
+ return *(RSTRUCT_PTR(get_layout(self)));
56
+ }
57
+
58
+ VALUE _miyako_layout_pos(VALUE self)
59
+ {
60
+ return layout_pos(self);
61
+ }
62
+
63
+ static VALUE layout_size(VALUE self)
64
+ {
65
+ return *(RSTRUCT_PTR(get_layout(self))+1);
66
+ }
67
+
68
+ VALUE _miyako_layout_size(VALUE self)
69
+ {
70
+ return layout_size(self);
71
+ }
72
+
73
+ static VALUE layout_x(VALUE self)
74
+ {
75
+ return *(RSTRUCT_PTR(layout_pos(self))+0);
76
+ }
77
+
78
+ VALUE _miyako_layout_x(VALUE self)
79
+ {
80
+ return layout_x(self);
81
+ }
82
+
83
+ static VALUE layout_y(VALUE self)
84
+ {
85
+ return *(RSTRUCT_PTR(layout_pos(self))+1);
86
+ }
87
+
88
+ VALUE _miyako_layout_y(VALUE self)
89
+ {
90
+ return layout_y(self);
91
+ }
92
+
47
93
  static VALUE layout_update_layout(VALUE self, VALUE dx, VALUE dy)
48
94
  {
49
95
  rb_funcall(self, rb_intern("update_layout_position"), 0);
50
- VALUE layout = rb_iv_get(self, "@layout");
96
+ VALUE layout = get_layout(self);
51
97
  VALUE children = *(RSTRUCT_PTR(*(RSTRUCT_PTR(layout)+3))+1);
52
98
  int i;
53
99
  for(i=0; i<RARRAY_LEN(children); i++)
@@ -59,7 +105,7 @@ static VALUE layout_update_layout(VALUE self, VALUE dx, VALUE dy)
59
105
 
60
106
  static VALUE layout_move(VALUE self, VALUE dx, VALUE dy)
61
107
  {
62
- VALUE *pos = RSTRUCT_PTR(*(RSTRUCT_PTR(rb_iv_get(self, "@layout"))));
108
+ VALUE *pos = RSTRUCT_PTR(*(RSTRUCT_PTR(get_layout(self))));
63
109
  VALUE *pox = pos+0;
64
110
  VALUE *poy = pos+1;
65
111
  VALUE tx = *pox;
@@ -67,7 +113,7 @@ static VALUE layout_move(VALUE self, VALUE dx, VALUE dy)
67
113
  *pox = INT2NUM(NUM2INT(tx)+NUM2INT(dx));
68
114
  *poy = INT2NUM(NUM2INT(ty)+NUM2INT(dy));
69
115
  layout_update_layout(self, dx, dy);
70
- VALUE on_move = *(RSTRUCT_PTR(rb_iv_get(self, "@layout")) + 4);
116
+ VALUE on_move = *(RSTRUCT_PTR(get_layout(self)) + 4);
71
117
  int i;
72
118
  for(i=0; i<RARRAY_LEN(on_move); i++)
73
119
  {
@@ -85,9 +131,14 @@ static VALUE layout_move(VALUE self, VALUE dx, VALUE dy)
85
131
  return self;
86
132
  }
87
133
 
134
+ VALUE _miyako_layout_move(VALUE self, VALUE dx, VALUE dy)
135
+ {
136
+ return layout_move(self, dx, dy);
137
+ }
138
+
88
139
  static VALUE layout_move_to(VALUE self, VALUE x, VALUE y)
89
140
  {
90
- VALUE *pos = RSTRUCT_PTR(*(RSTRUCT_PTR(rb_iv_get(self, "@layout"))));
141
+ VALUE *pos = RSTRUCT_PTR(*(RSTRUCT_PTR(get_layout(self))));
91
142
  VALUE *pox = pos+0;
92
143
  VALUE *poy = pos+1;
93
144
  VALUE tx = *pox;
@@ -97,7 +148,49 @@ static VALUE layout_move_to(VALUE self, VALUE x, VALUE y)
97
148
  VALUE dx = INT2NUM((NUM2INT(x))-(NUM2INT(tx)));
98
149
  VALUE dy = INT2NUM((NUM2INT(y))-(NUM2INT(ty)));
99
150
  layout_update_layout(self, dx, dy);
100
- VALUE on_move = *(RSTRUCT_PTR(rb_iv_get(self, "@layout")) + 4);
151
+ VALUE on_move = *(RSTRUCT_PTR(get_layout(self)) + 4);
152
+ int i;
153
+ for(i=0; i<RARRAY_LEN(on_move); i++)
154
+ {
155
+ rb_funcall(*(RARRAY_PTR(on_move) + i), rb_intern("call"), 5, self, *pox, *poy, dx, dy);
156
+ }
157
+ if(rb_block_given_p() == Qtrue){
158
+ VALUE ret = rb_yield(self);
159
+ if(ret == Qnil || ret == Qfalse)
160
+ {
161
+ *pox = tx;
162
+ *poy = ty;
163
+ layout_update_layout(self, INT2NUM(-(NUM2INT(dx))), INT2NUM(-(NUM2INT(dy))));
164
+ }
165
+ }
166
+ return self;
167
+ }
168
+
169
+ VALUE _miyako_layout_move_to(VALUE self, VALUE x, VALUE y)
170
+ {
171
+ return layout_move_to(self, x, y);
172
+ }
173
+
174
+ static VALUE layout_relative_move_to(VALUE self, VALUE x, VALUE y)
175
+ {
176
+ // bpos = @layout.base.pos
177
+ // Size.new(bpos.x+x,bpos.y+y)
178
+ VALUE *pos = RSTRUCT_PTR(*(RSTRUCT_PTR(get_layout(self))));
179
+ VALUE *pox = pos+0;
180
+ VALUE *poy = pos+1;
181
+ VALUE tx = *pox;
182
+ VALUE ty = *poy;
183
+
184
+ VALUE base = *(RSTRUCT_PTR(get_layout(self))+2);
185
+ VALUE *bpos = RSTRUCT_PTR(rb_funcall(base, rb_intern("pos"), 0));
186
+
187
+ *pox = INT2NUM(NUM2INT(x)+NUM2INT(*(bpos+0)));
188
+ *poy = INT2NUM(NUM2INT(y)+NUM2INT(*(bpos+1)));
189
+
190
+ VALUE dx = INT2NUM(NUM2INT(*pox)-NUM2INT(tx));
191
+ VALUE dy = INT2NUM(NUM2INT(*poy)-NUM2INT(ty));
192
+ layout_update_layout(self, dx, dy);
193
+ VALUE on_move = *(RSTRUCT_PTR(get_layout(self)) + 4);
101
194
  int i;
102
195
  for(i=0; i<RARRAY_LEN(on_move); i++)
103
196
  {
@@ -117,7 +210,7 @@ static VALUE layout_move_to(VALUE self, VALUE x, VALUE y)
117
210
 
118
211
  static VALUE layout_add_snap_child(VALUE self, VALUE spr)
119
212
  {
120
- VALUE layout = rb_iv_get(self, "@layout");
213
+ VALUE layout = get_layout(self);
121
214
  VALUE snap = *(RSTRUCT_PTR(layout)+3);
122
215
  VALUE children = *(RSTRUCT_PTR(snap)+1);
123
216
  if(rb_ary_includes(children, spr)==Qfalse){ rb_ary_push(children, spr); }
@@ -126,7 +219,7 @@ static VALUE layout_add_snap_child(VALUE self, VALUE spr)
126
219
 
127
220
  static VALUE layout_delete_snap_child(VALUE self, VALUE spr)
128
221
  {
129
- VALUE layout = rb_iv_get(self, "@layout");
222
+ VALUE layout = get_layout(self);
130
223
  VALUE snap = *(RSTRUCT_PTR(layout)+3);
131
224
  VALUE children = *(RSTRUCT_PTR(snap)+1);
132
225
  if(TYPE(spr) == T_ARRAY)
@@ -145,7 +238,7 @@ static VALUE layout_snap(int argc, VALUE *argv, VALUE self)
145
238
  {
146
239
  VALUE spr = Qnil;
147
240
  rb_scan_args(argc, argv, "01", &spr);
148
- VALUE layout = rb_iv_get(self, "@layout");
241
+ VALUE layout = get_layout(self);
149
242
  VALUE *sprite = RSTRUCT_PTR(*(RSTRUCT_PTR(layout)+3));
150
243
  VALUE *base = RSTRUCT_PTR(layout)+2;
151
244
  if(spr != Qnil)
@@ -182,8 +275,13 @@ void Init_miyako_layout()
182
275
  one = 1;
183
276
  nOne = INT2NUM(one);
184
277
 
278
+ rb_define_method(mLayout, "x", layout_x, 0);
279
+ rb_define_method(mLayout, "y", layout_y, 0);
280
+ rb_define_method(mLayout, "pos", layout_pos, 0);
281
+ rb_define_method(mLayout, "size", layout_size, 0);
185
282
  rb_define_method(mLayout, "move!", layout_move, 2);
186
283
  rb_define_method(mLayout, "move_to!", layout_move_to, 2);
284
+ rb_define_method(mLayout, "relative_move_to!", layout_relative_move_to, 2);
187
285
  rb_define_method(mLayout, "update_layout", layout_update_layout, 2);
188
286
  rb_define_method(mLayout, "snap", layout_snap, -1);
189
287
  rb_define_method(mLayout, "add_snap_child", layout_add_snap_child, 1);