I'm making an isometric turn based strategy. Characters can move between tiles and tiles only, so I made a function for moving one tile in any direction. Regarding path-finding, I implemented A*, which returns a list of directions to the target, for example: North, North, West; etc. Also, the game loop calls a MovementUpadate()
for the character, to check if it has reached the next tile, if it has, move to the next, if there is one. For starters, is this good or is there a better approach?
Now with the character movement/animation, I'm using linear interpolation between tiles 'till the target cell is reached. In the end, there is a lag between tiles, little, but still. Also, how to interpolates so, that the character doesn't start off fast, and slow down at the end?
void Character::MovementUpdate(){
if(moving){ //if moving, then do the calculations
float rate=(float)(moveTime-movesLeft)/moveTime; //ratio between coordinates
posX=(int) ( (float)(currentTile->x+20)*rate + (float)posX*((float)1-rate));
posY=(int) ( (float)(currentTile->y-25)*rate + (float)posY*((float)1-rate));
movesLeft--; //it has, for example 30 updates to move to that position
if(movesLeft==0){ //if no moves left, reset and move to the next
if(moveList.size()>0){
Move(moveList.at(0));
moveList.erase(moveList.begin());
}else{
moving=false;
characterSprite->UpdateAnimateSprite(moving);
}
movesLeft=moveTime;
}
}
}