X-Git-Url: https://git.rohieb.name/hackover2013-badge-firmware.git/blobdiff_plain/01d395b92b5ba972a6e1c3d8f2bf4803f155a3cb..1f9537dd82ca8630e31e61796ae82ab9479c6a84:/badge/jumpnrun/level_load.c?ds=sidebyside diff --git a/badge/jumpnrun/level_load.c b/badge/jumpnrun/level_load.c index 4b1e499..ae1a91f 100644 --- a/badge/jumpnrun/level_load.c +++ b/badge/jumpnrun/level_load.c @@ -11,8 +11,8 @@ #include typedef struct { - uint8_t x; - uint16_t y; + uint16_t x; + uint8_t y; uint8_t type; } level_thing; @@ -20,7 +20,7 @@ static level_thing jumpnrun_level_parse_blob(unsigned char blob[3]) { level_thing result; result.y = blob[0] >> 4; - result.x = ((blob[0] & 0xf) << 8) | blob[1]; + result.x = ((blob[0] & 0x0f) << 8) | blob[1]; result.type = blob[2]; return result; @@ -51,8 +51,8 @@ static void jumpnrun_level_make_enemy(jumpnrun_enemy *dest, level_thing thing) { dest->type = &jumpnrun_enemy_type_data[thing.type]; - dest->spawn_pos.x = FIXED_POINT( thing.x * JUMPNRUN_TILE_PIXEL_WIDTH , 0); - dest->spawn_pos.y = FIXED_POINT((thing.y + 1) * JUMPNRUN_TILE_PIXEL_HEIGHT - dest->type->animation_frames[0].height, 0); + dest->spawn_pos.x = FIXED_INT( thing.x * JUMPNRUN_TILE_PIXEL_WIDTH + fixed_point_cast_int(dest->type->hitbox.pos.x)); + dest->spawn_pos.y = FIXED_INT((thing.y + 1) * JUMPNRUN_TILE_PIXEL_HEIGHT - fixed_point_cast_int(dest->type->hitbox.extent.y)); jumpnrun_enemy_despawn(dest); }