Compare commits
No commits in common. "071c68811f1381da52dc64f673c21872d7769cd7" and "9e151e2f3f837081a5d3a3fb48310665cecb4aca" have entirely different histories.
071c68811f
...
9e151e2f3f
12
TODO.md
12
TODO.md
|
|
@ -8,12 +8,14 @@
|
||||||
|
|
||||||
- [ ] Add compression into asset builder and asset manager
|
- [ ] Add compression into asset builder and asset manager
|
||||||
|
|
||||||
|
- [ ] Make functionnal hitboxes between entities and map
|
||||||
|
|
||||||
- [ ] Make triggers
|
- [ ] Make triggers
|
||||||
- [ ] Add triggers into map loading
|
- [ ] Add triggers into map loading
|
||||||
|
|
||||||
- [ ] Make camera use acceleration
|
- [ ] Make physics component use acceleration
|
||||||
|
|
||||||
- [ ] Create lua component
|
- [ ] Make camera use acceleration
|
||||||
|
|
||||||
###### Bugs
|
###### Bugs
|
||||||
|
|
||||||
|
|
@ -24,12 +26,10 @@
|
||||||
|
|
||||||
### In progress
|
### In progress
|
||||||
|
|
||||||
|
- [ ] Create lua component
|
||||||
|
|
||||||
### Done
|
### Done
|
||||||
|
|
||||||
- [x] Make functionnal hitboxes between entities and map
|
|
||||||
|
|
||||||
- [x] Make physics component use acceleration
|
|
||||||
|
|
||||||
- [x] Rethink makefile structure
|
- [x] Rethink makefile structure
|
||||||
|
|
||||||
- [x] Make camera center on map
|
- [x] Make camera center on map
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ endif
|
||||||
$(LIBCORE): $(OBJECTS)
|
$(LIBCORE): $(OBJECTS)
|
||||||
$(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE) + 1))))
|
$(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE) + 1))))
|
||||||
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE) * 100 / $(TOTAL_BUILD_FILES)))))
|
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE) * 100 / $(TOTAL_BUILD_FILES)))))
|
||||||
@echo $(ECHO_OPTION) "[$(PERCENTAGE)%] $(YELLOW)Linking Static Lib $@$(RESET)"
|
@echo $(ECHO_OPTION) "[$(PERCENTAGE)%] $(YELLOW)Creating Static Lib $@$(RESET)"
|
||||||
$(Q)$(TARGET_HOST_AR) rcs $@ $(OBJECTS)
|
$(Q)$(TARGET_HOST_AR) rcs $@ $(OBJECTS)
|
||||||
|
|
||||||
$(BUILD_DIR)/$(notdir $(CORE_DIR))/%.o: $(CORE_DIR)/%
|
$(BUILD_DIR)/$(notdir $(CORE_DIR))/%.o: $(CORE_DIR)/%
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ int destroy_asset(asset_t *asset)
|
||||||
}
|
}
|
||||||
|
|
||||||
// No args
|
// No args
|
||||||
int create_asset_header_def(asset_header_def_t *asset_header_def, va_list args __attribute__((unused)))
|
int create_asset_header_def(asset_header_def_t *asset_header_def, va_list args)
|
||||||
{
|
{
|
||||||
asset_header_def->name = NULL;
|
asset_header_def->name = NULL;
|
||||||
|
|
||||||
|
|
|
||||||
39
core/map.c
39
core/map.c
|
|
@ -499,42 +499,3 @@ int map_display_foreground(void)
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG > 1
|
|
||||||
int map_display_hitboxes(void)
|
|
||||||
{
|
|
||||||
uint32_t left_tile = 0;
|
|
||||||
if(game.camera.view_rect.x / TILE_SIZE > 0)
|
|
||||||
left_tile = game.camera.view_rect.x / TILE_SIZE;
|
|
||||||
|
|
||||||
uint32_t right_tile = game.map->width;
|
|
||||||
if((game.camera.view_rect.x + game.camera.view_rect.w) / TILE_SIZE + 1 < (int)game.map->width)
|
|
||||||
right_tile = (game.camera.view_rect.x + game.camera.view_rect.w) / TILE_SIZE + 1;
|
|
||||||
|
|
||||||
uint32_t top_tile = 0;
|
|
||||||
if(game.camera.view_rect.y / TILE_SIZE > 0)
|
|
||||||
top_tile = game.camera.view_rect.y / TILE_SIZE;
|
|
||||||
|
|
||||||
uint32_t bottom_tile = game.map->height;
|
|
||||||
if((game.camera.view_rect.y + game.camera.view_rect.h) / TILE_SIZE + 1 < (int)game.map->height)
|
|
||||||
bottom_tile = (game.camera.view_rect.y + game.camera.view_rect.h) / TILE_SIZE + 1;
|
|
||||||
|
|
||||||
for(uint32_t tile_y = top_tile; tile_y < bottom_tile; tile_y++)
|
|
||||||
for(uint32_t tile_x = left_tile; tile_x < right_tile; tile_x++)
|
|
||||||
{
|
|
||||||
if(game.map->hitboxes[tile_y * game.map->width + tile_x] == 1)
|
|
||||||
{
|
|
||||||
frect_t draw_frect = {
|
|
||||||
.x = tile_x * TILE_SIZE,
|
|
||||||
.y = tile_y * TILE_SIZE,
|
|
||||||
.w = TILE_SIZE,
|
|
||||||
.h = TILE_SIZE
|
|
||||||
};
|
|
||||||
|
|
||||||
if(display_draw_frect(&draw_frect, C_RED, 128)) return_failure_int;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
#endif // DEBUG > 1
|
|
||||||
|
|
@ -41,8 +41,4 @@ int map_display_background(void);
|
||||||
|
|
||||||
int map_display_foreground(void);
|
int map_display_foreground(void);
|
||||||
|
|
||||||
#if DEBUG > 1
|
|
||||||
int map_display_hitboxes(void);
|
|
||||||
#endif // DEBUG > 1
|
|
||||||
|
|
||||||
#endif // MAP_H
|
#endif // MAP_H
|
||||||
|
|
@ -54,85 +54,9 @@ int physics_system_update(component_t *component)
|
||||||
|
|
||||||
system_data->velocity.x = lerp_time(system_data->velocity.x, system_data->target_velocity.x * system_data->speed, system_data->smoothing_factor, game.delta_time_ms);
|
system_data->velocity.x = lerp_time(system_data->velocity.x, system_data->target_velocity.x * system_data->speed, system_data->smoothing_factor, game.delta_time_ms);
|
||||||
system_data->velocity.y = lerp_time(system_data->velocity.y, system_data->target_velocity.y * system_data->speed, system_data->smoothing_factor, game.delta_time_ms);
|
system_data->velocity.y = lerp_time(system_data->velocity.y, system_data->target_velocity.y * system_data->speed, system_data->smoothing_factor, game.delta_time_ms);
|
||||||
|
|
||||||
if(hitbox_component_data->activated)
|
if(hitbox_component_data->activated)
|
||||||
{
|
|
||||||
// Resolve entities collisions.
|
|
||||||
if(linked_list_for_each(&game.entity_manager.entities, action_detect_solve_entities_collision, component)) return EXIT_FAILURE;
|
if(linked_list_for_each(&game.entity_manager.entities, action_detect_solve_entities_collision, component)) return EXIT_FAILURE;
|
||||||
|
|
||||||
// Resolve map collisions
|
|
||||||
if(game.map)
|
|
||||||
{
|
|
||||||
uint16_t left_tile = 0;
|
|
||||||
if(game.camera.view_rect.x / TILE_SIZE > 0)
|
|
||||||
left_tile = hitbox_component_data->bounds.x / TILE_SIZE;
|
|
||||||
|
|
||||||
uint16_t right_tile = game.map->width;
|
|
||||||
if((hitbox_component_data->bounds.x + hitbox_component_data->bounds.w) / TILE_SIZE + 1 < game.map->width)
|
|
||||||
right_tile = (hitbox_component_data->bounds.x + hitbox_component_data->bounds.w) / TILE_SIZE + 1;
|
|
||||||
|
|
||||||
uint16_t top_tile = 0;
|
|
||||||
if(hitbox_component_data->bounds.y / TILE_SIZE > 0)
|
|
||||||
top_tile = hitbox_component_data->bounds.y / TILE_SIZE;
|
|
||||||
|
|
||||||
uint16_t bottom_tile = game.map->height;
|
|
||||||
if((hitbox_component_data->bounds.y + hitbox_component_data->bounds.h) / TILE_SIZE + 1 < game.map->height)
|
|
||||||
bottom_tile = (hitbox_component_data->bounds.y + hitbox_component_data->bounds.h) / TILE_SIZE + 1;
|
|
||||||
|
|
||||||
for(uint16_t tile_y = top_tile; tile_y < bottom_tile; tile_y++)
|
|
||||||
for(uint16_t tile_x = left_tile; tile_x < right_tile; tile_x++)
|
|
||||||
{
|
|
||||||
if(game.map->hitboxes[tile_y * game.map->width + tile_x] == 1)
|
|
||||||
{
|
|
||||||
const frect_t *hitbox_bounds = &hitbox_component_data->bounds;
|
|
||||||
const frect_t target_hitbox_bounds = {
|
|
||||||
.x = tile_x * TILE_SIZE,
|
|
||||||
.y = tile_y * TILE_SIZE,
|
|
||||||
.w = TILE_SIZE,
|
|
||||||
.h = TILE_SIZE
|
|
||||||
};
|
|
||||||
frect_t intersect;
|
|
||||||
|
|
||||||
if(intersect_frect(hitbox_bounds, &target_hitbox_bounds, &intersect))
|
|
||||||
{
|
|
||||||
if(intersect.w < intersect.h)
|
|
||||||
{
|
|
||||||
const float left_correction = hitbox_bounds->x + hitbox_bounds->w - target_hitbox_bounds.x;
|
|
||||||
const float right_correction = target_hitbox_bounds.x + target_hitbox_bounds.w - hitbox_bounds->x;
|
|
||||||
|
|
||||||
if(left_correction < right_correction)
|
|
||||||
{
|
|
||||||
transform_component_data->bounds.x -= left_correction;
|
|
||||||
if(system_data->velocity.x > 0.0f) system_data->velocity.x = 0.0f;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
transform_component_data->bounds.x += right_correction;
|
|
||||||
if(system_data->velocity.x < 0.0f) system_data->velocity.x = 0.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
float top_correction = hitbox_bounds->y + hitbox_bounds->h - target_hitbox_bounds.y;
|
|
||||||
float bottom_correction = target_hitbox_bounds.y + target_hitbox_bounds.h - hitbox_bounds->y;
|
|
||||||
|
|
||||||
if(top_correction < bottom_correction)
|
|
||||||
{
|
|
||||||
transform_component_data->bounds.y -= top_correction;
|
|
||||||
if(system_data->velocity.y > 0.0f) system_data->velocity.y = 0.0f;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
transform_component_data->bounds.y += bottom_correction;
|
|
||||||
if(system_data->velocity.y < 0.0f) system_data->velocity.y = 0.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
transform_component_data->bounds.x += system_data->velocity.x * (float)game.delta_time_ms / 1000.0f;
|
transform_component_data->bounds.x += system_data->velocity.x * (float)game.delta_time_ms / 1000.0f;
|
||||||
transform_component_data->bounds.y += system_data->velocity.y * (float)game.delta_time_ms / 1000.0f;
|
transform_component_data->bounds.y += system_data->velocity.y * (float)game.delta_time_ms / 1000.0f;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -186,14 +186,6 @@ int game_render(void)
|
||||||
return_failure_int;
|
return_failure_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG > 1
|
|
||||||
if(map_display_hitboxes())
|
|
||||||
{
|
|
||||||
game.is_running = false;
|
|
||||||
return_failure_int;
|
|
||||||
}
|
|
||||||
#endif // DEBUG > 1
|
|
||||||
|
|
||||||
if(display_update())
|
if(display_update())
|
||||||
{
|
{
|
||||||
game.is_running = false;
|
game.is_running = false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue