Make water runner travel faster
Changelog: - introduce travel speed: how many move can the water runner make - normal movement cost : 2 - water movement cost : 1scene_man
parent
d2a19c5405
commit
963ba34164
|
@ -163,6 +163,7 @@ typedef struct _CWaterRunner {
|
||||||
int32_t fill_idx;
|
int32_t fill_idx;
|
||||||
int16_t fill_range[2];
|
int16_t fill_range[2];
|
||||||
uint8_t movement_delay;
|
uint8_t movement_delay;
|
||||||
|
int8_t movement_speed;
|
||||||
int16_t counter;
|
int16_t counter;
|
||||||
}CWaterRunner_t;
|
}CWaterRunner_t;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ Entity_t* create_water_runner(EntityManager_t* ent_manager, int32_t width, int32
|
||||||
p_crunner->bfs_tilemap.height = height;
|
p_crunner->bfs_tilemap.height = height;
|
||||||
p_crunner->bfs_tilemap.len = total;
|
p_crunner->bfs_tilemap.len = total;
|
||||||
p_crunner->movement_delay = 5;
|
p_crunner->movement_delay = 5;
|
||||||
|
p_crunner->movement_speed = 6;
|
||||||
|
|
||||||
sc_queue_init(&p_crunner->bfs_queue);
|
sc_queue_init(&p_crunner->bfs_queue);
|
||||||
p_crunner->visited = calloc(total, sizeof(bool));
|
p_crunner->visited = calloc(total, sizeof(bool));
|
||||||
|
@ -216,18 +217,31 @@ void update_water_runner_system(Scene_t* scene)
|
||||||
case LOWEST_POINT_MOVEMENT:
|
case LOWEST_POINT_MOVEMENT:
|
||||||
p_crunner->counter--;
|
p_crunner->counter--;
|
||||||
if (p_crunner->counter == 0)
|
if (p_crunner->counter == 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
int8_t move_left = p_crunner->movement_speed;
|
||||||
|
while (move_left)
|
||||||
{
|
{
|
||||||
p_crunner->current_tile = p_crunner->bfs_tilemap.tilemap[p_crunner->current_tile].to;
|
p_crunner->current_tile = p_crunner->bfs_tilemap.tilemap[p_crunner->current_tile].to;
|
||||||
CTransform_t* p_ct = get_component(ent, CTRANSFORM_COMP_T);
|
CTransform_t* p_ct = get_component(ent, CTRANSFORM_COMP_T);
|
||||||
p_ct->position.x = (p_crunner->current_tile % tilemap.width) * tilemap.tile_size;
|
p_ct->position.x = (p_crunner->current_tile % tilemap.width) * tilemap.tile_size;
|
||||||
p_ct->position.y = (p_crunner->current_tile / tilemap.width) * tilemap.tile_size;
|
p_ct->position.y = (p_crunner->current_tile / tilemap.width) * tilemap.tile_size;
|
||||||
tilemap.tiles[p_crunner->current_tile].wet = true;
|
|
||||||
|
Tile_t* tile = tilemap.tiles + p_crunner->current_tile;
|
||||||
|
tile->wet = true;
|
||||||
|
move_left--;
|
||||||
|
if (tile->water_level != tile->max_water_level)
|
||||||
|
{
|
||||||
|
move_left--;
|
||||||
|
}
|
||||||
if (p_crunner->current_tile == p_crunner->target_tile)
|
if (p_crunner->current_tile == p_crunner->target_tile)
|
||||||
{
|
{
|
||||||
p_crunner->state = REACHABILITY_SEARCH;
|
p_crunner->state = REACHABILITY_SEARCH;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
p_crunner->counter = p_crunner->movement_delay;
|
p_crunner->counter = p_crunner->movement_delay;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case REACHABILITY_SEARCH:
|
case REACHABILITY_SEARCH:
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue