best

im saving the position of the character so i can track it anytime without calling the function, that loops the whole map to track the character, again and again.

which one would be the best?

snippet #1
1
2
3
4
5
6
7
8
move_player(character_positionX,character_positionY+=1); // function call

void cave::move_player( int& x_coordinate , int& y_coordinate )
{
	x_coordinate = x_coordinate;
	y_coordinate = y_coordinate;
	cave_floor[x_coordinate][y_coordinate] = character;
}


snippet #2
1
2
3
4
5
6
7
8
move_player(character_positionX,++character_positionY); // function call

void cave::move_player ( int x_coordinate , int y_ coordinate )
{
	character_positionX = x_coordinate;
        character_positionY = y_coordinate;
	cave_floor[x_coordinate][y_coordinate] = character;
}
Last edited on
Im not 100% Sure, but one thing is sure, Your class name should always start with uppercase. Cave, not cave. =)
Topic archived. No new replies allowed.