From b994cb895d0fca1a829eef86ddfce5d33de34951 Mon Sep 17 00:00:00 2001 From: Bill Rossi Date: Tue, 7 Jan 2025 20:47:31 -0500 Subject: [PATCH] Put the stuff in a more sensible position --- 01_text_adventure/game.c | 7 ++++--- 01_text_adventure/log.c | 4 ++-- 01_text_adventure/log.h | 9 +++++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/01_text_adventure/game.c b/01_text_adventure/game.c index 8c9d8b6..88f0a73 100644 --- a/01_text_adventure/game.c +++ b/01_text_adventure/game.c @@ -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; diff --git a/01_text_adventure/log.c b/01_text_adventure/log.c index 2fc44d2..1a043b1 100644 --- a/01_text_adventure/log.c +++ b/01_text_adventure/log.c @@ -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 ); diff --git a/01_text_adventure/log.h b/01_text_adventure/log.h index b6b74c8..fbc77d6 100644 --- a/01_text_adventure/log.h +++ b/01_text_adventure/log.h @@ -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*);