#include "log.h" #include "../raylib.h" #include #include void draw_log(Log* log) { for(int line_num = 0; line_num < log->line_count; line_num++) { DrawText( log->lines[line_num], 190, 200 + ((line_num - log->line_count) * 20), 20, RAYWHITE ); } } Log *create_log(void) { Log *log = malloc(sizeof(Log)); log->line_count = 0; log->lines = malloc(sizeof(char**)); return log; } void push_line_to_log(Log* log, char* line) { log->line_count++; log->lines = realloc(log->lines, log->line_count * sizeof(char*)); log->lines[log->line_count - 1] = malloc(strlen(line) + 1); strcpy(log->lines[log->line_count - 1], line); } void free_log(Log* log) { for(int line_num = 0; line_num < log->line_count; line_num++) { free(log->lines[line_num]); } free(log->lines); }