aboutsummaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
Diffstat (limited to 'code')
-rwxr-xr-xcode/build.sh9
-rw-r--r--code/handmade.cpp155
l---------code/libs/linuxhmh/handmade_platform.h1
l---------code/libs/linuxhmh/linux_handmade.cpp1
l---------code/libs/linuxhmh/linux_handmade.h1
l---------code/libs/linuxhmh/linux_profile.h1
l---------code/libs/linuxhmh/linux_x11_keysym_and_buttons.c1
l---------code/libs/linuxhmh/linux_x11_keysyms_to_strings.c1
l---------code/libs/linuxhmh/win32_handmade.cpp1
l---------code/libs/linuxhmh/win32_handmade.h1
10 files changed, 93 insertions, 79 deletions
diff --git a/code/build.sh b/code/build.sh
index 966bcc3..9575bfe 100755
--- a/code/build.sh
+++ b/code/build.sh
@@ -5,7 +5,7 @@ cd "$ThisDir"
mkdir ../build > /dev/null 2>&1
-# Supported: clang, g++
+# Supported: clang
Compiler="clang"
CompilerFlags="
@@ -15,7 +15,9 @@ CompilerFlags="
-DHANDMADE_INTERNAL
-DHANDMADE_SLOW
-DOS_LINUX
+-DHANDMADE_SMALL_RESOLUTION
-nostdinc++
+
"
WarningFlags="-Wall
@@ -26,7 +28,10 @@ WarningFlags="-Wall
-Wno-write-strings
-Wno-pointer-arith
-Wno-unused-parameter
--Wno-unused-function"
+-Wno-unused-function
+-Wno-int-to-pointer-cast
+-Wno-missing-field-initializers
+"
ClangCompilerFlags="
-ftime-trace
diff --git a/code/handmade.cpp b/code/handmade.cpp
index fb96977..932215d 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);
@@ -659,6 +659,7 @@ extern "C" GAME_UPDATE_AND_RENDER(GameUpdateAndRender)
InitFont(Thread, &GameState->RegularFont, Memory, "../data/fonts/jetbrains_mono_regular.ttf");
InitFont(Thread, &GameState->ItalicFont, Memory, "../data/fonts/jetbrains_mono_italic.ttf");
InitFont(Thread, &GameState->BoldFont, Memory, "../data/fonts/jetbrains_mono_bold.ttf");
+ // TODO(luca): Italic & Bold font.
GameState->SelectedColor = SquareColor_Yellow;
GameState->ExportedPatternIndex = 0;
@@ -946,79 +947,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)
+ // 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 = (GuessCh == Word[CharIndex]);
- }
- else if(PatternValue == SquareColor_Yellow)
- {
- PatternMatches = 0;
- for(s32 CharAt = 0;
- CharAt < WORDLE_LENGTH;
- CharAt++)
+ u8 GuessCh = Guess[CharIndex];
+ s32 PatternValue = GameState->PatternGrid[PatternRowAt][CharIndex];
+
+ if(PatternValue == SquareColor_Green)
{
- if(Word[CharAt] == GuessCh)
+ PatternMatches = (GuessCh == Word[CharIndex]);
+ }
+ else if(PatternValue == SquareColor_Yellow)
+ {
+ PatternMatches = 0;
+ for(s32 CharAt = 0;
+ CharAt < WORDLE_LENGTH;
+ CharAt++)
{
- if(CharAt != CharIndex)
- {
- // TODO(luca): Should also check that position does not match.
- PatternMatches = ValidLetterCountInGuess(Word, Guess, GuessCh);
- }
- else
+ if(Word[CharAt] == GuessCh)
{
- 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 +1038,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;
}
}
@@ -1044,7 +1056,7 @@ extern "C" GAME_UPDATE_AND_RENDER(GameUpdateAndRender)
// NOTE(luca): Debug code for drawing inputted text.
#if 1
{
- r32 FontScale = stbtt_ScaleForPixelHeight(&DefaultFont.Info, 20.0f);
+ r32 FontScale = stbtt_ScaleForPixelHeight(&DefaultFont.Info, 22.0);
v2 Offset = {100.0f, 30.0f};
@@ -1080,6 +1092,16 @@ extern "C" GAME_UPDATE_AND_RENDER(GameUpdateAndRender)
DrawRectangle(Buffer, vMin + -1, vMax + 1, ColorBG);
}
+ // TODO(luca): Placeholder text when text is empty.
+ // Draw the text
+ {
+ DrawText(Buffer, &DefaultFont, FontScale,
+ GameState->TextInputCount, (u8 *)GameState->TextInputText,
+ Offset, ColorFG, true);
+
+ Assert(GameState->TextInputCount <= ArrayCount(GameState->TextInputText));
+ }
+
// Draw cursor
{
v2 vMin = {Offset.X + TextWidth, Offset.Y - Baseline};
@@ -1087,13 +1109,8 @@ extern "C" GAME_UPDATE_AND_RENDER(GameUpdateAndRender)
DrawRectangle(Buffer, vMin, vMax, ColorFG);
}
- // Draw the text
- DrawText(Buffer, &DefaultFont, FontScale,
- GameState->TextInputCount, (u8 *)GameState->TextInputText,
- Offset, ColorFG, true);
-
- Assert(GameState->TextInputCount <= ArrayCount(GameState->TextInputText));
}
+
#endif
}
diff --git a/code/libs/linuxhmh/handmade_platform.h b/code/libs/linuxhmh/handmade_platform.h
deleted file mode 120000
index 204a369..0000000
--- a/code/libs/linuxhmh/handmade_platform.h
+++ /dev/null
@@ -1 +0,0 @@
-/home/void/proj/handmade/linuxhmh/handmade_platform.h \ No newline at end of file
diff --git a/code/libs/linuxhmh/linux_handmade.cpp b/code/libs/linuxhmh/linux_handmade.cpp
deleted file mode 120000
index 6e24079..0000000
--- a/code/libs/linuxhmh/linux_handmade.cpp
+++ /dev/null
@@ -1 +0,0 @@
-/home/void/proj/handmade/linuxhmh/linux_handmade.cpp \ No newline at end of file
diff --git a/code/libs/linuxhmh/linux_handmade.h b/code/libs/linuxhmh/linux_handmade.h
deleted file mode 120000
index f9016b9..0000000
--- a/code/libs/linuxhmh/linux_handmade.h
+++ /dev/null
@@ -1 +0,0 @@
-/home/void/proj/handmade/linuxhmh/linux_handmade.h \ No newline at end of file
diff --git a/code/libs/linuxhmh/linux_profile.h b/code/libs/linuxhmh/linux_profile.h
deleted file mode 120000
index 960481f..0000000
--- a/code/libs/linuxhmh/linux_profile.h
+++ /dev/null
@@ -1 +0,0 @@
-/home/void/proj/handmade/linuxhmh/linux_profile.h \ No newline at end of file
diff --git a/code/libs/linuxhmh/linux_x11_keysym_and_buttons.c b/code/libs/linuxhmh/linux_x11_keysym_and_buttons.c
deleted file mode 120000
index 805eaeb..0000000
--- a/code/libs/linuxhmh/linux_x11_keysym_and_buttons.c
+++ /dev/null
@@ -1 +0,0 @@
-/home/void/proj/handmade/linuxhmh/linux_x11_keysym_and_buttons.c \ No newline at end of file
diff --git a/code/libs/linuxhmh/linux_x11_keysyms_to_strings.c b/code/libs/linuxhmh/linux_x11_keysyms_to_strings.c
deleted file mode 120000
index 1e1dc00..0000000
--- a/code/libs/linuxhmh/linux_x11_keysyms_to_strings.c
+++ /dev/null
@@ -1 +0,0 @@
-/home/void/proj/handmade/linuxhmh/linux_x11_keysyms_to_strings.c \ No newline at end of file
diff --git a/code/libs/linuxhmh/win32_handmade.cpp b/code/libs/linuxhmh/win32_handmade.cpp
deleted file mode 120000
index f8506bd..0000000
--- a/code/libs/linuxhmh/win32_handmade.cpp
+++ /dev/null
@@ -1 +0,0 @@
-/home/void/proj/handmade/linuxhmh/win32_handmade.cpp \ No newline at end of file
diff --git a/code/libs/linuxhmh/win32_handmade.h b/code/libs/linuxhmh/win32_handmade.h
deleted file mode 120000
index 94502d0..0000000
--- a/code/libs/linuxhmh/win32_handmade.h
+++ /dev/null
@@ -1 +0,0 @@
-/home/void/proj/handmade/linuxhmh/win32_handmade.h \ No newline at end of file