Fix regression in water air timer

scene_man
En Yi 2024-04-24 21:30:34 +08:00
parent c76ceba9bf
commit 6bcccf7412
2 changed files with 4 additions and 5 deletions

View File

@ -28,7 +28,7 @@ static inline unsigned int get_tile_idx(int x, int y, TileGrid_t gridmap)
{ {
unsigned int tile_x = x / gridmap.tile_size; unsigned int tile_x = x / gridmap.tile_size;
unsigned int tile_y = y / gridmap.tile_size; unsigned int tile_y = y / gridmap.tile_size;
return tile_y * gridmap.tile_size + tile_x; return tile_y * gridmap.width + tile_x;
} }
static inline void destroy_tile(LevelSceneData_t* lvl_data, unsigned int tile_idx) static inline void destroy_tile(LevelSceneData_t* lvl_data, unsigned int tile_idx)
@ -1895,8 +1895,7 @@ void airtimer_update_system(Scene_t* scene)
Entity_t* p_ent = get_entity(&scene->ent_manager, ent_idx); Entity_t* p_ent = get_entity(&scene->ent_manager, ent_idx);
if (!p_ent->m_alive) continue; if (!p_ent->m_alive) continue;
CBBox_t* p_bbox = get_component(p_ent, CBBOX_COMP_T); CBBox_t* p_bbox = get_component(p_ent, CBBOX_COMP_T);
CMovementState_t* p_movement = get_component(p_ent, CMOVEMENTSTATE_T); if (p_bbox == NULL) continue;
if (p_bbox == NULL || p_movement == NULL) continue;
Vector2 point_to_check = { Vector2 point_to_check = {
p_ent->position.x + p_bbox->half_size.x, p_ent->position.x + p_bbox->half_size.x,

View File

@ -98,8 +98,8 @@ Entity_t* create_player(EntityManager_t* ent_manager)
CAirTimer_t* p_air = add_component(p_ent, CAIRTIMER_T); CAirTimer_t* p_air = add_component(p_ent, CAIRTIMER_T);
p_air->max_count = 10; p_air->max_count = 10;
p_air->curr_count = 10; p_air->curr_count = 10;
p_air->max_ftimer = 300; p_air->max_ftimer = 1.0f;
p_air->decay_rate = 5; p_air->decay_rate = 1.0f;
CSprite_t* p_cspr = add_component(p_ent, CSPRITE_T); CSprite_t* p_cspr = add_component(p_ent, CSPRITE_T);
p_cspr->sprites = player_sprite_map; p_cspr->sprites = player_sprite_map;