- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2023-05-06T10:00:05+09:00","","")
#author("2023-05-06T21:23:06+09:00","","")
* 回転2 [#g3827f42]
スプライトの回転は前回と同様に設定します。PA~PDを操作する為、以下の関数を用意します。~
void SpriteRotate(u32 num, s32 angle)
{
OBJAFFINE* rot = (OBJAFFINE*)OAM + num;
rot->pa = GetCos(angle);
rot->pb = GetSin(angle);
rot->pc = -GetSin(angle);
rot->pd = GetCos(angle);
}
** スプライトの回転 [#hfbb29e5]
#include "lib/gba.h"
#include "irq.arm.h"
#include "spr.h"
#include "math.h"
//---------------------------------------------------------------------------
int main(void)
{
REG_WSCNT = 0x4317;
IrqInit();
SprInit();
s32 x = 240/2 - 64/2;
s32 y = 160/2 - 64/2;
s32 angle = 0;
SprSetSize (0, OBJ_SIZE(3), OBJ_SQUARE, OBJ_16_COLOR);
SprSetChr (0, 0);
SprSetPal (0, 0);
SprSetXy(0, x, y);
SprSetRotScale(0, 0, TRUE);
for(;;)
{
VBlankIntrWait();
SprSetRotate(0, angle);
angle++;
if(angle > 360)
{
angle = 0;
}
}
}
*** 動作画面 [#v076a07e]
-[[github:]]
-[[github:https://github.com/akkera102/gbadev-ja/tree/main/tut20%20%E5%9B%9E%E8%BB%A22]]
#ref(1.png,nolink)
** 履歴 [#ifef40ab]
- 2023/05/05
- 2023/05/06
- 2007/09/08