forked from kdx/jtmm2-old
Changed meaning of origin
This commit is contained in:
parent
1a9052c0a2
commit
943348e545
|
@ -8,7 +8,7 @@ typedef struct Player {
|
|||
Vec spd; /* velocity */
|
||||
Vec hbox; /* the bottom left corner of the player's hitbox */
|
||||
Vec vbox; /* the bottom left corner of the player's visual box */
|
||||
Vec origin; /* the origin of the player (offset) */
|
||||
Vec origin; /* the origin of the sprite (offset) */
|
||||
uint grace; /* coyot jump */
|
||||
} Player;
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ uint8_t collide_point(Vec point, const Level *level, uint layer_id) {
|
|||
bool player_collide(Player *player, Vec position, const Level *level, uint layer_id) {
|
||||
Vec pos;
|
||||
vec_cpy(&pos, position);
|
||||
vec_sub(&pos, player->origin);
|
||||
if (collide_point(pos, level, layer_id)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ int play_level(uint level_id) {
|
|||
.origin = {0 * VEC_PRECISION, 0 * VEC_PRECISION},
|
||||
.grace = 0
|
||||
};
|
||||
vec_cpy(&player.pos, player.origin); /* place the player at "0/0"*/
|
||||
vec_cpy(&player.pos, (Vec){0, 0}); /* place the player at "0/0"*/
|
||||
|
||||
/* set level */
|
||||
const Level *level;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define PLAYER_COLLIDE(pos) player_collide(player, pos, level, level->solid_layer)
|
||||
|
||||
void player_move(Player *player, const Level *level) {
|
||||
/* TODO: Take into account player.origin. */
|
||||
/* TODO: Take into account player's hitbox */
|
||||
const int sgn_spd_x = SGN(player->spd.x);
|
||||
const int sgn_spd_y = SGN(player->spd.y);
|
||||
Vec destination;
|
||||
|
@ -90,7 +90,7 @@ void player_draw(Player *player, Camera *camera) {
|
|||
/* The rest of this function calculates the player on screen
|
||||
* position and draw it. */
|
||||
vec_cpy(&tl, player->pos);
|
||||
vec_sub(&tl, player->origin);
|
||||
vec_add(&tl, player->origin);
|
||||
vec_cpy(&br, tl);
|
||||
vec_div(&tl, VEC_PRECISION);
|
||||
vec_div(&br, VEC_PRECISION);
|
||||
|
|
Loading…
Reference in New Issue