Without knowing where 0,0 is in your map system, it's hard to tell if your logic is what you intended. In most simple games, a world consts of [n][n] tiles. If that's the case in your game, then your logic seems reversed.
Line 52: Don't you mean MAP_BOUNDARY?
As far as your move functions, I would tend to think of those as
bool
functions. Returns true, if the move was made in that direction, returns false, if you can't move in that direction. Throwing an exception simply because you reached the edge of the map is generally overkill.
In set_coordinates, I would agree that throwing an exception is appropriate. You should be checking that the coordinates are valid before calling it.
As a general point of style, I don't like to see exceptions thrown in else clauses. I prefer to see the exception thrown in the then portion of the if statement. It makes for cleaner code.
1 2 3 4 5 6 7
|
void Actor::set_coordinates(const int x, const int y)
{ if ( x < MAP_BOUNDARY || y < MAP_BOUNDARY )
throw invalid_argument( "Attempt to set cartesian points out of bounds." );
// error conditions checked. Continue inline
xCoord = x;
yCoord = y;
}
|
Note: The above example assumes the existing boundary checking logic you're using, although I'm not sure it's what you meant.