pls help | developer.brewmp.com pls help | developer.brewmp.com

Developer

pls help

Forums:

hi all
i read all the thread regarding memory but no one has focused on what if application/game become slow?

i have done something like this

typedef struct UserData UserData;
typedef struct Enemy_struct Enemy;

struct Enemy_struct
{
int xDist,yDist;
//for collision
int enemyH,enemyW,enemyX,enemyY;
int direction,enemyType;
boolean enemyAnim;
;

struct UserData
{
Enemy *enemy;//STRUCTURE FOR ENEMIES
Image imgPool[10];
;

the allocate memory in load resource method like

pMe->ud->enemy=(Enemy*)MALLOC(sizeof(Enemy)*2);
if(!pMe->ud->enemy){
DBGPRINTF("enemy allocation failed");
return EFAILED;
}
MEMSET(pMe->ud->enemy, 0, sizeof(pMe->ud->enemy));

i am releasing memory allocated for enemy struct like
Enemy *enemy;
enemy = pMe->ud->enemy;
if(enemy){
FREEIF(enemy);
}
i have used timers for drawing enemy.....like

in EVT_APP_START:
ISHELL_SetTimer(pMe->a.m_pIShell, 0, (PFNNOTIFY)Tick, (void *)pMe);

in callback i am calling Tick method The defn for tick is

SpriteGame_NextFrame(pMe);
IDISPLAY_UpdateEx(pMe->a.m_pIDisplay, FALSE);
ISHELL_SetTimer(pMe->a.m_pIShell,100, (PFNNOTIFY)Tick, (void *)pMe);
in SpriteGame_NextFrame function

if(pMe->ud->enemyA){
for(i=0;i<2;i++)
drawEnemy(pMe,i,DRONE_HEIGHT,DRONE_WIDTH,100,pMe->ud->enemyA);
pMe->ud->enemyA =FALSE;
}
else{
for(i=0;i<2;i++)
drawEnemy(pMe,i,DRONE_HEIGHT,DRONE_WIDTH,100,pMe->ud->enemyA);
pMe->ud->enemyA = TRUE;
}

& in drewenemy method i am drawing enemy like

switch(pMe->ud->enemy[enemyIndex].enemyType)
{
case AUTODRONE_LR:

pMe->ud->enemy[enemyIndex].xDist = pMe->ud->enemy[enemyIndex].enemyX - pMe->rgCmds[0].x;
pMe->ud->enemy[enemyIndex].yDist = pMe->ud->enemy[enemyIndex].enemyY - pMe->rgCmds[0].x;

if(pMe->ud->enemy[enemyIndex].direction){
for(i=0;i<16;i++){
for(j=0;j<7;j++){
if(!pMe->ud->enemy[enemyIndex].enemyAnim)
DrawClippedImage(&pMe->a, pMe->ud->imgPool[DroneLR_FrameArr_1[i][j]],pMe->ud->enemy[enemyIndex].enemyX + DroneLR_FrameArr_1[i][j+1]
,pMe->ud->enemy[enemyIndex].enemyY +DroneLR_FrameArr_1[i][j+2],DroneLR_FrameArr_1[i][j+3]
,DroneLR_FrameArr_1[i][j+4],DroneLR_FrameArr_1[i][j+5],DroneLR_FrameArr_1[i][j+6],TRUE);
else
DrawClippedImage(&pMe->a, pMe->ud->imgPool[DroneLR_FrameArr_2[i][j]],pMe->ud->enemy[enemyIndex].enemyX + DroneLR_FrameArr_2[i][j+1]
,pMe->ud->enemy[enemyIndex].enemyY +DroneLR_FrameArr_2[i][j+2],DroneLR_FrameArr_2[i][j+3]
,DroneLR_FrameArr_2[i][j+4],DroneLR_FrameArr_2[i][j+5],DroneLR_FrameArr_2[i][j+6],TRUE);

j = 7;//bcoz in single iteration of j we have to draw object(drone).
}
}
}
else{
for(i=0;i<16;i++){
for(j=0;j<7;j++){
if(!pMe->ud->enemy[enemyIndex].enemyAnim){
DrawClippedImage(&pMe->a, pMe->ud->imgPool[DroneRH_FrameArr_1[i][j]],pMe->ud->enemy[enemyIndex].enemyX + DroneRH_FrameArr_1[i][j+1]
,pMe->ud->enemy[enemyIndex].enemyY +DroneRH_FrameArr_1[i][j+2],DroneRH_FrameArr_1[i][j+3]
,DroneRH_FrameArr_1[i][j+4],DroneRH_FrameArr_1[i][j+5],DroneRH_FrameArr_1[i][j+6],TRUE);
//DBGPRINTF("Inside i indices");
}
else{
DrawClippedImage(&pMe->a, pMe->ud->imgPool[DroneRH_FrameArr_2[i][j]],pMe->ud->enemy[enemyIndex].enemyX + DroneRH_FrameArr_2[i][j+1]
,pMe->ud->enemy[enemyIndex].enemyY +DroneRH_FrameArr_2[i][j+2],DroneRH_FrameArr_2[i][j+3]
,DroneRH_FrameArr_2[i][j+4],DroneRH_FrameArr_2[i][j+5],DroneRH_FrameArr_2[i][j+6],TRUE);
//DBGPRINTF("Inside II indices");
}
j = 7;//bcoz in single iteration of j we have to draw object(drone).
}
}
}
break;
default:
break;
}

Actually i am using the demo code of spritegame and i have removed the background layer ie 0 th layer(mountain layer) by backgrounding images. now there is only 1 layer in application which i have used to define the tile cordinate.
& sprite remains same.

my question can anyone tell me y my game become slow after some time?
the enemy is actually a moving chopper which moves left to right. bt after some time its speed become slow. i have checked for all possible condition ie BPOINT and all. but problem remains same.
i am using brew 3.1.4 & testing this game on LG VX 7000.
pls help me..
ketan

I guess device is going in sleep mode, returning TRUE from EVT_APP_NO_SLEEP in your event handler will solve your problem,this way the application prevents the device from being be put in sleep mode.
Thanks,
Mahesh

I guess device is going in sleep mode, returning TRUE from EVT_APP_NO_SLEEP in your event handler will solve your problem,this way the application prevents the device from being be put in sleep mode.
Thanks,
Mahesh

Thanks smahesh
it works..
ketan

Thanks smahesh
it works..
ketan