📄 gameplay.c
字号:
{
pPlayer->pSprite->stPos.y = -tempY;
}
}
}
}
}
/**
* Play_MoveScreen - .
*/
void Play_MoveScreen(void)
{
CMD *pCmd;
StepX = 0;
StepY = 0;
if (g_nPlayerVx > 0)
{
g_nPlayerVx --;
}
if (g_nPlayerVy > 0)
{
g_nPlayerVy --;
}
//process event
if (g_stEvent.Ev_Key != VK_MAX_NUM)
{//available input info
pCmd = Play_ProcessEvent();
}
else
{
Key_Index = LCD_KEYMIDDLE;
}
/*if ( g_nPlayerState == ST_LEFTCRAZY || g_nPlayerState == ST_RIGHTCRAZY )
{
return;
}*/
//move actor sprite
Play_ActorMove();
if (StepX)
{
g_nScreenStep_X = StepX;
E_HScroll(TEXT2, StepX, g_nPlayerAx);
if ( g_nText3Mode )
{
E_HScroll(TEXT3, StepX, g_nPlayerAx);
}
//scroll text1
g_aTextPos_X[TEXT1] = 192 + (((g_aTextPos_X[TEXT2] - 192) >> 1));
}
else
{
if (g_bMoveFlag_X)
{
g_nScreenStep_X = PlayStep[g_nPlayerVx];
E_HScroll(TEXT2, PlayStep[g_nPlayerVx], g_nPlayerAx);
if ( g_nText3Mode )
{
E_HScroll(TEXT3, PlayStep[g_nPlayerVx], g_nPlayerAx);
}
//scroll text1
g_aTextPos_X[TEXT1] = 192 + (((g_aTextPos_X[TEXT2] - 192) >> 1));
}
}
if (StepY)
{
g_nScreenStep_Y = StepY;
E_VScroll(TEXT2, StepY, g_nPlayerAy);
if ( g_nText3Mode )
{
if (g_nPlayerAy)
{//down
g_aTextPos_Y[TEXT3] = (g_aTextPos_Y[TEXT3] + StepY) & 0x000001FF;
}
else
{
g_aTextPos_Y[TEXT3] = (g_aTextPos_Y[TEXT3] - StepY) & 0x000001FF;
}
}
//scroll text1
E_VScroll(TEXT1, abs((iTextCount_Y[TEXT1] - (iTextCount_Y[TEXT2] >> 1))), g_nPlayerAy);
}
else
{
if (g_bMoveFlag_Y)
{
g_nScreenStep_Y = PlayStep[g_nPlayerVy];
E_VScroll(TEXT2, PlayStep[g_nPlayerVy], g_nPlayerAy);
if ( g_nText3Mode )
{
if (g_nPlayerAy)
{//down
g_aTextPos_Y[TEXT3] = (g_aTextPos_Y[TEXT3] + PlayStep[g_nPlayerVy]) & 0x000001FF;
}
else
{
g_aTextPos_Y[TEXT3] = (g_aTextPos_Y[TEXT3] - PlayStep[g_nPlayerVy]) & 0x000001FF;
}
}
//scroll text1
E_VScroll(TEXT1, abs((iTextCount_Y[TEXT1] - (iTextCount_Y[TEXT2] >> 1))), g_nPlayerAy);
}
}
}
void Play_Death(void)
{
E_ChangeAction(pPlayer, ST_HIDE);
g_nPlayerState = ST_DEATH;
Key_Index = LCD_KEYMIDDLE;//LCD Key reset
g_nDeathCnt = 0;
}
void Hit_Fish2(void)
{
U8 i,j;
U16 nActionID;
U8 nType;
//fish2_1
for (i = 0; i < g_nCurrentFish2; i++)
{
if ( pFish2[i] == NULL )
{
continue;
}
if ( GETFISH_KIND(pFish2[i]->pSprite->nCtrlFlag) == 1 )
{//Seajelly
continue;
}
nActionID = pFish2[i]->nMtnInfo.B.MTN_ActionID;
if ( nActionID < FISH_L2R )
{
//eat player
if ( g_nPlayerState > ST_HIDE
&& g_nPlayerState < ST_DEATH
&& g_nPlayerLevel == LEVEL1
&& g_bInvincibleFlag == false )
{
if ( E_DetectBlock2Sp(pPlayer->pSprite, pFish2[i]->pSprite,
Fish2_1_EatBox[nActionID*4+0], Fish2_1_EatBox[nActionID*4+1],
Fish2_1_EatBox[nActionID*4+2], Fish2_1_EatBox[nActionID*4+3]) )
{//eat player
E_ChangeAction(pFish2[i], nActionID + 4);
Play_Death();
Fish_Index = LCD_2_1;
return;
}
}
//eat fish1
for (j = 0; j < g_nCurrentFish1; j++)
{
if ( pFish1[j] == NULL )
{
continue;
}
if ( E_DetectBlock2Sp(pFish1[j]->pSprite, pFish2[i]->pSprite,
Fish2_1_EatBox[nActionID*4+0], Fish2_1_EatBox[nActionID*4+1],
Fish2_1_EatBox[nActionID*4+2], Fish2_1_EatBox[nActionID*4+3]) )
{//eat Fish1
E_ChangeAction(pFish2[i], nActionID + 4);
E_FreeMotion(pFish1[j]);
pFish1[j] = (MOTION*)NULL;
break;
}
}
}
}
}
void Hit_Fish3(void)
{
U8 i,j;
U16 nActionID;
U8 nType;
for (i = 0; i < g_nCurrentFish3; i++)
{
if ( pFish3[i] == NULL )
{
continue;
}
nActionID = pFish3[i]->nMtnInfo.B.MTN_ActionID;
if ( nActionID < FISH_L2R )
{
nType = GETFISH_KIND(pFish3[i]->pSprite->nCtrlFlag);
//eat player
if ( g_nPlayerState > ST_HIDE
&& g_nPlayerState < ST_DEATH
&& g_bInvincibleFlag == false )
{
if ( E_DetectBlock2Sp(pPlayer->pSprite, pFish3[i]->pSprite,
Fish3_1_EatBox[nType*8+nActionID*4+0], Fish3_1_EatBox[nType*8+nActionID*4+1],
Fish3_1_EatBox[nType*8+nActionID*4+2], Fish3_1_EatBox[nType*8+nActionID*4+3]) )
{//eat player
E_ChangeAction(pFish3[i], nActionID + 4);
Play_Death();
if ( nType )
{
Fish_Index = LCD_3_2;
}
else
{
Fish_Index = LCD_3_1;
}
return;
}
}
//eat fish1
for (j = 0; j < g_nCurrentFish1; j++)
{
if ( pFish1[j] == NULL )
{
continue;
}
if ( E_DetectBlock2Sp(pFish1[j]->pSprite, pFish3[i]->pSprite,
Fish3_1_EatBox[nType*8+nActionID*4+0], Fish3_1_EatBox[nType*8+nActionID*4+1],
Fish3_1_EatBox[nType*8+nActionID*4+2], Fish3_1_EatBox[nType*8+nActionID*4+3]) )
{//eat Fish1
E_ChangeAction(pFish3[i], nActionID + 4);
E_FreeMotion(pFish1[j]);
pFish1[j] = (MOTION*)NULL;
break;
}
}
//eat fish2
for (j = 0; j < g_nCurrentFish2; j++)
{
if ( pFish3[i]->nMtnInfo.B.MTN_ActionID > FISH_RIGHTMOVE )
{
break;
}
if ( pFish2[j] == NULL )
{
continue;
}
if ( GETFISH_KIND(pFish2[j]->pSprite->nCtrlFlag) == 1 )
{//Seajelly
continue;
}
if ( E_DetectBlock2Sp(pFish2[j]->pSprite, pFish3[i]->pSprite,
Fish3_1_EatBox[nType*8+nActionID*4+0], Fish3_1_EatBox[nType*8+nActionID*4+1],
Fish3_1_EatBox[nType*8+nActionID*4+2], Fish3_1_EatBox[nType*8+nActionID*4+3]) )
{//eat Fish2
E_ChangeAction(pFish3[i], nActionID + 4);
E_FreeMotion(pFish2[j]);
pFish2[j] = (MOTION*)NULL;
break;
}
}
}
}
}
void Hit_Fish4(void)
{
U8 i,j;
U16 nActionID;
U8 nType;
nActionID = pFish4->nMtnInfo.B.MTN_ActionID;
if ( nActionID == SHARK_LEFTMOVE || nActionID == SHARK_RIGHTMOVE)
{
//eat player
if ( g_nPlayerState > ST_HIDE
&& g_nPlayerState < ST_DEATH
&& g_bInvincibleFlag == false )
{
if ( E_DetectBlock2Sp(pPlayer->pSprite, pFish4->pSprite,
Fish4_1_EatBox[(nActionID-1)*4+0], Fish4_1_EatBox[(nActionID-1)*4+1],
Fish4_1_EatBox[(nActionID-1)*4+2], Fish4_1_EatBox[(nActionID-1)*4+3]) )
{//eat player
E_ChangeAction(pFish4, nActionID + 2);
Play_Death();
return;
}
}
//eat fish1
for (j = 0; j < g_nCurrentFish1; j++)
{
if ( pFish1[j] == NULL )
{
continue;
}
if ( E_DetectBlock2Sp(pFish1[j]->pSprite, pFish4->pSprite,
Fish4_1_EatBox[(nActionID-1)*4+0], Fish4_1_EatBox[(nActionID-1)*4+1],
Fish4_1_EatBox[(nActionID-1)*4+2], Fish4_1_EatBox[(nActionID-1)*4+3]) )
{//eat Fish1
E_ChangeAction(pFish4, nActionID + 2);
E_FreeMotion(pFish1[j]);
pFish1[j] = (MOTION*)NULL;
//break;
return;
}
}
//eat fish2
for (j = 0; j < g_nCurrentFish2; j++)
{
/*if ( pFish4->nMtnInfo.B.MTN_ActionID > SHARK_RIGHTMOVE )
{
break;
}*/
if ( pFish2[j] == NULL )
{
continue;
}
if ( E_DetectBlock2Sp(pFish2[j]->pSprite, pFish4->pSprite,
Fish4_1_EatBox[(nActionID-1)*4+0], Fish4_1_EatBox[(nActionID-1)*4+1],
Fish4_1_EatBox[(nActionID-1)*4+2], Fish4_1_EatBox[(nActionID-1)*4+3]) )
{//eat Fish2
E_ChangeAction(pFish4, nActionID + 2);
E_FreeMotion(pFish2[j]);
pFish2[j] = (MOTION*)NULL;
//break;
return;
}
}
//eat fish3
for (j = 0; j < g_nCurrentFish3; j++)
{
/*if ( pFish4->nMtnInfo.B.MTN_ActionID > SHARK_RIGHTMOVE )
{
break;
}*/
if ( pFish3[j] == NULL )
{
continue;
}
if ( E_DetectBlock2Sp(pFish3[j]->pSprite, pFish4->pSprite,
Fish4_1_EatBox[(nActionID-1)*4+0], Fish4_1_EatBox[(nActionID-1)*4+1],
Fish4_1_EatBox[(nActionID-1)*4+2], Fish4_1_EatBox[(nActionID-1)*4+3]) )
{//eat Fish3
E_ChangeAction(pFish4, nActionID + 2);
E_FreeMotion(pFish3[j]);
pFish3[j] = (MOTION*)NULL;
//break;
return;
}
}
}
}
void Hit_Player(void)
{
U8 i,j;
U16 nActionID;
U8 nType;
U8 level;
if ( (g_nPlayerAx ^ (g_nPlayerState - 1)) )
{
return;
}
nActionID = pPlayer->nMtnInfo.B.MTN_ActionID;
level = g_nPlayerLevel-1;
if ( g_nPlayerState == ST_LEFTMOVE || g_nPlayerState == ST_RIGHTMOVE )
{
//eat fish1
for (j = 0; j < g_nCurrentFish1; j++)
{
if ( pFish1[j] == NULL )
{
continue;
}
if ( E_DetectBlock2Sp(pFish1[j]->pSprite, pPlayer->pSprite,
Actor_EatBox[level*8+(g_nPlayerState-1)*4+0],
Actor_EatBox[level*8+(g_nPlayerState-1)*4+1],
Actor_EatBox[level*8+(g_nPlayerState-1)*4+2],
Actor_EatBox[level*8+(g_nPlayerState-1)*4+3]) )
{//eat Fish1
if ( GETFISH_KIND(pFish1[j]->pSprite->nCtrlFlag) )
{
Fish_Index = LCD_1_3;
}
else
{
Fish_Index = LCD_1_2;
}
E_ChangeAction(pPlayer, (level*12+g_nPlayerState+4));
E_FreeMotion(pFish1[j]);
pFish1[j] = (MOTION*)NULL;
g_nScore += 1;//add by xjliu for conut score
#ifdef AUDIO_ENABLE
//TM_StopPCM(AUDIO_NO7);
TM_PlayPCM((U8 *)RES_WAVESFX_EAT1_DRM, 64, 127);
#endif
}
}
if ( g_nPlayerLevel == LEVEL1 )
{
return;
}
//eat fish2
for (j = 0; j < g_nCurrentFish2; j++)
{
if ( pFish2[j] == NULL )
{
continue;
}
if ( E_DetectBlock2Sp(pFish2[j]->pSprite, pPlayer->pSprite,
Actor_EatBox[level*8+(g_nPlayerState-1)*4+0],
Actor_EatBox[level*8+(g_nPlayerState-1)*4+1],
Actor_EatBox[level*8+(g_nPlayerState-1)*4+2],
Actor_EatBox[level*8+(g_nPlayerState-1)*4+3]) )
{//eat Fish2
if ( GETFISH_KIND(pFish2[j]->pSprite->nCtrlFlag) )
{//Seajelly
E_ChangeAction(pPlayer, (level*12+g_nPlayerState+10));
E_FreeMotion(pFish2[j]);
pFish2[j] = (MOTION*)NULL;
Fish_Index = LCD_2_2;
g_nScore += 2;//add by xjliu for conut score
#ifdef AUDIO_ENABLE
//TM_StopPCM(AUDIO_NO7);
TM_PlayPCM((U8 *)RES_WAVESFX_ELETRICITY_DRM, 64, 127);
#endif
return;
}
else
{
E_ChangeAction(pPlayer, (level*12+g_nPlayerState+4));
Fish_Index = LCD_2_1;
g_nScore += 4;//add by xjliu for conut score
#ifdef AUDIO_ENABLE
//TM_StopPCM(AUDIO_NO7);
TM_PlayPCM((U8 *)RES_WAVESFX_EAT1_DRM, 64, 127);
#endif
}
E_FreeMotion(pFish2[j]);
pFish2[j] = (MOTION*)NULL;
}
}
}
}
/**
* ProcCollision - all the collision process.
*/
void ProcCollision(void)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -