ruby-miyako 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -1,8 +1,8 @@
1
1
  *******************************************************************************
2
2
  【 作者名 】 サイロス誠
3
3
  【 ソフト名 】 Interactive Media Authoring System "Miyako"
4
- 【 バージョン 】 2.1.1
5
- 【 作成日 】 2009/10/16
4
+ 【 バージョン 】 2.1.2
5
+ 【 作成日 】 2009/10/25
6
6
  【 種別 】 フリーウェア
7
7
  【 開発言語 】 Ruby 1.9.1
8
8
  【 ランタイム 】 Ruby 1.9.1~,Ruby/SDL 2.1~,SDL
@@ -1343,7 +1343,7 @@ v2.1.0(2009.10.9)
1343
1343
  ・Segments#max_x
1344
1344
  ・Segments#max_y
1345
1345
 
1346
- v2.1.0.1(2009.10.16)
1346
+ v2.1.1(2009.10.16)
1347
1347
  <バグ修正>
1348
1348
  ・InitiativeYuki#commandメソッドで、選択不可の選択肢を選んだときにメソッド処理が終了するバグを修正
1349
1349
  ・Font#draw_textメソッドで、文字を転送先画像の外で描画するとSEGVを起こす問題を修正
@@ -1366,5 +1366,37 @@ v2.1.0.1(2009.10.16)
1366
1366
  ・WaitCounter#stop_callback_inner
1367
1367
  <インスタンスメソッド廃止>
1368
1368
 
1369
+ v2.1.2(2009.10.25)
1370
+ <バグ修正>
1371
+ ・Plane#render,render_toメソッドで、画面より小さいスプライトを描画しようとしても何も描画されないバグを修正
1372
+ ・Plane#move!,move_to!メソッドで、描画時に画面の左上が描画されない時があるバグを修正
1373
+ ・Plane#move,move_toメソッドが、move!、move_to!と全く同じ動作をするバグを修正
1374
+ <機能改善>
1375
+ ・各種render_toメソッドでの内部処理の安全性を高めた
1376
+ <仕様変更>
1377
+ ・Sprite#part_move!,move_to!,resize!,resize_to!などのメソッドで、部分矩形の大きさを自動的に補正する処理を廃止
1378
+ ・Sprite#ox=,oh=,ow=,oh=で、画像の範囲外の値を設定すると例外が発生する処理を廃止
1379
+ <ファイル追加>
1380
+ <ファイル削除>
1381
+ <グローバル変数追加>
1382
+ <定数追加>
1383
+ <定数削除>
1384
+ <構造体追加>
1385
+ <クラス追加>
1386
+ <モジュール追加>
1387
+ <mixin>
1388
+ <クラス・モジュールメソッド追加>
1389
+ <クラス・モジュールメソッド廃止>
1390
+ <インスタンスメソッド追加>
1391
+ ・Sprite#render_rect
1392
+ ・Sprite#render_rect_to
1393
+ ・Sprite#render_rect2
1394
+ ・Sprite#render_rect2_to
1395
+ ・Sprite#render_rect_xy
1396
+ ・Sprite#render_rect_xy_to
1397
+ ・Sprite#render_rect2_xy
1398
+ ・Sprite#render_rect2_xy_to
1399
+ <インスタンスメソッド廃止>
1400
+
1369
1401
  *******************************************************************************
1370
1402
  このReadMeファイルは「れ~どめ~えじた~」によって作成されました。
@@ -69,6 +69,14 @@ module Miyako
69
69
  return @pos.y
70
70
  end
71
71
 
72
+ def adjust_pos(pos) #:nodocs:
73
+ pos.x %= @sprite.ow if pos.x >= @sprite.ow || pos.x <= -@sprite.ow
74
+ pos.y %= @sprite.oh if pos.y >= @sprite.oh || pos.y <= -@sprite.oh
75
+ return pos
76
+ end
77
+
78
+ private :adjust_pos
79
+
72
80
  #===プレーンの表示位置を移動させる
73
81
  #画像スクロールと同じ効果を得る
74
82
  #_dx_:: 移動量(x 座標)
@@ -76,8 +84,7 @@ module Miyako
76
84
  #返却値:: 自分自身を返す
77
85
  def move!(dx, dy)
78
86
  @pos.move!(dx, dy)
79
- @pos.x %= @sprite.ow if @pos.x >= @sprite.ow || @pos.x <= -@sprite.ow
80
- @pos.y %= @sprite.oh if @pos.y >= @sprite.oh || @pos.y <= -@sprite.oh
87
+ @pos = adjust_pos(@pos)
81
88
  return self
82
89
  end
83
90
 
@@ -88,8 +95,7 @@ module Miyako
88
95
  #返却値:: 自分自身を返す
89
96
  def move_to!(x, y)
90
97
  @pos.move_to!(x, y)
91
- @pos.x %= @screen.ow if @pos.x >= @sprite.ow || @pos.x <= -@sprite.ow
92
- @pos.y %= @screen.oh if @pos.y >= @sprite.oh || @pos.y <= -@sprite.oh
98
+ @pos = adjust_pos(@pos)
93
99
  return self
94
100
  end
95
101
 
@@ -99,11 +105,8 @@ module Miyako
99
105
  #_dx_:: 移動量(x 座標)
100
106
  #_dy_:: 移動量(y 座標)
101
107
  #返却値:: 変更したPosition構造体を返す
102
- def move!(dx, dy)
103
- @pos.move!(dx, dy)
104
- @pos.x %= @sprite.ow if @pos.x >= @sprite.ow || @pos.x <= -@sprite.ow
105
- @pos.y %= @sprite.oh if @pos.y >= @sprite.oh || @pos.y <= -@sprite.oh
106
- return self
108
+ def move(dx, dy)
109
+ return adjust_pos(@pos.move(dx, dy))
107
110
  end
108
111
 
109
112
  #===プレーンの表示位置を移動させたときの位置を求める(移動位置指定)
@@ -112,11 +115,8 @@ module Miyako
112
115
  #_x_:: 移動先の位置(x 座標)
113
116
  #_y_:: 移動先の位置(y 座標)
114
117
  #返却値:: 変更したPosition構造体を返す
115
- def move_to!(x, y)
116
- @pos.move_to!(x, y)
117
- @pos.x %= @screen.ow if @pos.x >= @sprite.ow || @pos.x <= -@sprite.ow
118
- @pos.y %= @screen.oh if @pos.y >= @sprite.oh || @pos.y <= -@sprite.oh
119
- return self
118
+ def move_to(x, y)
119
+ return adjust_pos(@pos.move_to(x, y))
120
120
  end
121
121
 
122
122
  #===画像の表示矩形を取得する
@@ -138,23 +138,6 @@ module Miyako
138
138
  @sprite.dispose
139
139
  end
140
140
 
141
- #===画面に描画を指示する
142
- #現在表示できるプレーンを、現在の状態で描画するよう指示する
143
- #--
144
- #(但し、実際に描画されるのはScreen.renderメソッドが呼び出された時)
145
- #++
146
- #返却値:: 自分自身を返す
147
- def render
148
- @size.h.times{|y|
149
- @size.w.times{|x|
150
- u = @sprite.to_unit
151
- u.move_to!(x * @sprite.ow + @pos.x, y * @sprite.oh + @pos.y)
152
- Screen.render_screen(u) if u.x >= 0 && u.y >= 0 && u.x + u.ow <= Screen.bitmap.w && u.y + u.oh <= Screen.bitmap.h
153
- }
154
- }
155
- return self
156
- end
157
-
158
141
  #===描画の素になるスプライトのアニメーションを更新する
159
142
  #返却値:: 更新した結果、パターンが変わった・アニメーションが終了したときはtrue、それ以外はfalseを返す
160
143
  def update_animation
@@ -190,6 +173,12 @@ module Miyako
190
173
  #画面の描画範囲は、src側SpriteUnitの(x,y)を起点に、タイリングを行いながら貼り付ける。
191
174
  #visibleメソッドの値がfalseのときは描画されない。
192
175
  def render
176
+ @size.h.times{|y|
177
+ @size.w.times{|x|
178
+ @sprite.render_xy(x * @sprite.ow + @pos.x, y * @sprite.oh + @pos.y)
179
+ }
180
+ }
181
+ return self
193
182
  end
194
183
 
195
184
  #===プレーンを画像に描画する
@@ -198,6 +187,12 @@ module Miyako
198
187
  #visibleメソッドの値がfalseのときは描画されない。
199
188
  #_dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
200
189
  def render_to(dst)
190
+ @size.h.times{|y|
191
+ @size.w.times{|x|
192
+ @sprite.render_xy_to(dst, x * @sprite.ow + @pos.x, y * @sprite.oh + @pos.y)
193
+ }
194
+ }
195
+ return self
201
196
  end
202
197
 
203
198
  def_delegators(:sprite)
@@ -248,7 +248,6 @@ module Miyako
248
248
  #値が画像の幅の範囲外(値がマイナス、画像の幅を超える値)のときは例外が発生する
