Freeing everything

This commit is contained in:
Anonymus Raccoon
2020-01-11 17:55:08 +01:00
parent dbd49cfc36
commit f12b438cef
6 changed files with 9 additions and 16 deletions

View File

@@ -56,16 +56,12 @@
</gc_entity>
<gc_entity id="50">
<transform_component>
<Position x="500" y="-200" />
<Size x="1000000" y="10" />
</transform_component>
<transform_component />
<renderer text="" />
<collision_component layer="00000000" />
<fixed_to_cam />
<timer_component time="60"/>
</gc_entity>
<gc_entity>
<transform_component>
<Position x="-500" y="-200" />

View File

@@ -22,13 +22,13 @@ static void on_collide(gc_engine *engine, gc_entity *entity, int id)
if (GETCOLCMP(kill_component)) {
cmp->live--;
if (cmp->live < 0) {
exit(0);
engine->should_close = true;
} else {
trans->position = cmp->spawn_position;
}
}
if (GETCOLCMP(win_component)) {
exit(0);
engine->should_close = true;
}
}

View File

@@ -63,13 +63,8 @@ int start_game(const char *map)
return (ERROR);
if (create_game_scene(engine, map) < 0)
return (ERROR);
while (engine->is_open(engine)) {
while (engine->is_open(engine))
engine->game_loop(engine, sfTime_asSeconds(sfClock_restart(clock)));
if (engine->is_keypressed(sfKeyEscape)) {
prefab_load(engine, "prefabs/pause.gcprefab");
sfClock_restart(clock);
}
}
engine->destroy(engine);
sfClock_destroy(clock);
return (0);

View File

@@ -23,6 +23,8 @@ gc_entity *entity, float dtime)
if (!rend || rend->type != GC_TXTREND)
return;
timer->time_left -= dtime;
if (((gc_text *)rend->data)->text)
free(((gc_text *)rend->data)->text);
((gc_text *)rend->data)->text = tostr((int)timer->time_left);
(void)system;
(void)engine;