Put the stuff in a more sensible position

This commit is contained in:
Bill Rossi 2025-01-07 20:47:31 -05:00
parent dfd204ff14
commit b994cb895d
3 changed files with 13 additions and 7 deletions
01_text_adventure

View File

@ -20,9 +20,10 @@ Game *game_create(void) {
Log *log = create_log();
g->log = log;
Vector2 input_position = { 190, 200 };
Vector2 input_position = { 20, 400 };
Input *input = create_input(input_position);
input->log = log;
log->input = input;
input->g = g;
input->command = '>'; // Don't change this
@ -91,7 +92,7 @@ void game_handle_directional_command(Game *g, const char *c) {
}
}
#define INVALID_COMMAND "I don't know how to "
#define INVALID_COMMAND "I don't know how to %s"
void game_handle_command(Game *g, const char *command) {
Input *input = g->input;
@ -110,7 +111,7 @@ void game_handle_command(Game *g, const char *command) {
break;
default:
char *response = malloc(strlen(INVALID_COMMAND) + strlen(command) + 1);
sprintf(response, INVALID_COMMAND "%s", command);
sprintf(response, INVALID_COMMAND, command);
push_line_to_log(input->log, response);
free(response);
break;

View File

@ -8,8 +8,8 @@ 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),
log->input->position.x,
log->input->position.y + ((line_num - log->line_count) * 20),
20,
RAYWHITE
);

View File

@ -1,10 +1,15 @@
#ifndef _FD_LOG_
#define _FD_LOG_
typedef struct Log {
typedef struct Log Log;
#include "input.h"
struct Log {
char** lines;
int line_count;
} Log;
Input *input;
};
Log *create_log(void);
void draw_log(Log*);