249
249
  #_v_:: 表示開始位置。整数で指定
250
250
  def ox=(v)
251
- raise MiyakoValueError, "Illegal ox parameter! : #{v} (range: 0..#{@w-@unit.ow})" if (v < 0 || (v+@unit.ow) > @w)
252
251
  @unit.ox = v
253
252
  end
254
253
 
@@ -257,7 +256,6 @@ module Miyako
257
256
  #値が画像の高さの範囲外(値がマイナス、画像の高さを超える値)のときは例外が発生する
258
257
  #_v_:: 表示開始位置。整数で指定
259
258
  def oy=(v)
260
- raise MiyakoValueError, "Illegal oy parameter! : #{v} (range: 0..#{@h-@unit.oh})" if (v < 0 || (v+@unit.oh) > @h)
261
259
  @unit.oy = v
262
260
  end
263
261
 
@@ -266,7 +264,6 @@ module Miyako
266
264
  #値が画像の幅の範囲外(値がマイナス、画像の幅を超える値)のときは例外が発生する
267
265
  #_v_:: 表示幅。整数で指定
268
266
  def ow=(v)
269
- raise MiyakoValueError, "Illegal ox parameter! : #{v} (range: 0..#{@w-@unit.ox})" if (v < 0 || (@unit.ox+v) > @w)
270
267
  @unit.ow = v
271
268
  set_layout_size(v, @unit.oh)
272
269
  end
@@ -276,7 +273,6 @@ module Miyako
276
273
  #値が画像の高さの範囲外(値がマイナス、画像の高さを超える値)のときは例外が発生する
277
274
  #_v_:: 表示高。整数で指定
278
275
  def oh=(v)
279
- raise MiyakoValueError, "Illegal ox parameter! : #{v} (range: 0..#{@h-@unit.oy})" if (v < 0 || (@unit.oy+v) > @h)
280
276
  @unit.oh = v
281
277
  set_layout_size(@unit.ow, v)
282
278
  end
@@ -288,30 +284,30 @@ module Miyako
288
284
  end
289
285
 
290
286
  def adjust_part(ox, oy, ow, oh)
291
- if ox < 0
292
- ow += ox
293
- ox = 0
294
- end
295
- if oy < 0
296
- oh += oy
297
- oy = 0
298
- end
299
- ow = 1 if ow <= 0
300
- oh = 1 if oh <= 0
301
- if ox + ow > w
302
- ow = w - ox
303
- if ow == 0
304
- ox -= 1
305
- ow = 1
306
- end
307
- end
308
- if oy + oh > h
309
- oh = h - oy
310
- if oh == 0
311
- oy -= 1
312
- oh = 1
313
- end
314
- end
287
+ # if ox < 0
288
+ # ow += ox
289
+ # ox = 0
290
+ # end
291
+ # if oy < 0
292
+ # oh += oy
293
+ # oy = 0
294
+ # end
295
+ # ow = 1 if ow <= 0
296
+ # oh = 1 if oh <= 0
297
+ # if ox + ow > w
298
+ # ow = w - ox
299
+ # if ow == 0
300
+ # ox -= 1
301
+ # ow = 1
302
+ # end
303
+ # end
304
+ # if oy + oh > h
305
+ # oh = h - oy
306
+ # if oh == 0
307
+ # oy -= 1
308
+ # oh = 1
309
+ # end
310
+ # end
315
311
  Rect.new(ox,oy,ow,oh)
316
312
  end
317
313
 
@@ -562,29 +558,24 @@ module Miyako
562
558
  def render_to(dst)
563
559
  end
564
560
 
565
- #===インスタンスの内容を画面に描画する
566
- #現在の画像を、現在の状態で描画するよう指示する
567
- #ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る)
568
- #(ブロック引数のインスタンスは複写しているので、メソッドの引数として渡した値が持つSpriteUnitには影響しない)
569
- #ブロックの引数は、|インスタンスのSpriteUnit, 画面のSpriteUnit|となる。
561
+ #===インスタンスの内容を画面の指定の位置に描画する
562
+ #画像を画面の[x,y]の位置を開始点として描画する
563
+ #このメソッドでは、あらかじめ持っている描画開始位置を無視して描画する
570
564
  #visibleメソッドの値がfalseのときは描画されない。
571
565
  #返却値:: 自分自身を返す
572
566
  def render_xy(x,y)
573
567
  end
574
568
 
575
- #===インスタンスの内容を別のインスタンスに描画する
576
- #転送元の描画範囲は、src側SpriteUnitの(ox,oy)を起点に、src側(ow,oh)の範囲で転送する。
577
- #画面の描画範囲は、src側SpriteUnitの(x,y)を起点に設定にする。
578
- #ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る)
579
- #(ブロック引数のインスタンスは複写しているので、メソッドの引数として渡した値が持つSpriteUnitには影響しない)
580
- #ブロックの引数は、|インスタンスのSpriteUnit,転送先のSpriteUnit|となる。
569
+ #===インスタンスの内容を別のインスタンスの指定の位置に描画する
570
+ #画像を大正の画像の[x,y]位置を開始点として描画する
571
+ #このメソッドでは、あらかじめ持っている描画開始位置を無視して描画する
581
572
  #visibleメソッドの値がfalseのときは描画されない。
582
573
  #_dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
583
574
  #返却値:: 自分自身を返す
584
575
  def render_xy_to(dst,x,y)
585
576
  end
586
577
 
587
- #===インスタンスの内容を画面に描画する
578
+ #===部分矩形の一部分を画面に描画する
588
579
  #現在の画像を、現在の状態で描画するよう指示する
589
580
  #ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る)
590
581
  #(ブロック引数のインスタンスは複写しているので、メソッドの引数として渡した値が持つSpriteUnitには影響しない)
@@ -594,7 +585,7 @@ module Miyako
594
585
  def render_rect(rect)
595
586
  end
596
587
 
597
- #===インスタンスの内容を別のインスタンスに描画する
588
+ #===部分矩形の一部分を別のインスタンスに描画する
598
589
  #転送元の描画範囲は、src側SpriteUnitの(ox,oy)を起点に、src側(ow,oh)の範囲で転送する。
599
590
  #画面の描画範囲は、src側SpriteUnitの(x,y)を起点に設定にする。
600
591
  #ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る)
@@ -606,50 +597,71 @@ module Miyako
606
597
  def render_rect_to(dst,rect)
607
598
  end
608
599
 
609
- #===インスタンスの内容を画面に描画する
610
- #現在の画像を、現在の状態で描画するよう指示する
611
- #ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る)
612
- #(ブロック引数のインスタンスは複写しているので、メソッドの引数として渡した値が持つSpriteUnitには影響しない)
613
- #ブロックの引数は、|インスタンスのSpriteUnit, 画面のSpriteUnit|となる。
600
+ #===画像の一部分を画面に描画する
601
+ #画像の一部分(rect構造体で示した矩形)を画面に描画する
602
+ #このメソッドでは、部分矩形を無視して描画する
614
603
  #visibleメソッドの値がfalseのときは描画されない。
604
+ #_rect_:: Rect構造体
615
605
  #返却値:: 自分自身を返す
616
606
  def render_rect2(rect)
617
607
  end
618
608
 
619
- #===インスタンスの内容を別のインスタンスに描画する
620
- #転送元の描画範囲は、src側SpriteUnitの(ox,oy)を起点に、src側(ow,oh)の範囲で転送する。
621
- #画面の描画範囲は、src側SpriteUnitの(x,y)を起点に設定にする。
622
- #ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る)
623
- #(ブロック引数のインスタンスは複写しているので、メソッドの引数として渡した値が持つSpriteUnitには影響しない)
624
- #ブロックの引数は、|インスタンスのSpriteUnit,転送先のSpriteUnit|となる。
609
+ #===画像の一部分を別のインスタンスに描画する
610
+ #画像の一部分(rect構造体で示した矩形)を別のスプライトに描画する
611
+ #このメソッドでは、部分矩形を無視して描画する
625
612
  #visibleメソッドの値がfalseのときは描画されない。
626
613
  #_dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
614
+ #_rect_:: Rect構造体
627
615
  #返却値:: 自分自身を返す
628
616
  def render_rect2_to(dst,rect)
629
617
  end
630
618
 
631
- #===インスタンスの内容を画面に描画する
632
- #現在の画像を、現在の状態で描画するよう指示する
633
- #ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る)
634
- #(ブロック引数のインスタンスは複写しているので、メソッドの引数として渡した値が持つSpriteUnitには影響しない)
635
- #ブロックの引数は、|インスタンスのSpriteUnit, 画面のSpriteUnit|となる。
619
+ #===部分矩形の一部分を画面の指定の位置に描画する
620
+ #画像の一部分(rect構造体で示した矩形)を画面の[x,y]の位置を開始点として描画する
621
+ #このメソッドでは、あらかじめ持っている描画開始位置を無視して描画する
636
622
  #visibleメソッドの値がfalseのときは描画されない。
