forked from kdx/jtmm2-old
a40d42584c
takes into account SCALE.
42 lines
1.2 KiB
C
42 lines
1.2 KiB
C
#include <gint/display.h>
|
|
|
|
#include "player.h"
|
|
#include "conf.h"
|
|
#include "camera.h"
|
|
#include "input.h"
|
|
|
|
void player_step(Player *player, Input *input)
|
|
{
|
|
Vec move = {
|
|
(input_is_down(input, K_RIGHT) - input_is_down(input, K_LEFT)),
|
|
(input_is_down(input, K_DOWN) - input_is_down(input, K_UP))
|
|
};
|
|
vec_mul(&move, 32 * PXS);
|
|
vec_add(&player->pos, move);
|
|
}
|
|
|
|
void player_draw(Player *player, Camera *camera)
|
|
{
|
|
Vec draw_pos_tl;
|
|
Vec draw_pos_br;
|
|
vec_cpy(&draw_pos_tl, player->pos);
|
|
vec_sub(&draw_pos_tl, player->origin);
|
|
vec_cpy(&draw_pos_br, draw_pos_tl);
|
|
vec_add(&draw_pos_br, player->hbox);
|
|
vec_div(&draw_pos_tl, VEC_PRECISION);
|
|
vec_div(&draw_pos_br, VEC_PRECISION);
|
|
vec_mul(&draw_pos_tl, SCALE);
|
|
vec_mul(&draw_pos_br, SCALE);
|
|
drect(draw_pos_tl.x, draw_pos_tl.y, draw_pos_br.x, draw_pos_br.y, C_BLACK);
|
|
}
|
|
|
|
void player_draw_debug(Player *player, uint step)
|
|
{
|
|
dprint(0, 0, C_BLACK, "x: %d", player->pos.x);
|
|
dprint(0, 10, C_BLACK, "y: %d", player->pos.y);
|
|
dprint(0, 20, C_BLACK, "dx: %d", player->pos.x / SCALE * VEC_PRECISION);
|
|
dprint(0, 30, C_BLACK, "dy: %d", player->pos.y / SCALE * VEC_PRECISION);
|
|
dprint(0, 40, C_BLACK, "vp: %d", VEC_PRECISION);
|
|
dprint(0, 50, C_BLACK, "st: %u", step);
|
|
}
|