Correctly limit camera.
This commit is contained in:
parent
81000d7948
commit
0d534d6ef8
|
@ -287,7 +287,6 @@ struct Tuple {
|
|||
};
|
||||
|
||||
typedef struct {
|
||||
SDL_Rect bounds;
|
||||
float shakeAmount;
|
||||
int x;
|
||||
int y;
|
||||
|
|
|
@ -42,12 +42,12 @@ int getPercent(float current, float total)
|
|||
|
||||
float limit(float i, float a, float b)
|
||||
{
|
||||
if (i > a)
|
||||
if (i < a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
if (i < b)
|
||||
if (i > b)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
|
|
|
@ -84,10 +84,8 @@ float cameraChase(Entity *e, int maxSpeed)
|
|||
|
||||
void clip(void)
|
||||
{
|
||||
camera.bounds.x = (int) limit(camera.x, world.map.bounds.x, world.map.bounds.w);
|
||||
camera.bounds.y = (int) limit(camera.y, world.map.bounds.y, world.map.bounds.h + (MAP_TILE_SIZE * 3));
|
||||
camera.bounds.w = SCREEN_WIDTH;
|
||||
camera.bounds.h = SCREEN_HEIGHT;
|
||||
camera.x = (int) limit(camera.x, world.map.bounds.x, world.map.bounds.w);
|
||||
camera.y = (int) limit(camera.y, world.map.bounds.y, world.map.bounds.h);
|
||||
}
|
||||
|
||||
int isOnScreen(Entity *e)
|
||||
|
|
Loading…
Reference in New Issue