623
+ #_rect_:: Rect構造体
624
+ #_x_:: 描画開始位置(x座標)
625
+ #_y_:: 描画開始位置(y座標)
637
626
  #返却値:: 自分自身を返す
638
627
  def render_rect_xy(rect,x,y)
639
628
  end
640
629
 
641
- #===インスタンスの内容を別のインスタンスに描画する
642
- #転送元の描画範囲は、src側SpriteUnitの(ox,oy)を起点に、src側(ow,oh)の範囲で転送する。
643
- #画面の描画範囲は、src側SpriteUnitの(x,y)を起点に設定にする。
644
- #ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る)
645
- #(ブロック引数のインスタンスは複写しているので、メソッドの引数として渡した値が持つSpriteUnitには影響しない)
646
- #ブロックの引数は、|インスタンスのSpriteUnit,転送先のSpriteUnit|となる。
630
+ #===部分矩形の一部分を別のインスタンスの指定の位置にに描画する
631
+ #画像の一部分(rect構造体で示した矩形)をスプライトの[x,y]の位置を開始点として描画する
632
+ #このメソッドでは、あらかじめ持っている描画開始位置を無視して描画する
647
633
  #visibleメソッドの値がfalseのときは描画されない。
648
634
  #_dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
635
+ #_rect_:: Rect構造体
636
+ #_x_:: 描画開始位置(x座標)
637
+ #_y_:: 描画開始位置(y座標)
649
638
  #返却値:: 自分自身を返す
650
639
  def render_rect_xy_to(dst,rect,x,y)
651
640
  end
652
641
 
642
+ #===画像の一部分を画面の指定の位置に描画する
643
+ #画像の一部分(rect構造体で示した矩形)を画面の[x,y]の位置を開始点として描画する
644
+ #このメソッドでは、あらかじめ持っている描画開始位置と部分矩形を無視して描画する
645
+ #visibleメソッドの値がfalseのときは描画されない。
646
+ #_rect_:: Rect構造体
647
+ #_x_:: 描画開始位置(x座標)
648
+ #_y_:: 描画開始位置(y座標)
649
+ #返却値:: 自分自身を返す
650
+ def render_rect2_xy(rect,x,y)
651
+ end
652
+
653
+ #===画像の一部分を別のインスタンスの指定の位置にに描画する
654
+ #画像の一部分(rect構造体で示した矩形)をスプライトの[x,y]の位置を開始点として描画する
655
+ #このメソッドでは、あらかじめ持っている描画開始位置と部分矩形を無視して描画する
656
+ #visibleメソッドの値がfalseのときは描画されない。
657
+ #_dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
658
+ #_rect_:: Rect構造体
659
+ #_x_:: 描画開始位置(x座標)
660
+ #_y_:: 描画開始位置(y座標)
661
+ #返却値:: 自分自身を返す
662
+ def render_rect2_xy_to(dst,rect,x,y)
663
+ end
664
+
653
665
  #===インスタンスの内容を画面に描画する(回転/拡大/縮小/鏡像付き)
654
666
  #転送元の描画範囲は、src側SpriteUnitの(ox,oy)を起点に、src側(ow,oh)の範囲で転送する。回転の中心はsrc側(ox,oy)を起点に、src側(cx,cy)が中心になるように設定する。
655
667
  #画面の描画範囲は、src側SpriteUnitの(x,y)を起点に、画面側SpriteUnitの(cx,cy)が中心になるように設定にする。
data/lib/Miyako/miyako.rb CHANGED
@@ -60,7 +60,7 @@ Thread.abort_on_exception = true
60
60
 
61
61
  #==Miyako基幹モジュール
62
62
  module Miyako
63
- VERSION = "2.1.1"
63
+ VERSION = "2.1.2"
64
64
 
65
65
  #===アプリケーション実行中に演奏する音楽のサンプリングレートを指定する
66
66
  #単位はHz(周波数)
data/miyako_no_katana.c CHANGED
@@ -37,6 +37,7 @@ static VALUE mInput = Qnil;
37
37
  static VALUE mSpriteBase = Qnil;
38
38
  static VALUE mAnimation = Qnil;
39
39
  static VALUE mDiagram = Qnil;
40
+ static VALUE eMiyakoError = Qnil;
40
41
  static VALUE cSurface = Qnil;
41
42
  static VALUE cGL = Qnil;
42
43
  static VALUE cFont = Qnil;
@@ -119,34 +120,77 @@ static VALUE miyako_main_loop(int argc, VALUE *argv, VALUE self)
119
120
  return Qnil;
120
121
  }
121
122
 
123
+ /*
124
+ :nodoc:
125
+ */
126
+ static VALUE sprite_get_rect(VALUE src, int *dst)
127
+ {
128
+ int i;
129
+ VALUE *tmp;
130
+ switch(TYPE(src))
131
+ {
132
+ case T_ARRAY:
133
+ if(RARRAY_LEN(src) < 4)
134
+ rb_raise(eMiyakoError, "rect needs 4 or much elements!");
135
+ tmp = RARRAY_PTR(src);
136
+ for(i=0; i<4; i++){ *dst++ = NUM2INT(*tmp++); }
137
+ break;
138
+ case T_STRUCT:
139
+ if(RSTRUCT_LEN(src) < 4)
140
+ rb_raise(eMiyakoError, "rect needs 4 or much members!");
141
+ tmp = RSTRUCT_PTR(src);
142
+ for(i=0; i<4; i++){ *dst++ = NUM2INT(*tmp++); }
143
+ break;
144
+ default:
145
+ *(dst+0) = NUM2INT(rb_funcall(src, rb_intern("x"), 0));
146
+ *(dst+1) = NUM2INT(rb_funcall(src, rb_intern("y"), 0));
147
+ *(dst+2) = NUM2INT(rb_funcall(src, rb_intern("w"), 0));
148
+ *(dst+3) = NUM2INT(rb_funcall(src, rb_intern("h"), 0));
149
+ break;
150
+ }
151
+ return Qnil;
152
+ }
153
+
122
154
  /*
123
155
  ===内部用レンダメソッド
124
156
  */
125
157
  static void render_to_inner(MiyakoBitmap *sb, MiyakoBitmap *db)
