thrive/01_text_adventure/log.c

32 lines
708 B
C
Raw Normal View History

2024-08-30 06:27:14 -04:00
#include "log.h"
#include "../raylib.h"
#include <stdlib.h>
#include <string.h>
void draw_log(Log* log) {
for(int line_num = log->line_count - 1; line_num >= 0; 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);
}