forked from kdx/jtmm2-old
33 lines
722 B
C
33 lines
722 B
C
#include <gint/display.h>
|
|
|
|
#include "camera.h"
|
|
#include "conf.h"
|
|
#include "vec.h"
|
|
#include "debug.h"
|
|
|
|
void camera_step(Camera *camera)
|
|
{
|
|
/* lerp towards target */
|
|
vec_lerp(&camera->pos, *camera->target, camera->speed);
|
|
/* calculate pixel offset */
|
|
Vec * const offset = &camera->offset; /* DRY */
|
|
vec_cpy(offset, camera->pos);
|
|
vec_div(offset, VEC_PRECISION);
|
|
vec_sub(offset, VEC_DCENTER);
|
|
}
|
|
|
|
void camera_draw_debug(Camera *camera)
|
|
{
|
|
Vec draw_pos;
|
|
vec_cpy(&draw_pos, camera->pos);
|
|
vec_mul(&draw_pos, SCALE);
|
|
vec_div(&draw_pos, VEC_PRECISION);
|
|
#ifdef FX9860G
|
|
const int color = C_BLACK;
|
|
#endif /* FX9860G */
|
|
#ifdef FXCG50
|
|
const int color = C_RED;
|
|
#endif /* FXCG50 */
|
|
dpixel(draw_pos.x, draw_pos.y, color);
|
|
}
|