126
158
  {
127
- if(sb->ptr == db->ptr){ return; }
159
+ if(sb->ptr == db->ptr){ return; }
128
160
 
129
- MiyakoSize size;
161
+ MiyakoSize size;
130
162
  if(_miyako_init_rect(sb, db, &size) == 0) return;
131
163
 
132
- SDL_LockSurface(sb->surface);
133
- SDL_LockSurface(db->surface);
164
+ SDL_LockSurface(sb->surface);
165
+ SDL_LockSurface(db->surface);
166
+
167
+ int x, y;
168
+ for(y = 0; y < size.h; y++)
169
+ {
170
+ Uint32 src_y = (sb->rect.y + y);
171
+ Uint32 dst_y = (db->rect.y + sb->y + y);
172
+ Uint32 src_x = sb->rect.x;
173
+ Uint32 dst_x = db->rect.x + sb->x;
174
+
175
+ if(src_y < 0 || dst_y < 0){ continue; }
176
+ if(src_y >= sb->surface->h || dst_y >= db->surface->h){ break; }
134
177
 
135
- int x, y;
136
- for(y = 0; y < size.h; y++)
137
- {
138
- Uint32 *psrc = sb->ptr + (sb->rect.y + y) * sb->surface->w + sb->rect.x;
139
- Uint32 *pdst = db->ptr + (db->rect.y + sb->y + y) * db->surface->w + db->rect.x + sb->x;
140
- for(x = 0; x < size.w; x++)
141
- {
178
+ Uint32 *psrc = sb->ptr + src_y * sb->surface->w + src_x;
179
+ Uint32 *pdst = db->ptr + dst_y * db->surface->w + dst_x;
180
+ for(x = 0; x < size.w; x++)
181
+ {
182
+ if(src_x < 0 || dst_x < 0){ psrc++; pdst++; src_x++; dst_x++; continue; }
183
+ if(src_x >= sb->surface->w || dst_x >= db->surface->w){ break; }
142
184
  #if SDL_BYTEORDER == SDL_LIL_ENDIAN
143
185
  sb->color.a = (*psrc >> 24) & 0xff | sb->a255;
144
- if(sb->color.a == 0){ psrc++; pdst++; continue; }
186
+ if(sb->color.a == 0){ psrc++; pdst++; src_x++; dst_x++; continue; }
145
187
  db->color.a = (*pdst >> 24) & 0xff | db->a255;
146
188
  if(db->color.a == 0 || sb->color.a == 255){
147
189
  *pdst = *psrc | (sb->a255 << 24);
148
190
  psrc++;
149
191
  pdst++;
192
+ src_x++;
193
+ dst_x++;
150
194
  continue;
151
195
  }
152
196
  int a1 = sb->color.a + 1;
@@ -157,18 +201,20 @@ static void render_to_inner(MiyakoBitmap *sb, MiyakoBitmap *db)
157
201
  db->color.r = (*pdst >> 16) & 0xff;
158
202
  db->color.g = (*pdst >> 8) & 0xff;
159
203
  db->color.b = (*pdst ) & 0xff;
160
- *pdst = ((sb->color.r * a1 + db->color.r * a2) >> 8) << 16 |
161
- ((sb->color.g * a1 + db->color.g * a2) >> 8) << 8 |
162
- ((sb->color.b * a1 + db->color.b * a2) >> 8) |
163
- 0xff << 24;
204
+ *pdst = ((sb->color.r * a1 + db->color.r * a2) >> 8) << 16 |
205
+ ((sb->color.g * a1 + db->color.g * a2) >> 8) << 8 |
206
+ ((sb->color.b * a1 + db->color.b * a2) >> 8) |
207
+ 0xff << 24;
164
208
  #else
165
209
  sb->color.a = (*psrc & sb->fmt->Amask) | sb->a255;
166
- if(sb->color.a == 0){ psrc++; pdst++; continue; }
210
+ if(sb->color.a == 0){ psrc++; pdst++; src_x++; dst_x++; continue; }
167
211
  db->color.a = (*pdst & db->fmt->Amask) | db->a255;
168
212
  if(db->color.a == 0 || sb->color.a == 255){
169
213
  *pdst = *psrc | sb->a255;
170
214
  psrc++;
171
215
  pdst++;
216
+ src_x++;
217
+ dst_x++;
172
218
  continue;
173
219
  }
174
220
  int a1 = sb->color.a + 1;
@@ -179,18 +225,20 @@ static void render_to_inner(MiyakoBitmap *sb, MiyakoBitmap *db)
179
225
  db->color.r = (*pdst & db->fmt->Rmask) >> db->fmt->Rshift;
180
226
  db->color.g = (*pdst & db->fmt->Gmask) >> db->fmt->Gshift;
181
227
  db->color.b = (*pdst & db->fmt->Bmask) >> db->fmt->Bshift;
182
- *pdst = ((sb->color.r * a1 + db->color.r * a2) >> 8) << db->fmt->Rshift |
183
- ((sb->color.g * a1 + db->color.g * a2) >> 8) << db->fmt->Gshift |
184
- ((sb->color.b * a1 + db->color.b * a2) >> 8) << db->fmt->Bshift |
185
- 0xff;
228
+ *pdst = ((sb->color.r * a1 + db->color.r * a2) >> 8) << db->fmt->Rshift |
229
+ ((sb->color.g * a1 + db->color.g * a2) >> 8) << db->fmt->Gshift |
230
+ ((sb->color.b * a1 + db->color.b * a2) >> 8) << db->fmt->Bshift |
231
+ 0xff;
186
232
  #endif
187
233
  psrc++;
188
234
  pdst++;
235
+ src_x++;
236
+ dst_x++;
189
237
  }
190
238
  }
191
239
 
192
- SDL_UnlockSurface(sb->surface);
193
- SDL_UnlockSurface(db->surface);
240
+ SDL_UnlockSurface(sb->surface);
241
+ SDL_UnlockSurface(db->surface);
194
242
  }
195
243
 
196
244
  /*
@@ -198,8 +246,8 @@ static void render_to_inner(MiyakoBitmap *sb, MiyakoBitmap *db)
198
246
  */
199
247
  static void render_inner(MiyakoBitmap *sb, MiyakoBitmap *db)
200
248
  {
201
- db->rect.x += sb->x;
202
- db->rect.y += sb->y;
249
+ db->rect.x += sb->x;
250
+ db->rect.y += sb->y;
203
251
  SDL_BlitSurface(sb->surface, &(sb->rect), db->surface, &(db->rect));
204
252
  }
205
253
 
@@ -299,8 +347,8 @@ VALUE _miyako_sprite_render(VALUE sprite)
299
347
  static VALUE sprite_render_to_sprite(VALUE self, VALUE vdst)
300
348
  {
301
349
  if(rb_iv_get(self, str_visible) == Qfalse) return self;
302
- MiyakoBitmap src, dst;
303
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
350
+ MiyakoBitmap src, dst;
351
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
304
352
  _miyako_setup_unit_2(self, vdst, scr, &src, &dst, Qnil, Qnil, 1);
305
353
  render_to_inner(&src, &dst);
306
354
  return self;
@@ -349,8 +397,8 @@ static VALUE sprite_render_xy_to_sprite(VALUE self, VALUE vdst, VALUE vx, VALUE
349
397
  {
350
398
  VALUE visible = rb_iv_get(self, str_visible);
351
399
  if(visible == Qfalse) return self;
352
- MiyakoBitmap src, dst;
353
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
400
+ MiyakoBitmap src, dst;
401
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
354
402
  _miyako_setup_unit_2(self, vdst, scr, &src, &dst, Qnil, Qnil, 1);
355
403
  src.x = NUM2INT(vx);
356
404
  src.y = NUM2INT(vy);
@@ -358,6 +406,224 @@ static VALUE sprite_render_xy_to_sprite(VALUE self, VALUE vdst, VALUE vx, VALUE
358
406
  return self;
359
407
  }
360
408
 
409
+ /*
410
+ インスタンスの内容を画面に描画する
411
+ */
412
+ static VALUE sprite_render_rect(VALUE self, VALUE vrect)
413
+ {
414
+ if(rb_iv_get(self, str_visible) == Qfalse) return self;
415
+
416
+ int rect[4];
417
+ sprite_get_rect(vrect, &(rect[0]));
418
+
419
+ VALUE src_unit = rb_iv_get(self, "@unit");
420
+ VALUE dst_unit = rb_iv_get(mScreen, "@@unit");
421
+
422
+ SDL_Surface *src = GetSurface(*(RSTRUCT_PTR(src_unit)+0))->surface;
423
+ SDL_Surface *dst = GetSurface(*(RSTRUCT_PTR(dst_unit)+0))->surface;
424
+
425
+ SDL_Rect srect, drect;
426
+
427
+ VALUE *s_p = RSTRUCT_PTR(src_unit);
428
+ srect.x = NUM2INT(*(s_p + 1)) + rect[0];
429
+ srect.y = NUM2INT(*(s_p + 2)) + rect[1];
430
+ srect.w = rect[2];
431
+ srect.h = rect[3];
432
+
433
+ VALUE *d_p = RSTRUCT_PTR(dst_unit);
434
+ drect.x = NUM2INT(*(d_p + 1));
435
+ drect.y = NUM2INT(*(d_p + 2));
436
+ drect.w = NUM2INT(*(d_p + 3));
437
+ drect.h = NUM2INT(*(d_p + 4));
438
+
439
+ SDL_BlitSurface(src, &srect, dst, &drect);
440
+ return self;
441
+ }
442
+
443
+ /*
444
+ インスタンスの内容を別のインスタンスに描画する
445
+ */
446
+ static VALUE sprite_render_rect_to_sprite(VALUE self, VALUE vdst, VALUE vrect)
447
+ {
448
+ VALUE visible = rb_iv_get(self, str_visible);
449
+ if(visible == Qfalse) return self;
450
+ int rect[4];
451
+ sprite_get_rect(vrect, &(rect[0]));
452
+ MiyakoBitmap src, dst;
453
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
454
+ _miyako_setup_unit_2(self, vdst, scr, &src, &dst, Qnil, Qnil, 1);
455
+ src.rect.x += rect[0];
456
+ src.rect.y += rect[1];
457
+ src.rect.w = rect[2];
458
+ src.rect.h = rect[3];
459
+ render_to_inner(&src, &dst);
460
+ return self;
461
+ }
462
+
463
+ /*
464
+ インスタンスの内容を画面に描画する
465
+ */
466
+ static VALUE sprite_render_rect2(VALUE self, VALUE vrect)
467
+ {
468
+ if(rb_iv_get(self, str_visible) == Qfalse) return self;
469
+
470
+ int rect[4];
471
+ sprite_get_rect(vrect, &(rect[0]));
472
+
473
+ VALUE src_unit = rb_iv_get(self, "@unit");
474
+ VALUE dst_unit = rb_iv_get(mScreen, "@@unit");
475
+
476
+ SDL_Surface *src = GetSurface(*(RSTRUCT_PTR(src_unit)+0))->surface;
477
+ SDL_Surface *dst = GetSurface(*(RSTRUCT_PTR(dst_unit)+0))->surface;
478
+
479
+ SDL_Rect srect, drect;
480
+
481
+ srect.x = rect[0];
482
+ srect.y = rect[1];
483
+ srect.w = rect[2];
484
+ srect.h = rect[3];
485
+
486
+ VALUE *d_p = RSTRUCT_PTR(dst_unit);
487
+ drect.x = NUM2INT(*(d_p + 1));
488
+ drect.y = NUM2INT(*(d_p + 2));
489
+ drect.w = NUM2INT(*(d_p + 3));
490
+ drect.h = NUM2INT(*(d_p + 4));
491
+
492
+ SDL_BlitSurface(src, &srect, dst, &drect);
493
+ return self;
494
+ }
495
+
496
+ /*
497
+ インスタンスの内容を別のインスタンスに描画する
498
+ */
499
+ static VALUE sprite_render_rect2_to_sprite(VALUE self, VALUE vdst, VALUE vrect)
500
+ {
501
+ VALUE visible = rb_iv_get(self, str_visible);
502
+ if(visible == Qfalse) return self;
503
+ int rect[4];
504
+ sprite_get_rect(vrect, &(rect[0]));
505
+ MiyakoBitmap src, dst;
506
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
507
+ _miyako_setup_unit_2(self, vdst, scr, &src, &dst, Qnil, Qnil, 1);
508
+ src.rect.x = rect[0];
509
+ src.rect.y = rect[1];
510
+ src.rect.w = rect[2];
511
+ src.rect.h = rect[3];
512
+ render_to_inner(&src, &dst);
513
+ return self;
514
+ }
515
+
516
+ /*
517
+ インスタンスの内容を画面に描画する
518
+ */
519
+ static VALUE sprite_render_rect_xy(VALUE self, VALUE vrect, VALUE vx, VALUE vy)
520
+ {
521
+ if(rb_iv_get(self, str_visible) == Qfalse) return self;
522
+
523
+ int rect[4];
524
+ sprite_get_rect(vrect, &(rect[0]));
525
+
526
+ VALUE src_unit = rb_iv_get(self, "@unit");
527
+ VALUE dst_unit = rb_iv_get(mScreen, "@@unit");
528
+
529
+ SDL_Surface *src = GetSurface(*(RSTRUCT_PTR(src_unit)+0))->surface;
530
+ SDL_Surface *dst = GetSurface(*(RSTRUCT_PTR(dst_unit)+0))->surface;
531
+
532
+ SDL_Rect srect, drect;
533
+
534
+ VALUE *s_p = RSTRUCT_PTR(src_unit);
535
+ srect.x = NUM2INT(*(s_p + 1)) + rect[0];
536
+ srect.y = NUM2INT(*(s_p + 2)) + rect[1];
537
+ srect.w = rect[2];
538
+ srect.h = rect[3];
539
+
540
+ VALUE *d_p = RSTRUCT_PTR(dst_unit);
541
+ drect.x = NUM2INT(*(d_p + 1)) + NUM2INT(vx);
542
+ drect.y = NUM2INT(*(d_p + 2)) + NUM2INT(vy);
543
+ drect.w = NUM2INT(*(d_p + 3));
544
+ drect.h = NUM2INT(*(d_p + 4));
545
+
546
+ SDL_BlitSurface(src, &srect, dst, &drect);
547
+ return self;
548
+ }
549
+
550
+ /*
551
+ インスタンスの内容を別のインスタンスに描画する
552
+ */
553
+ static VALUE sprite_render_rect_xy_to_sprite(VALUE self, VALUE vdst, VALUE vrect, VALUE vx, VALUE vy)
554
+ {
555
+ VALUE visible = rb_iv_get(self, str_visible);
556
+ if(visible == Qfalse) return self;
557
+ int rect[4];
558
+ sprite_get_rect(vrect, &(rect[0]));
559
+ MiyakoBitmap src, dst;
560
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
561
+ _miyako_setup_unit_2(self, vdst, scr, &src, &dst, Qnil, Qnil, 1);
562
+ src.rect.x += rect[0];
563
+ src.rect.y += rect[1];
564
+ src.rect.w = rect[2];
565
+ src.rect.h = rect[3];
566
+ src.x = NUM2INT(vx);
567
+ src.y = NUM2INT(vy);
568
+ render_to_inner(&src, &dst);
569
+ return self;
570
+ }
571
+
572
+ /*
573
+ インスタンスの内容を画面に描画する
574
+ */
575
+ static VALUE sprite_render_rect2_xy(VALUE self, VALUE vrect, VALUE vx, VALUE vy)
576
+ {
577
+ if(rb_iv_get(self, str_visible) == Qfalse) return self;
578
+
579
+ int rect[4];
580
+ sprite_get_rect(vrect, &(rect[0]));
581
+
582
+ VALUE src_unit = rb_iv_get(self, "@unit");
583
+ VALUE dst_unit = rb_iv_get(mScreen, "@@unit");
584
+
585
+ SDL_Surface *src = GetSurface(*(RSTRUCT_PTR(src_unit)+0))->surface;
586
+ SDL_Surface *dst = GetSurface(*(RSTRUCT_PTR(dst_unit)+0))->surface;
587
+
588
+ SDL_Rect srect, drect;
589
+
590
+ srect.x = rect[0];
591
+ srect.y = rect[1];
592
+ srect.w = rect[2];
593
+ srect.h = rect[3];
594
+
595
+ VALUE *d_p = RSTRUCT_PTR(dst_unit);
596
+ drect.x = NUM2INT(*(d_p + 1)) + NUM2INT(vx);
597
+ drect.y = NUM2INT(*(d_p + 2)) + NUM2INT(vy);
598
+ drect.w = NUM2INT(*(d_p + 3));
599
+ drect.h = NUM2INT(*(d_p + 4));
600
+
601
+ SDL_BlitSurface(src, &srect, dst, &drect);
602
+ return self;
603
+ }
604
+
605
+ /*
606
+ インスタンスの内容を別のインスタンスに描画する
607
+ */
608
+ static VALUE sprite_render_rect2_xy_to_sprite(VALUE self, VALUE vdst, VALUE vrect, VALUE vx, VALUE vy)
609
+ {
610
+ VALUE visible = rb_iv_get(self, str_visible);
611
+ if(visible == Qfalse) return self;
612
+ int rect[4];
613
+ sprite_get_rect(vrect, &(rect[0]));
614
+ MiyakoBitmap src, dst;
615
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
616
+ _miyako_setup_unit_2(self, vdst, scr, &src, &dst, Qnil, Qnil, 1);
617
+ src.rect.x = rect[0];
618
+ src.rect.y = rect[1];
619
+ src.rect.w = rect[2];
620
+ src.rect.h = rect[3];
621
+ src.x = NUM2INT(vx);
622
+ src.y = NUM2INT(vy);
623
+ render_to_inner(&src, &dst);
624
+ return self;
625
+ }
626
+
361
627
  /*
362
628
  :nodoc:
363
629
  */
@@ -404,7 +670,7 @@ void _miyako_screen_pre_render()
404
670
  static VALUE screen_render(VALUE self)
405
671
  {
406
672
  VALUE dst = rb_iv_get(mScreen, "@@unit");
407
- SDL_Surface *pdst = GetSurface(*(RSTRUCT_PTR(dst)))->surface;
673
+ SDL_Surface *pdst = GetSurface(*(RSTRUCT_PTR(dst)))->surface;
408
674
  VALUE fps_view = rb_iv_get(mScreen, "@@fpsView");
409
675
 
410
676
  _miyako_sprite_list_render(rb_iv_get(cSprite, "@@sprites"));
@@ -449,8 +715,8 @@ void _miyako_screen_render()
449
715
  */
450
716
  static VALUE screen_render_screen(VALUE self, VALUE vsrc)
451
717
  {
452
- MiyakoBitmap src, dst;
453
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
718
+ MiyakoBitmap src, dst;
719
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
454
720
  _miyako_setup_unit_2(vsrc, mScreen, scr, &src, &dst, Qnil, Qnil, 1);
455
721
  render_inner(&src, &dst);
456
722
  return self;
@@ -566,7 +832,7 @@ static void maplayer_render_inner(VALUE self, MiyakoBitmap *dst)
566
832
  int my = pos_y % mc_chip_size_h;
567
833
 
568
834
  MiyakoBitmap src;
569
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
835
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
570
836
 
571
837
  int bx = dst->rect.x;
572
838
  int by = dst->rect.y;
@@ -580,7 +846,7 @@ static void maplayer_render_inner(VALUE self, MiyakoBitmap *dst)
580
846
  int code = NUM2INT(*(RARRAY_PTR(mapdat2) + idx2));
581
847
  if(code == -1){ continue; }
582
848
  _miyako_setup_unit(
583
- rb_funcall(*(RARRAY_PTR(munits) + code),
849
+ rb_funcall(*(RARRAY_PTR(munits) + code),
584
850
  rb_intern("to_unit"), 0),
585
851
  scr, &src,
586
852
  INT2NUM(x * ow - mx), INT2NUM(y * oh - my), 0);
@@ -613,7 +879,7 @@ static void fixedmaplayer_render_inner(VALUE self, MiyakoBitmap *dst)
613
879
  VALUE mapdat = rb_iv_get(self, "@mapdat");
614
880
 
615
881
  MiyakoBitmap src;
616
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
882
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
617
883
 
618
884
  int bx = dst->rect.x;
619
885
  int by = dst->rect.y;
@@ -676,7 +942,7 @@ static void maplayer_render_to_inner(VALUE self, MiyakoBitmap *dst)
676
942
  int my = pos_y % mc_chip_size_h;
677
943
 
678
944
  MiyakoBitmap src;
679
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
945
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
680
946
 
681
947
  int bx = dst->rect.x;
682
948
  int by = dst->rect.y;
@@ -720,7 +986,7 @@ static void fixedmaplayer_render_to_inner(VALUE self, MiyakoBitmap *dst)
720
986
  VALUE mapdat = rb_iv_get(self, "@mapdat");
721
987
 
722
988
  MiyakoBitmap src;
723
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
989
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
724
990
 
725
991
  int bx = dst->rect.x;
726
992
  int by = dst->rect.y;
@@ -749,8 +1015,8 @@ static VALUE maplayer_render(VALUE self)
749
1015
  {
750
1016
  VALUE visible = rb_iv_get(self, str_visible);
751
1017
  if(visible == Qfalse) return self;
752
- MiyakoBitmap dst;
753
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1018
+ MiyakoBitmap dst;
1019
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
754
1020
  _miyako_setup_unit(mScreen, scr, &dst, Qnil, Qnil, 1);
755
1021
  maplayer_render_inner(self, &dst);
756
1022
  return self;
@@ -763,8 +1029,8 @@ static VALUE fixedmaplayer_render(VALUE self)
763
1029
  {
764
1030
  VALUE visible = rb_iv_get(self, str_visible);
765
1031
  if(visible == Qfalse) return self;
766
- MiyakoBitmap dst;
767
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1032
+ MiyakoBitmap dst;
1033
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
768
1034
  _miyako_setup_unit(mScreen, scr, &dst, Qnil, Qnil, 1);
769
1035
  fixedmaplayer_render_inner(self, &dst);
770
1036
  return self;
@@ -777,8 +1043,8 @@ static VALUE maplayer_render_to_sprite(VALUE self, VALUE vdst)
777
1043
  {
778
1044
  VALUE visible = rb_iv_get(self, str_visible);
779
1045
  if(visible == Qfalse) return self;
780
- MiyakoBitmap dst;
781
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1046
+ MiyakoBitmap dst;
1047
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
782
1048
  _miyako_setup_unit(vdst, scr, &dst, Qnil, Qnil, 1);
783
1049
  maplayer_render_to_inner(self, &dst);
784
1050
  return self;
@@ -791,8 +1057,8 @@ static VALUE fixedmaplayer_render_to_sprite(VALUE self, VALUE vdst)
791
1057
  {
792
1058
  VALUE visible = rb_iv_get(self, str_visible);
793
1059
  if(visible == Qfalse) return self;
794
- MiyakoBitmap dst;
795
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1060
+ MiyakoBitmap dst;
1061
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
796
1062
  _miyako_setup_unit(vdst, scr, &dst, Qnil, Qnil, 1);
797
1063
  maplayer_render_inner(self, &dst);
798
1064
  return self;
@@ -805,8 +1071,8 @@ static VALUE map_render(VALUE self)
805
1071
  {
806
1072
  VALUE visible = rb_iv_get(self, str_visible);
807
1073
  if(visible == Qfalse) return self;
808
- MiyakoBitmap dst;
809
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1074
+ MiyakoBitmap dst;
1075
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
810
1076
  _miyako_setup_unit(mScreen, scr, &dst, Qnil, Qnil, 1);
811
1077
  VALUE map_layers = rb_iv_get(self, "@map_layers");
812
1078
  int i;
@@ -824,8 +1090,8 @@ static VALUE fixedmap_render(VALUE self)
824
1090
  {
825
1091
  VALUE visible = rb_iv_get(self, str_visible);
826
1092
  if(visible == Qfalse) return self;
827
- MiyakoBitmap dst;
828
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1093
+ MiyakoBitmap dst;
1094
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
829
1095
  _miyako_setup_unit(mScreen, scr, &dst, Qnil, Qnil, 1);
830
1096
  VALUE map_layers = rb_iv_get(self, "@map_layers");
831
1097
  int i;
@@ -843,8 +1109,8 @@ static VALUE map_render_to_sprite(VALUE self, VALUE vdst)
843
1109
  {
844
1110
  VALUE visible = rb_iv_get(self, str_visible);
845
1111
  if(visible == Qfalse) return self;
846
- MiyakoBitmap dst;
847
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1112
+ MiyakoBitmap dst;
1113
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
848
1114
  _miyako_setup_unit(vdst, scr, &dst, Qnil, Qnil, 1);
849
1115
 
850
1116
  VALUE map_layers = rb_iv_get(self, "@map_layers");
@@ -863,8 +1129,8 @@ static VALUE fixedmap_render_to_sprite(VALUE self, VALUE vdst)
863
1129
  {
864
1130
  VALUE visible = rb_iv_get(self, str_visible);
865
1131
  if(visible == Qfalse) return self;
866
- MiyakoBitmap dst;
867
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1132
+ MiyakoBitmap dst;
1133
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
868
1134
  _miyako_setup_unit(vdst, scr, &dst, Qnil, Qnil, 1);
869
1135
 
870
1136
  VALUE map_layers = rb_iv_get(self, "@map_layers");
@@ -1001,8 +1267,8 @@ static VALUE sa_render(VALUE self)
1001
1267
  *(runit + 5) = INT2NUM(NUM2INT(tmp_x) + NUM2INT(*(move_off+0)));
1002
1268
  *(runit + 6) = INT2NUM(NUM2INT(tmp_y) + NUM2INT(*(move_off+1)));
1003
1269
 
1004
- MiyakoBitmap src, dst;
1005
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1270
+ MiyakoBitmap src, dst;
1271
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1006
1272
  _miyako_setup_unit_2(vsrc, mScreen, scr, &src, &dst, Qnil, Qnil, 1);
1007
1273
  render_inner(&src, &dst);
1008
1274
 
@@ -1042,8 +1308,8 @@ static VALUE sa_render_to_sprite(VALUE self, VALUE vdst)
1042
1308
  *(runit + 5) = INT2NUM(NUM2INT(tmp_x) + NUM2INT(rb_funcall(move_off, id_kakko, 1, nZero)));
1043
1309
  *(runit + 6) = INT2NUM(NUM2INT(tmp_y) + NUM2INT(rb_funcall(move_off, id_kakko, 1, nOne )));
1044
1310
 
1045
- MiyakoBitmap src, dst;
1046
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1311
+ MiyakoBitmap src, dst;
1312
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1047
1313
  _miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
1048
1314
  render_to_inner(&src, &dst);
1049
1315
 
@@ -1063,32 +1329,24 @@ static VALUE plane_render(VALUE self)
1063
1329
  if(visible == Qfalse) return self;
1064
1330
  VALUE sprite = rb_iv_get(self, "@sprite");
1065
1331
 
1066
- VALUE ssize = rb_iv_get(mScreen, "@@size");
1067
- int ssw = NUM2INT(*(RSTRUCT_PTR(ssize) + 0));
1068
- int ssh = NUM2INT(*(RSTRUCT_PTR(ssize) + 1));
1069
1332
  VALUE pos = rb_iv_get(self, "@pos");
1070
1333
  VALUE size = rb_iv_get(self, "@size");
1334
+ VALUE osize = rb_funcall(sprite, rb_intern("layout_size"), 0);
1071
1335
  int w = NUM2INT(*(RSTRUCT_PTR(size) + 0));
1072
1336
  int h = NUM2INT(*(RSTRUCT_PTR(size) + 1));
1073
1337
  int pos_x = NUM2INT(*(RSTRUCT_PTR(pos) + 0));
1074
1338
  int pos_y = NUM2INT(*(RSTRUCT_PTR(pos) + 1));
1075
-
1076
- MiyakoBitmap src, dst;
1077
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1078
- _miyako_setup_unit_2(sprite, mScreen, scr, &src, &dst, Qnil, Qnil, 1);
1079
-
1080
- int sw = src.rect.w;
1081
- int sh = src.rect.h;
1339
+ int ow = NUM2INT(*(RSTRUCT_PTR(osize) + 0));
1340
+ int oh = NUM2INT(*(RSTRUCT_PTR(osize) + 1));
1082
1341
 
1083
1342
  int x, y;
1084
1343
  for(y = 0; y < h; y++){
1085
1344
  for(x = 0; x < w; x++){
1086
- src.x = (x-1) * sw + pos_x;
1087
- src.y = (y-1) * sh + pos_y;
1088
- if(src.x > 0 || src.y > 0
1089
- || (src.x+sw) <= ssw || (src.y+sh) <= ssh){
1090
- render_inner(&src, &dst);
1091
- }
1345
+ if(pos_x > 0) pos_x -= ow;
1346
+ if(pos_y > 0) pos_y -= oh;
1347
+ VALUE vx = INT2NUM(pos_x + x * ow);
1348
+ VALUE vy = INT2NUM(pos_y + y * oh);
1349
+ rb_funcall(sprite, rb_intern("render_xy"), 2, vx, vy);
1092
1350
  }
1093
1351
  }
1094
1352
 
@@ -1104,32 +1362,24 @@ static VALUE plane_render_to_sprite(VALUE self, VALUE vdst)
1104
1362
  if(visible == Qfalse) return self;
1105
1363
  VALUE sprite = rb_iv_get(self, "@sprite");
1106
1364
 
1107
- VALUE ssize = rb_iv_get(mScreen, "@@size");
1108
- int ssw = NUM2INT(*(RSTRUCT_PTR(ssize) + 0));
1109
- int ssh = NUM2INT(*(RSTRUCT_PTR(ssize) + 1));
1110
1365
  VALUE pos = rb_iv_get(self, "@pos");
1111
1366
  VALUE size = rb_iv_get(self, "@size");
1367
+ VALUE osize = rb_funcall(sprite, rb_intern("layout_size"), 0);
1112
1368
  int w = NUM2INT(*(RSTRUCT_PTR(size) + 0));
1113
1369
  int h = NUM2INT(*(RSTRUCT_PTR(size) + 1));
1114
1370
  int pos_x = NUM2INT(*(RSTRUCT_PTR(pos) + 0));
1115
1371
  int pos_y = NUM2INT(*(RSTRUCT_PTR(pos) + 1));
1116
-
1117
- MiyakoBitmap src, dst;
1118
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
1119
- _miyako_setup_unit_2(sprite, vdst, scr, &src, &dst, Qnil, Qnil, 1);
1120
-
1121
- int sw = src.rect.w;
1122
- int sh = src.rect.h;
1372
+ int ow = NUM2INT(*(RSTRUCT_PTR(osize) + 0));
1373
+ int oh = NUM2INT(*(RSTRUCT_PTR(osize) + 1));
1123
1374
 
1124
1375
  int x, y;
1125
1376
  for(y = 0; y < h; y++){
1126
1377
  for(x = 0; x < w; x++){
1127
- src.x = (x-1) * sw + pos_x;
1128
- src.y = (y-1) * sh + pos_y;
1129
- if(src.x > 0 || src.y > 0
1130
- || (src.x+sw) <= ssw || (src.y+sh) <= ssh){
1131
- render_to_inner(&src, &dst);
1132
- }
1378
+ if(pos_x > 0) pos_x -= ow;
1379
+ if(pos_y > 0) pos_y -= oh;
1380
+ VALUE vx = INT2NUM(pos_x + x * ow);
1381
+ VALUE vy = INT2NUM(pos_y + y * oh);
1382
+ rb_funcall(sprite, rb_intern("render_xy_to"), 3, vdst, vx, vy);
1133
1383
  }
1134
1384
  }
1135
1385
 
@@ -1205,6 +1455,7 @@ void Init_miyako_no_katana()
1205
1455
  mSpriteBase = rb_define_module_under(mMiyako, "SpriteBase");
1206
1456
  mAnimation = rb_define_module_under(mMiyako, "Animation");
1207
1457
  mDiagram = rb_define_module_under(mMiyako, "Diagram");
1458
+ eMiyakoError = rb_define_class_under(mMiyako, "MiyakoError", rb_eException);
1208
1459
  cSurface = rb_define_class_under(mSDL, "Surface", rb_cObject);
1209
1460
  cGL = rb_define_module_under(mSDL, "GL");
1210
1461
  cFont = rb_define_class_under(mMiyako, "Font", rb_cObject);
@@ -1279,6 +1530,14 @@ void Init_miyako_no_katana()
1279
1530
  rb_define_method(cSprite, "render_to", sprite_render_to_sprite, 1);
1280
1531
  rb_define_method(cSprite, "render_xy", sprite_render_xy, 2);
1281
1532
  rb_define_method(cSprite, "render_xy_to", sprite_render_xy_to_sprite, 3);
1533
+ rb_define_method(cSprite, "render_rect", sprite_render_rect, 1);
1534
+ rb_define_method(cSprite, "render_rect_to", sprite_render_rect_to_sprite, 2);
1535
+ rb_define_method(cSprite, "render_rect2", sprite_render_rect2, 1);
1536
+ rb_define_method(cSprite, "render_rect2_to", sprite_render_rect2_to_sprite, 2);
1537
+ rb_define_method(cSprite, "render_rect_xy", sprite_render_rect_xy, 3);
1538
+ rb_define_method(cSprite, "render_rect_xy_to", sprite_render_rect_xy_to_sprite, 4);
1539
+ rb_define_method(cSprite, "render_rect2_xy", sprite_render_rect2_xy, 3);
1540
+ rb_define_method(cSprite, "render_rect2_xy_to", sprite_render_rect2_xy_to_sprite, 4);
1282
1541
 
1283
1542
  rb_define_method(cPlane, "render", plane_render, 0);
1284
1543
  rb_define_method(cPlane, "render_to", plane_render_to_sprite, 1);
data/miyako_transform.c CHANGED
@@ -54,14 +54,14 @@ static VALUE bitmap_miyako_rotate(VALUE self, VALUE vsrc, VALUE vdst, VALUE radi
54
54
  {
55
55
  MiyakoBitmap src, dst;
56
56
  MiyakoSize size;
57
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
57
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
58
58
 
59
59
  _miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
60
60
 
61
- size.w = dst.rect.w;
62
- size.h = dst.rect.h;
61
+ size.w = dst.rect.w;
62
+ size.h = dst.rect.h;
63
63
 
64
- if(src.surface == dst.surface){ return Qnil; }
64
+ if(src.surface == dst.surface){ return Qnil; }
65
65
 
66
66
  if(dst.rect.w >= 32768 || dst.rect.h >= 32768){ return Qnil; }
67
67
 
@@ -69,19 +69,19 @@ static VALUE bitmap_miyako_rotate(VALUE self, VALUE vsrc, VALUE vdst, VALUE radi
69
69
  long isin = (long)(sin(rad)*4096.0);
70
70
  long icos = (long)(cos(rad)*4096.0);
71
71
 
72
- int px = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+7)));
73
- int py = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+8)));
74
- int pr = src.rect.w + px;
75
- int pb = src.rect.h + py;
76
- int qx = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+7)));
77
- int qy = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+8)));
78
- int qr = dst.rect.w + qx;
79
- int qb = dst.rect.h + qy;
72
+ int px = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+7)));
73
+ int py = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+8)));
74
+ int pr = src.rect.w + px;
75
+ int pb = src.rect.h + py;
76
+ int qx = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+7)));
77
+ int qy = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+8)));
78
+ int qr = dst.rect.w + qx;
79
+ int qb = dst.rect.h + qy;
80
80
  Uint32 sr, sg, sb, sa;
