Just FYI, it might simplify things a bit to encapsulate common operations into (preferably generic) functions, eg:
Code:
template < typename Type >
inline void clamp( Type& value, Type const& low, Type const& high )
{
if( value < low )
value = low;
else if( value > high )
value = high;
}
...then you could rewrite that bit like so:
Code:
void Player::update()
{
if((clock() - Last_Update) > 50)
{
Last_Update = clock();
if(grapple_x != -1 && grapple_y != -1)
{
if(x_coord != grapple_x)x_vel = move_speed*(double)(grapple_x-x_coord)/((double)abs(grapple_y-y_coord)+(double)abs(grapple_x-x_coord));
else x_vel = 0;
if(y_coord != grapple_y)y_vel = move_speed*(double)(grapple_y-y_coord)/((double)abs(grapple_y-y_coord)+(double)abs(grapple_x-x_coord));
else y_vel = 0;
clamp< double >( x_coord += x_vel, 0, 960 );
clamp< double >( y_coord += y_vel, 0, 704 );
if(abs(x_coord-grapple_x) < move_speed+1 && abs(x_coord-grapple_y) < move_speed+1){grapple_x = -1;grapple_y = -1;}//correcting for being close, but not on top of a coordinate keeps player from spasming.
}
}
}
Just a suggestion.