how to diffrent key in IShell_SetTimer...... | developer.brewmp.com how to diffrent key in IShell_SetTimer...... | developer.brewmp.com

Developer

how to diffrent key in IShell_SetTimer......

Forums:

hi friend
i am making a game
but find problem in key handling
bullet should move according to key.
plz help
____________________________
//.........................
//...............................
case EVT_KEY_PRESS:
Figure_throwBullet(pApp,wParam);
break;

void Figure_MoveBullet(myapp_t* pApp)
{

pApp->sprBullet.nY -= 2;
if (pApp->sprBullet.nY <= 5)
{
pApp->bBullet = FALSE;
}

}

void Figure_MoveBulletL(myapp_t* pApp)
{
pApp->sprBullet.nY -= 3;
pApp->sprBullet.nX -= 2;
if (pApp->sprBullet.nX <= 5)
{
pApp->bBullet = FALSE;
}
}
void Figure_MoveBulletR(myapp_t* pApp)
{
pApp->sprBullet.nY -= 3;
pApp->sprBullet.nX += 2;
if (pApp->sprBullet.nY <= 5)
{
pApp->bBullet= FALSE;
}

void Figure_DrawScreen(myapp_t* pApp)
{
AECHAR szTempBuf[] = {'%','d','\0'};
/////// background
IDISPLAY_ClearScreen(pApp->a.m_pIDisplay);

IDISPLAY_BitBlt(pApp->a.m_pIDisplay, pApp->sprPlayer.nX, pApp->sprPlayer.nY, -1, -1, pApp->pRawImagePtrs[pApp->sprPlayer.nImage], 0, 0, AEE_RO_COPY);

///alien
IDISPLAY_BitBlt(pApp->a.m_pIDisplay, pApp->sprAlien.nX, pApp->sprAlien.nY, -1, -1, pApp->pRawImagePtrs[pApp->sprAlien.nImage], 0, 0, AEE_RO_COPY);

if (pApp->bBullet)
IDISPLAY_BitBlt(pApp->a.m_pIDisplay, pApp->sprBullet.nX, pApp->sprBullet.nY, -1, -1, pApp->pRawImagePtrs[pApp->sprBullet.nImage], 0, 0, AEE_RO_COPY);

///game over text
if (pApp->bGameOver)
{
ISHELL_LoadResString(pApp->a.m_pIShell, RES_FILE, STR_GAMEOVER, pApp->szBuf, sizeof(pApp->szBuf));
IDISPLAY_DrawText(pApp->a.m_pIDisplay, AEE_FONT_NORMAL, pApp->szBuf, -1, 0, 0, NULL, IDF_TEXT_TRANSPARENT | IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
}

IDISPLAY_Update(pApp->a.m_pIDisplay);

void Figure_SetGameMode(myapp_t* pApp, int nMode)
{
timer clear gui for all state changes
ISHELL_CancelTimer(pApp->a.m_pIShell, NULL, NULL);
Figure_ClearGUI(pApp);
switch (nMode)
{
case GAME_MODE_PLAY:
Figure_SetupGame(pApp);
break;
}
// now our current game mode
pApp->nGameMode = nMode;

void Figure_TimerCallback(myapp_t* pApp)
{
///objects
Figure_MoveBullet(pApp);

// screen
Figure_DrawScreen(pApp);

ISHELL_SetTimer(pApp->a.m_pIShell, TIMER_PERIOD, (PFNNOTIFY)Figure_TimerCallback, pApp);

void Figure_SetupGame(myapp_t* pApp)
{
pApp->bGameOver = FALSE;
pApp->bBullet = FALSE;

//player starts at the bottom, centered
pApp->sprPlayer.nX = pApp->di.cxScreen / 2 - (pApp->sprPlayer.nWidth / 2);
pApp->sprPlayer.nY = pApp->di.cyScreen - pApp->sprPlayer.nHeight;

//alien starts near the top
pApp->sprAlien.nX = 0;
pApp->sprAlien.nY = pApp->sprAlien.nHeight;

//the main game loop timer up
ISHELL_SetTimer(pApp->a.m_pIShell,TIMER_PERIOD,(PFNNOTIFY)Figure_TimerCallback, pApp);

}

void Figure_throwBullet(myapp_t* pApp, uint16 wParam)
{
file://launch bullet
pApp->sprBullet.nX = (pApp->sprPlayer.nX + (pApp->sprPlayer.nWidth / 2) - (pApp->sprBullet.nWidth / 2));
pApp->sprBullet.nY = pApp->sprPlayer.nY - pApp->sprPlayer.nHeight + 15;
bBullet=" title="//pApp->bBullet=">file://pApp->bBullet= TRUE;
switch (wParam)
{
case AVK_LEFT:
if (!pApp->bBullet)
{
pApp->bBullet= TRUE;
}

break;
case AVK_RIGHT:
if (!pApp->bBullet)
{
pApp->bBullet = TRUE;

}
break;

case AVK_SELECT:
if (!pApp->bBullet)
{
pApp->bBullet= TRUE;

}
break;
}

Use code tags so that your code can be read.
Have you done any sort of debugging? What is the exact problem you're having?

Use code tags so that your code can be read.
Have you done any sort of debugging? What is the exact problem you're having?

because the key event cycle MUST return very quickly.

because the key event cycle MUST return very quickly.

You must return TRUE or FALSE when handling a event. :D

You must return TRUE or FALSE when handling a event. :D

thank you friends
my problem is solved

thank you friends
my problem is solved