81
81
  Uint32 dr, dg, db, da;
82
82
 
83
- SDL_LockSurface(src.surface);
84
- SDL_LockSurface(dst.surface);
83
+ SDL_LockSurface(src.surface);
84
+ SDL_LockSurface(dst.surface);
85
85
 
86
86
  int x, y;
87
87
  for(y = qy; y < qb; y++)
@@ -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
- Uint32 *psrc = src.ptr + (src.rect.x + ny - py) * src.surface->w + src.rect.x + nx - px;
124
+ Uint32 *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)
@@ -157,7 +157,7 @@ static VALUE bitmap_miyako_scale(VALUE self, VALUE vsrc, VALUE vdst, VALUE xscal
157
157
  {
158
158
  MiyakoBitmap src, dst;
159
159
  MiyakoSize size;
160
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
160
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
161
161
  Uint32 sr, sg, sb, sa;
162
162
  Uint32 dr, dg, db, da;
163
163
 
@@ -165,7 +165,7 @@ static VALUE bitmap_miyako_scale(VALUE self, VALUE vsrc, VALUE vdst, VALUE xscal
165
165
 
166
166
  if(_miyako_init_rect(&src, &dst, &size) == 0) return Qnil;
167
167
 
168
- if(src.surface == dst.surface){ return Qnil; }
168
+ if(src.surface == dst.surface){ return Qnil; }
169
169
 
170
170
  if(dst.rect.w >= 32768 || dst.rect.h >= 32768){ return Qnil; }
171
171
 
@@ -180,17 +180,17 @@ static VALUE bitmap_miyako_scale(VALUE self, VALUE vsrc, VALUE vdst, VALUE xscal
180
180
  int off_x = scx < 0 ? 1 : 0;
181
181
  int off_y = scy < 0 ? 1 : 0;
182
182
 
183
- int px = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+7)));
184
- int py = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+8)));
185
- int pr = src.rect.w + px;
186
- int pb = src.rect.h + py;
187
- int qx = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+7)));
188
- int qy = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+8)));
189
- int qr = dst.rect.w + qx;
190
- int qb = dst.rect.h + qy;
183
+ int px = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+7)));
184
+ int py = -(NUM2INT(*(RSTRUCT_PTR(src.unit)+8)));
185
+ int pr = src.rect.w + px;
186
+ int pb = src.rect.h + py;
187
+ int qx = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+7)));
188
+ int qy = -(NUM2INT(*(RSTRUCT_PTR(dst.unit)+8)));
189
+ int qr = dst.rect.w + qx;
190
+ int qb = dst.rect.h + qy;
191
191
 
