I'm having problems when I pass the address of my player object to a pointer parameter in the following function:
bool Player(RPGChar* thisPlayer, vector< vector<RPGTile> > currentTilesInPlay) // animates and does player movement
{
bool bSlideNotNeedRedraw = true;
thisPlayer->rpgC_Animate();
thisPlayer->rpgC_Movement(currentTilesInPlay);
if(!Navigation(thisPlayer))
bSlideNotNeedRedraw = false;
if(!InteriorsExteriors(thisPlayer, currentTilesInPlay))
bSlideNotNeedRedraw = false;
return bSlideNotNeedRedraw;
}
The function is called by a function called
game(), where my player object is defined locally:
void game() // dispatcher function
{
RPGChar rpgPlayer("obj/sprite1.bmp",999);
//...//
g_bSlideDrawn = Player(&rpgPlayer, g_CurrentTilesInPlay);
}
The game compiles and links correctly, and the functions
rpgC_Movement, along with the other functions called in
Player() work fine, except for
rpgC_Animate(). The function is defined as follows:
void RPGChar::rpgC_Animate()
{
dbSprite(m_iSpriteID,m_iX,m_iY,m_iImageID);
int iStart,iEnd;
switch(m_iDir)
{
case 0:
iStart=3;
iEnd = 4;
break;
case 1:
iStart=5;
iEnd = 6;
break;
case 2:
iStart=1;
iEnd = 2;
break;
case 3:
iStart=7;
iEnd=8;
break;
}
if(dbTimer()-m_iAnimTimer>100)
{
if(dbSpriteFrame(m_iSpriteID)!=iStart)
{
dbSetSpriteFrame(m_iSpriteID,iStart);
m_iAnimTimer = dbTimer();
return;
}
else
{
dbSetSpriteFrame(m_iSpriteID,iEnd);
m_iAnimTimer = dbTimer();
return;
}
}
};
The character scoots around without animating.
This issue only came up after I started passing my player using pointers rather than keeping it global.
~you can call me lantz~