Oh, I figured it out a few days ago, sorry I forgot to post it.
bool entity::slope_collision_detection( tile * Tile )
{
float y1 , y2 , x1 , x2 , m , b , x;
y1 = Tile->y;
y2 = Tile->y + tile_size;
x1 = Tile->x;
x2 = Tile->x + tile_size;
m = ( y2 - y1 ) / ( x2 - x1 );
if( Tile->tile_type == slope_right )
{
if( last_position.x + width - collision_box_position.x - FPS::FPS_control.last_time >= Tile->x + tile_size ) return false;
m *= -1;
}
if( Tile->tile_type == slope_left )
{
if( last_position.x + collision_box_position.x + 1 + FPS::FPS_control.last_time <= Tile->x ) return false;
}
if( last_position.y + height - collision_box_position.y - 1 + FPS::FPS_control.last_time >= Tile->y + tile_size ) return false;
b = y1 - m * x1;
x = position.x + collision_box_position.x * m;
if( position.y + height >= m * x + b + 1 )
{
on_ground = true;
position.y = m * x + b - height + 1 - FPS::FPS_control.last_time;
return true;
}
return true;
}
The additions and subtractions of 1 and FPS::FPS_control.last_time ( = time step ) are added so the sprite does not jitter, and for the slopes to line up perfectly to each other, so the sprite does not jump when traversing multi-tiled slopes.
The code works perfectly for me.