diff options
| author | Raymaekers Luca <luca@spacehb.net> | 2025-09-07 12:22:02 +0200 |
|---|---|---|
| committer | Raymaekers Luca <luca@spacehb.net> | 2025-09-07 12:22:02 +0200 |
| commit | 86fe424f46f21a59ae871bb68ad20c998fe11b4a (patch) | |
| tree | 6b1b7813f4b924c069087a0df51aecc69f166339 | |
| parent | 62c46671921e1e8ba0e58b2e28b8ee25476598bb (diff) | |
checkpoint
| -rwxr-xr-x | build/handmade.so | bin | 261440 -> 263840 bytes | |||
| -rwxr-xr-x | build/linux_handmade | bin | 88016 -> 88272 bytes | |||
| -rw-r--r-- | code/handmade.cpp | 135 | ||||
| m--------- | code/libs/linuxhmh | 0 |
4 files changed, 73 insertions, 62 deletions
diff --git a/build/handmade.so b/build/handmade.so Binary files differindex 92ebde3..c9e6fde 100755 --- a/build/handmade.so +++ b/build/handmade.so diff --git a/build/linux_handmade b/build/linux_handmade Binary files differindex 01f5807..609ac5e 100755 --- a/build/linux_handmade +++ b/build/linux_handmade diff --git a/code/handmade.cpp b/code/handmade.cpp index fb96977..ca64c27 100644 --- a/code/handmade.cpp +++ b/code/handmade.cpp @@ -532,7 +532,7 @@ PLATFORM_WORK_QUEUE_CALLBACK(GetTodaysWordleCurl) struct tm *LocalTimeNow = localtime(&Now); u8 URLBuffer[256] = {}; - stbsp_sprintf((char *)URLBuffer, "%s/%d-%02d-%d.json", URL, + stbsp_sprintf((char *)URLBuffer, "%s/%d-%02d-%02d.json", URL, LocalTimeNow->tm_year + 1900, LocalTimeNow->tm_mon + 1, LocalTimeNow->tm_mday); @@ -946,79 +946,87 @@ extern "C" GAME_UPDATE_AND_RENDER(GameUpdateAndRender) s32 PatternRowAt = 0; s32 PatternRowsCount = 6; - for(s32 WordsIndex = 0; - ((WordsIndex < WordsCount) && - (PatternRowAt < PatternRowsCount)); - WordsIndex++) + for(s32 PatternRowAt = 0; + PatternRowAt < PatternRowsCount; + PatternRowAt++) { - // Match the pattern's row against the guess. - // TODO(luca): Check if the guess == the word and skip it otherwise it would end the game. - s32 PatternMatches = 1; - u8 *Guess = &Words[WordsIndex*(WORDLE_LENGTH+1)]; - for(s32 CharIndex = 0; - ((CharIndex < WORDLE_LENGTH) && - (PatternMatches)); - CharIndex++) + s32 PatternMatches = 0; + u8 *Guess = 0; + + for(s32 WordsIndex = 0; + ((WordsIndex < WordsCount) && + (!PatternMatches)); + WordsIndex++) { - u8 GuessCh = Guess[CharIndex]; - s32 PatternValue = GameState->PatternGrid[PatternRowAt][CharIndex]; - - if(PatternValue == SquareColor_Green) - { - PatternMatches = (GuessCh == Word[CharIndex]); - } - else if(PatternValue == SquareColor_Yellow) + // Match the pattern's row against the guess. + // TODO(luca): Check if the guess == the word and skip it otherwise it would end the game. + Guess = &Words[WordsIndex*(WORDLE_LENGTH+1)]; + PatternMatches = 1; + for(s32 CharIndex = 0; + ((CharIndex < WORDLE_LENGTH) && + (PatternMatches)); + CharIndex++) { - PatternMatches = 0; - for(s32 CharAt = 0; - CharAt < WORDLE_LENGTH; - CharAt++) + u8 GuessCh = Guess[CharIndex]; + s32 PatternValue = GameState->PatternGrid[PatternRowAt][CharIndex]; + + if(PatternValue == SquareColor_Green) + { + PatternMatches = (GuessCh == Word[CharIndex]); + } + else if(PatternValue == SquareColor_Yellow) { - if(Word[CharAt] == GuessCh) + PatternMatches = 0; + for(s32 CharAt = 0; + CharAt < WORDLE_LENGTH; + CharAt++) { - if(CharAt != CharIndex) + if(Word[CharAt] == GuessCh) { - // TODO(luca): Should also check that position does not match. - PatternMatches = ValidLetterCountInGuess(Word, Guess, GuessCh); - } - else - { - PatternMatches = 0; + if(CharAt != CharIndex) + { + // TODO(luca): Should also check that position does not match. + PatternMatches = ValidLetterCountInGuess(Word, Guess, GuessCh); + } + else + { + PatternMatches = 0; + } + + break; } - - break; } + } - - } - // TODO(luca): Have one that can be either yellow/green + // TODO(luca): Have one that can be either yellow/green #if 0 - else if(PatternValue == 1) - { - PatternMatches = 0; - for(s32 CharAt = 0; - CharAt < WORDLE_LENGTH; - CharAt++) + else if(PatternValue == 1) { - if(Word[CharAt] == GuessCh) + PatternMatches = 0; + for(s32 CharAt = 0; + CharAt < WORDLE_LENGTH; + CharAt++) { - PatternMatches = ValidLetterCountInGuess(Word, Guess, GuessCh); - break; + if(Word[CharAt] == GuessCh) + { + PatternMatches = ValidLetterCountInGuess(Word, Guess, GuessCh); + break; + } } } - } #endif - else if(PatternValue == SquareColor_Gray) - { - PatternMatches = 1; - for(s32 CharAt = 0; - CharAt < WORDLE_LENGTH; - CharAt++) + else if(PatternValue == SquareColor_Gray) { - if(Word[CharAt] == GuessCh) + PatternMatches = 1; + for(s32 CharAt = 0; + CharAt < WORDLE_LENGTH; + CharAt++) { - PatternMatches = 0; - break; + if(Word[CharAt] == GuessCh) + { + PatternMatches = 0; + break; + } } } } @@ -1029,12 +1037,15 @@ extern "C" GAME_UPDATE_AND_RENDER(GameUpdateAndRender) DrawText(Buffer, &DefaultFont, FontScale, WORDLE_LENGTH, Guess, TextOffset, color_rgb(1.0f), false); - - TextOffset.Y += YAdvance; - - WordsIndex = 0; - PatternRowAt++; } + else + { + u8 Text[] = "no match"; + DrawText(Buffer, &GameState->ItalicFont, FontScale, + sizeof(Text) - 1, Text, + TextOffset, color_rgb(0.6f), false); + } + TextOffset.Y += YAdvance; } } diff --git a/code/libs/linuxhmh b/code/libs/linuxhmh -Subproject 36c8c66d7e04d2a1b84630294cec3fb6dca90b2 +Subproject 00494541c8c1c4c7c8feb779cf401c015d42bc4 |
