#include <stdio.h>
typedef struct {
- uint8_t x;
- uint16_t y;
+ uint16_t x;
+ uint8_t y;
uint8_t type;
} level_thing;
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;
memset(dest, 0, sizeof(*dest));
dest->type = &jumpnrun_item_type_data[thing.type];
- dest->pos.x = FIXED_POINT( thing.x * JUMPNRUN_TILE_PIXEL_WIDTH , 0);
- dest->pos.y = FIXED_POINT((thing.y + 1) * JUMPNRUN_TILE_PIXEL_WIDTH - dest->type->sprite.height, 0);
+
+ uint8_t xoff = (JUMPNRUN_TILE_PIXEL_WIDTH - (dest->type->sprite.width % JUMPNRUN_TILE_PIXEL_WIDTH)) / 2;
+ uint8_t yoff = thing.type != JUMPNRUN_ITEM_TYPE_CHECKPOINT ? 1 : 0; // HACK: spezielle Ausnahme
+
+ dest->pos.x = FIXED_POINT( thing.x * JUMPNRUN_TILE_PIXEL_WIDTH + xoff, 0);
+ dest->pos.y = FIXED_POINT((thing.y + 1) * JUMPNRUN_TILE_PIXEL_WIDTH - dest->type->sprite.height - yoff, 0);
}
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->base.current_box = rectangle_new(dest->spawn_pos, dest->type->extent);
- dest->base.inertia = dest->type->spawn_inertia;
+ 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);
}
#ifdef __linux__
#endif
return JUMPNRUN_LEVEL_LOAD_ERROR;
} else {
- dest->start_pos.x = fixed_point_sub(FIXED_INT((spos[0] + 1) * JUMPNRUN_TILE_PIXEL_WIDTH ), hacker_extents().x);
+ dest->start_pos.x = fixed_point_sub(FIXED_INT((spos[0] + 1) * JUMPNRUN_TILE_PIXEL_WIDTH ), jumpnrun_player_extents().x);
dest->start_pos.y = FIXED_INT( spos[1] * JUMPNRUN_TILE_PIXEL_HEIGHT);
}
+#ifdef __linux__
+ if(1 != fread(&dest->start_lives, 1, 1, fd)) {
+#else
+ if(FR_OK != f_read(fd, &dest->start_lives, sizeof(dest->start_lives), &count) || count != sizeof(dest->start_lives)) {
+#endif
+ return JUMPNRUN_LEVEL_LOAD_ERROR;
+ }
+
for(i = 0; i < dest->header.tile_count; ++i) {
#ifdef __linux__
if(1 != fread(buf, 3, 1, fd)) {