192
- SDL_LockSurface(src.surface);
193
- SDL_LockSurface(dst.surface);
192
+ SDL_LockSurface(src.surface);
193
+ SDL_LockSurface(dst.surface);
194
194
 
195
195
  int x, y;
196
196
  for(y = qy; y < qb; y++)
@@ -204,7 +204,7 @@ static VALUE bitmap_miyako_scale(VALUE self, VALUE vsrc, VALUE vdst, VALUE xscal
204
204
  if(ny < py || ny >= pb){ tp++; continue; }
205
205
  #if SDL_BYTEORDER == SDL_LIL_ENDIAN
206
206
  da = (*tp >> 24) | dst.a255;
207
- Uint32 *psrc = src.ptr + (src.rect.x + ny - py) * src.surface->w + src.rect.x + nx - px;
207
+ Uint32 *psrc = src.ptr + (src.rect.x + ny - py) * src.surface->w + src.rect.x + nx - px;
208
208
  sa = (*psrc >> 24) | src.a255;
209
209
  if(sa == 0){ tp++; continue; }
210
210
  if(da == 0 || sa == 255)
@@ -230,7 +230,7 @@ static VALUE bitmap_miyako_scale(VALUE self, VALUE vsrc, VALUE vdst, VALUE xscal
230
230
  dg = (*tp & dst.fmt->Gmask) >> dst.fmt->Gshift;
231
231
  db = (*tp & dst.fmt->Bmask) >> dst.fmt->Bshift;
232
232
  da = (*tp & dst.fmt->Amask) | dst.a255;
233
- Uint32 *psrc = src.ptr + (src.rect.x + ny - py) * src.surface->w + src.rect.x + nx - px;
233
+ Uint32 *psrc = src.ptr + (src.rect.x + ny - py) * src.surface->w + src.rect.x + nx - px;
234
234
  sa = (*psrc & src.fmt->Amask) | src.a255;
235
235
  if(sa == 0){ tp++; continue; }
236
236
  if(da == 0 || sa == 255)
@@ -285,19 +285,19 @@ static void transform_inner(MiyakoBitmap *src, MiyakoBitmap *dst, VALUE radian,
285
285
  int off_x = scx < 0 ? 1 : 0;
286
286
  int off_y = scy < 0 ? 1 : 0;
287
287
 
288
- int px = -(NUM2INT(*(RSTRUCT_PTR(src->unit)+7)));
289
- int py = -(NUM2INT(*(RSTRUCT_PTR(src->unit)+8)));
290
- int pr = src->rect.w + px;
291
- int pb = src->rect.h + py;
292
- int qx = -(NUM2INT(*(RSTRUCT_PTR(dst->unit)+7)));
293
- int qy = -(NUM2INT(*(RSTRUCT_PTR(dst->unit)+8)));
294
- int qr = dst->rect.w + qx;
295
- int qb = dst->rect.h + qy;
288
+ int px = -(NUM2INT(*(RSTRUCT_PTR(src->unit)+7)));
289
+ int py = -(NUM2INT(*(RSTRUCT_PTR(src->unit)+8)));
290
+ int pr = src->rect.w + px;
291
+ int pb = src->rect.h + py;
292
+ int qx = -(NUM2INT(*(RSTRUCT_PTR(dst->unit)+7)));
293
+ int qy = -(NUM2INT(*(RSTRUCT_PTR(dst->unit)+8)));
294
+ int qr = dst->rect.w + qx;
295
+ int qb = dst->rect.h + qy;
296
296
  Uint32 sr, sg, sb, sa;
297
297
  Uint32 dr, dg, db, da;
298
298
 
299
- SDL_LockSurface(src->surface);
300
- SDL_LockSurface(dst->surface);
299
+ SDL_LockSurface(src->surface);
300
+ SDL_LockSurface(dst->surface);
301
301
 
302
302
  int x, y;
303
303
  for(y = qy; y < qb; y++)
@@ -337,7 +337,7 @@ static void transform_inner(MiyakoBitmap *src, MiyakoBitmap *dst, VALUE radian,
337
337
  dg = (*tp & dst->fmt->Gmask) >> dst->fmt->Gshift;
338
338
  db = (*tp & dst->fmt->Bmask) >> dst->fmt->Bshift;
339
339
  da = (*tp & dst->fmt->Amask) | dst->a255;
340
- Uint32 *psrc = src->ptr + (src->rect.x + ny - py) * src->surface->w + src->rect.x + nx - px;
340
+ Uint32 *psrc = src->ptr + (src->rect.x + ny - py) * src->surface->w + src->rect.x + nx - px;
341
341
  sa = (*psrc & src->fmt->Amask) | src->a255;
342
342
  if(sa == 0){ tp++; continue; }
343
343
  if(da == 0 || sa == 255)
@@ -370,11 +370,11 @@ static void transform_inner(MiyakoBitmap *src, MiyakoBitmap *dst, VALUE radian,
370
370
  static VALUE bitmap_miyako_transform(VALUE self, VALUE vsrc, VALUE vdst, VALUE radian, VALUE xscale, VALUE yscale)
371
371
  {
372
372
  MiyakoBitmap src, dst;
373
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
373
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
374
374
 
375
375
  _miyako_setup_unit_2(vsrc, vdst, scr, &src, &dst, Qnil, Qnil, 1);
376
376
 
377
- if(src.surface == dst.surface){ return Qnil; }
377
+ if(src.surface == dst.surface){ return Qnil; }
378
378
 
379
379
  transform_inner(&src, &dst, radian, xscale, yscale);
380
380
  return vdst;
@@ -388,11 +388,11 @@ static VALUE sprite_render_transform(VALUE self, VALUE radian, VALUE xscale, VAL
388
388
  VALUE visible = rb_iv_get(self, "@visible");
389
389
  if(visible == Qfalse) return self;
390
390
  MiyakoBitmap src, dst;
391
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
391
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
392
392
 
393
393
  _miyako_setup_unit_2(self, mScreen, scr, &src, &dst, Qnil, Qnil, 1);
394
394
 
395
- if(src.surface == dst.surface){ return Qnil; }
395
+ if(src.surface == dst.surface){ return Qnil; }
396
396
 
397
397
  transform_inner(&src, &dst, radian, xscale, yscale);
398
398
  return self;
@@ -406,11 +406,11 @@ static VALUE sprite_render_to_sprite_transform(VALUE self, VALUE vdst, VALUE rad
406
406
  VALUE visible = rb_iv_get(self, "@visible");
407
407
  if(visible == Qfalse) return self;
408
408
  MiyakoBitmap src, dst;
409
- SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
409
+ SDL_Surface *scr = GetSurface(rb_iv_get(mScreen, "@@screen"))->surface;
410
410
 
411
411
  _miyako_setup_unit_2(self, vdst, scr, &src, &dst, Qnil, Qnil, 1);
412
412
 
413
- if(src.surface == dst.surface){ return Qnil; }
413
+ if(src.surface == dst.surface){ return Qnil; }
414
414
 
415
415
  transform_inner(&src, &dst, radian, xscale, yscale);
416
416
  return self;
@@ -438,7 +438,7 @@ void Init_miyako_transform()
438
438
  one = 1;
439
439
  nOne = INT2NUM(one);
440
440
 
441
- rb_define_singleton_method(cBitmap, "rotate", bitmap_miyako_rotate, 3);
442
- rb_define_singleton_method(cBitmap, "scale", bitmap_miyako_scale, 4);
443
- rb_define_singleton_method(cBitmap, "transform", bitmap_miyako_transform, 5);
441
+ rb_define_singleton_method(cBitmap, "rotate", bitmap_miyako_rotate, 3);
442
+ rb_define_singleton_method(cBitmap, "scale", bitmap_miyako_scale, 4);
443
+ rb_define_singleton_method(cBitmap, "transform", bitmap_miyako_transform, 5);
444
444
  }
@@ -29,7 +29,7 @@ mode = 0
29
29
  len_body = Sprite.new({:file=>sprintf("lex_body.png"), :type=>:ck})
30
30
  len_body.move_to!(425, 219)
31
31
 
32
- len_anim_param = {
32
+ len_anim_param = {
33
33
  :sprite => len_body,
34
34
  :wait => 0.1,
35
35
  :move_offset => [[0,0], [0,-1], [0,0], [0,1]]
@@ -40,7 +40,7 @@ len_anim.start
40
40
  road_roller = Sprite.new({:file=>sprintf("lex_roadroller.png"), :type=>:ck})
41
41
  road_roller.move_to!(310, 180)
42
42
 
43
- rr_anim_param = {
43
+ rr_anim_param = {
44
44
  :sprite => road_roller,
45
45
  :wait => 0.1,
46
46
  :move_offset => [[0,0], [0,1], [0,0], [0,-1]]
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-miyako
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyross Makoto
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-16 00:00:00 +09:00
12
+ date: 2009-10-25 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15