#include #include #include "action.h" short ActNum; /* 現在アクティブなAct */ action ActWork[ACT_MAX]; /* action構造体の配列 */ /*---------------------------------------------------------------------- action構造体初期化 ----------------------------------------------------------------------*/ void InitAct( void ){ short i; for (i=0;iID == EMPTY ) return (ap); } return (NULL); } /*---------------------------------------------------------------------- 【処理終了】 ----------------------------------------------------------------------*/ void ResetAction( void ){ ActWork[ActNum].ID = EMPTY; } /*---------------------------------------------------------------------- 【action処理】 ----------------------------------------------------------------------*/ void GoAction( void ){ short i; action *ap; ap = ActWork; for (i=0; i<=ACT_MAX; i++, ap++ ){ ActNum = i; if ( ap->ID != EMPTY ){ ap->fnAction( ap ); } } } /*---------------------------------------------------------------------- 【action切換え】 ----------------------------------------------------------------------*/ void ChangeAction( void *newfunc ){ ActWork[ActNum].fnAction = newfunc; } /*---------------------------------------------------------------------- 【RECT当たり判定】 in : action *ACT 自分のaction構造体 out: short はずれ=NULL ----------------------------------------------------------------------*/ short CheckCollisionRect( action *ap ){ action *cp; short i; short top,bottom,left,right; short dtop,dbottom,dleft,dright; left = ap->posX + ap->collision.x; right = left + ap->collision.w; top = ap->posY + ap->collision.y; bottom = top + ap->collision.h; cp = ActWork; for ( i=0; i <= ACT_MAX; i++, cp++ ){ if ( cp->ID != 0 ){ dleft = cp->posX + cp->collision.x; dright = dleft + cp->collision.w; dtop = cp->posY + cp->collision.y; dbottom = dtop + cp->collision.h; if ((left >= dleft || right > dleft) && ( left < dright || right < dright ) && ( top >= dtop || bottom > dtop ) && ( top < dbottom || bottom < dbottom )) { ap->ptr0 = cp; /* 当たった相手を記録 */ cp->message |= COLLISION; /* 相手に当たり通知 */ cp->ptr0 = ap; /* 当たったのは俺じゃ! */ return ( 1 ); } } } return ( NULL ); }