camera: instant follow on the first entity
parent
934aaf565f
commit
6b2f049704
|
@ -11,6 +11,9 @@ typedef struct {
|
|||
camera_mode mode;
|
||||
uint64_t ent_id;
|
||||
double x, y;
|
||||
|
||||
// HACK(zaklaus): Don't lerp if this is the first time we follow any entity.
|
||||
bool first_time;
|
||||
} camera;
|
||||
|
||||
void camera_reset(void);
|
||||
|
|
|
@ -10,6 +10,7 @@ static camera main_camera;
|
|||
void camera_reset(void) {
|
||||
zpl_zero_item(&main_camera);
|
||||
main_camera.mode = CAMERA_MODE_STATIONARY;
|
||||
main_camera.first_time = true;
|
||||
}
|
||||
|
||||
void camera_update(void) {
|
||||
|
@ -22,6 +23,12 @@ void camera_update(void) {
|
|||
|
||||
main_camera.x = zpl_lerp(main_camera.x, view->x, CAMERA_LERP_FACTOR);
|
||||
main_camera.y = zpl_lerp(main_camera.y, view->y, CAMERA_LERP_FACTOR);
|
||||
|
||||
if (main_camera.first_time) {
|
||||
main_camera.first_time = false;
|
||||
main_camera.x = view->x;
|
||||
main_camera.y = view->y;
|
||||
}
|
||||
}break;
|
||||
|
||||
default: {
|
||||
|
|
Loading…
Reference in New Issue