minor syntactic cleanup

This commit is contained in:
Gregory Gauthier 2025-12-17 09:28:00 +00:00
parent 8f3e6ef638
commit 7679dd9c6c
4 changed files with 40 additions and 35 deletions

View File

@ -3,7 +3,7 @@
// //
/* main.c - Entry point and main game loop */ /* main.c - Entry point and main game loop */
/* Compile with: gcc -std=c90 -o cordle src/*.c -Iinclude -lncurses */ /* Compile with: gcc -std=c90 -o cordle src\/\*.c -Iinclude -lncurses */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -165,7 +165,8 @@ int main_game_loop(int argc, char* argv[]) {
key = getch(); key = getch();
/* Handle input */ /* Handle input */
if (key == 27) { /* ESC */ if (key == 27) {
/* ESC */
break; break;
} else if (key == '\n' || key == '\r' || key == KEY_ENTER) { } else if (key == '\n' || key == '\r' || key == KEY_ENTER) {
if (game.current_guess_length == WORD_LENGTH) { if (game.current_guess_length == WORD_LENGTH) {

View File

@ -41,7 +41,7 @@ void draw_board(WINDOW* win, GameState* game, int y) {
y_pos = y + row * 2; y_pos = y + row * 2;
if (row < game->guess_count) { if (row < game->guess_count) {
/* Draw completed guess */ /* Draw a completed guess */
for (col = 0; col < WORD_LENGTH; col++) { for (col = 0; col < WORD_LENGTH; col++) {
x_pos = board_x + col * 4; x_pos = board_x + col * 4;
sprintf(cell, "[%c]", game->guesses[row][col]); sprintf(cell, "[%c]", game->guesses[row][col]);
@ -98,10 +98,14 @@ void draw_keyboard(WINDOW* win, GameState* game, int y) {
status = game->letter_status[letter - 'A']; status = game->letter_status[letter - 'A'];
switch (status) { switch (status) {
case STATUS_CORRECT: color = COLOR_CORRECT; break; case STATUS_CORRECT: color = COLOR_CORRECT;
case STATUS_PRESENT: color = COLOR_PRESENT; break; break;
case STATUS_ABSENT: color = COLOR_ABSENT; break; case STATUS_PRESENT: color = COLOR_PRESENT;
default: color = COLOR_UNUSED; break; break;
case STATUS_ABSENT: color = COLOR_ABSENT;
break;
default: color = COLOR_UNUSED;
break;
} }
if (color == COLOR_UNUSED) { if (color == COLOR_UNUSED) {