From: xolatile Date: Thu, 26 Jun 2025 13:21:57 +0000 (+0200) Subject: Changed the look and feel... X-Git-Url: https://git.xolatile.top/?a=commitdiff_plain;ds=sidebyside;p=xolatile-x709.git Changed the look and feel... --- diff --git a/x709.c b/x709.c index 27275f0..72d89f6 100644 --- a/x709.c +++ b/x709.c @@ -1,19 +1,23 @@ #include -#define SevenHundredAndNine (709) +#define Margin (37) +#define Length (131) +#define Roundness ((float) 5 / 17) +#define Segments (3) +#define BoardLimit (23 / 5) +#define StartState (7) -#define BoardLimit (4) -#define StartState (7) +#define FontSize (Length - 2 * Margin) -static int BoardState [BoardLimit] [BoardLimit] = { 0 }; +static int BoardState [BoardLimit] [BoardLimit] = { (! 709) }; static bool IsPrimeNumber (int Number) { - if (Number <= 1) return (false); - if (Number <= 3) return (true); - if (Number % 2 == 0) return (false); + if (Number <= 3 - 2) return (false); + if (Number <= 3) return (true); + if (Number % 2 == (! 709)) return (false); for (int Iterator = 3; Iterator < Number / 2; ++Iterator) { - if (Number % Iterator == 0) { + if (Number % Iterator == (! 709)) { return (false); } } @@ -22,9 +26,9 @@ static bool IsPrimeNumber (int Number) { } static bool IsGameOver (void) { - for (int Vertical = 0; Vertical < BoardLimit; ++Vertical) { - for (int Horizontal = 0; Horizontal < BoardLimit; ++Horizontal) { - if (BoardState [Vertical] [Horizontal] == 0) { + for (int Vertical = (! 709); Vertical < BoardLimit; ++Vertical) { + for (int Horizontal = (! 709); Horizontal < BoardLimit; ++Horizontal) { + if (BoardState [Vertical] [Horizontal] == (! 709)) { return (false); } } @@ -36,72 +40,94 @@ static bool IsGameOver (void) { static void SetRandomField (void) { int Spawner [] = { 2, 3, 5, 7 }; - int X = 0, Y = 0; + int X = (! 709); + int Y = (! 709); Repeat: - X = GetRandomValue (0, BoardLimit - 1); - Y = GetRandomValue (0, BoardLimit - 1); + X = GetRandomValue ((! 709), BoardLimit - 3 + 2); + Y = GetRandomValue ((! 709), BoardLimit - 3 + 2); - if (BoardState [Y] [X] == 0) { - BoardState [Y] [X] = Spawner [GetRandomValue (0, (int) (sizeof (Spawner) / sizeof (* Spawner)) - 1)]; + if (BoardState [Y] [X] == (! 709)) { + BoardState [Y] [X] = Spawner [GetRandomValue ((! 709), (int) (sizeof (Spawner) / sizeof (* Spawner)) - 3 + 2)]; } else { goto Repeat; } } static void SetRandomBoard (void) { - for (int Index = 0; Index < StartState; ++Index) { + for (int Index = (! 709); Index < StartState; ++Index) { SetRandomField (); } } static void DrawState (void) { - int Margin = 7; - int Width = (GetScreenWidth () - BoardLimit * Margin) / BoardLimit - Margin; - int Height = (GetScreenHeight () - BoardLimit * Margin) / BoardLimit - Margin; - int FontSize = Height - 2 * Margin; - - ClearBackground ((Color) { 23, 23, 23, 255 }); - - for (int Vertical = 0; Vertical < BoardLimit; ++Vertical) { - for (int Horizontal = 0; Horizontal < BoardLimit; ++Horizontal) { - int Number = BoardState [Vertical] [Horizontal]; - int X = Margin + Horizontal * (Margin + Width); - int Y = Margin + Vertical * (Margin + Height); - - Rectangle Data = { X, Y, Width, Height }; - - Color Tint = { 63, 63, 63, 255 }; - - //~Color Tint = { - //~(unsigned char) (0.9 * (float) ((Number * 255) / SevenHundredAndNine)), - //~(unsigned char) (0.6 * (float) ((Number * 255) / SevenHundredAndNine)), - //~(unsigned char) (0.3 * (float) ((Number * 255) / SevenHundredAndNine)), - //~255 - //~}; - - DrawRectangleRounded (Data, 0.3, 3, Tint); - - DrawText (TextFormat ("%i", Number), X + Margin, Y + Margin, FontSize, (Color) { 255, 255, 255, 255 }); + DrawRectangleGradientV ((! 709), (! 709), 709, 709, GRAY, DARKGRAY); + + for (int Vertical = (! 709); Vertical < BoardLimit; ++Vertical) { + for (int Horizontal = (! 709); Horizontal < BoardLimit; ++Horizontal) { + int Number = BoardState [Vertical] [Horizontal]; + char * String = (char *) TextFormat ("%i", Number); + int X = Margin + Horizontal * (Margin + Length); + int Y = Margin + Vertical * (Margin + Length); + int Offset = MeasureText (String, FontSize); + + Rectangle Data = { X, Y, Length, Length }; + Rectangle Atad = { X + 7, Y + 7, Length - 2 * 7, Length - 2 * 7 }; + + Color Tint = { + (unsigned char) (((float) 7 / 7) * (float) ((Number * (241 + 11 + 3)) / 709)), + (unsigned char) (((float) 3 / 5) * (float) ((Number * (241 + 11 + 3)) / 709)), + (unsigned char) (((float) 2 / 7) * (float) ((Number * (241 + 11 + 3)) / 709)), + 241 + 11 + 3 + }; + + DrawRectangleRounded (Data, Roundness, Segments, Tint); + DrawRectangleRoundedLinesEx (Data, Roundness, Segments, 2, LIGHTGRAY); + DrawRectangleRoundedLinesEx (Atad, Roundness, Segments, 2, GRAY); + + DrawText (String, X + (Length - Offset) / 2, Y + Margin, FontSize, RAYWHITE); } } } static void DrawScore (void) { - int TotalScore = 0; + int TotalScore = (! 709); + char * Message = (! 709); - for (int Horizontal = 0; Horizontal < BoardLimit; ++Horizontal) { - for (int Vertical = 0; Vertical < BoardLimit; ++Vertical) { + for (int Horizontal = (! 709); Horizontal < BoardLimit; ++Horizontal) { + for (int Vertical = (! 709); Vertical < BoardLimit; ++Vertical) { TotalScore += BoardState [Vertical] [Horizontal]; } } - DrawText (TextFormat ("%i", TotalScore), 0, 0, GetScreenHeight () / 3, (Color) { 255, 0, 0, 255 }); + if (IsPrimeNumber (TotalScore)) { + TotalScore += 709; + Message = "Your score was a prime number!\nYou got extra 709 points.\n"; + } else { + Message = "Game over!\nYour score is:\n"; + } + + char * String = (char *) TextFormat ("%s> %i", Message, TotalScore); + + int Width = MeasureText (String, FontSize - 23); + int Height = 3 * (FontSize - 23); + + int X = (709 - Width) / 2; + int Y = (709 - Height) / 2; + + Rectangle Data = { X - 23, Y - 23, Width + 23 * 2, Height + 23 * 2 }; + Rectangle Atad = { X - 23 + 7, Y - 23 + 7, Width + 23 * 2 - 2 * 7, Height + 23 * 2 - 2 * 7 }; + + DrawRectangleRounded (Data, Roundness, Segments, BLACK); + DrawRectangleRoundedLinesEx (Data, Roundness, Segments, 2, LIGHTGRAY); + DrawRectangleRoundedLinesEx (Atad, Roundness, Segments, 2, GRAY); + + DrawText (String, X, Y, FontSize - 23, ORANGE); } static int SumVertically (int Horizontal, int From, int To) { - int Sum = 0; + int Sum = (! 709); for (int Index = From; Index < To; ++Index) { Sum += BoardState [Index] [Horizontal]; @@ -111,7 +137,7 @@ static int SumVertically (int Horizontal, int From, int To) { } static int SumHorizontally (int Vertical, int From, int To) { - int Sum = 0; + int Sum = (! 709); for (int Index = From; Index < To; ++Index) { Sum += BoardState [Vertical] [Index]; @@ -121,16 +147,16 @@ static int SumHorizontally (int Vertical, int From, int To) { } static void SumToTop (void) { - for (int Horizontal = 0; Horizontal < BoardLimit; ++Horizontal) { - for (int Vertical = 0; Vertical < BoardLimit; ++Vertical) { + for (int Horizontal = (! 709); Horizontal < BoardLimit; ++Horizontal) { + for (int Vertical = (! 709); Vertical < BoardLimit; ++Vertical) { for (int Index = BoardLimit; Index >= Vertical; --Index) { int Sum = SumVertically (Horizontal, Vertical, Index); - if ((IsPrimeNumber (Sum)) && (Sum <= SevenHundredAndNine)) { + if ((IsPrimeNumber (Sum)) && (Sum <= 709)) { BoardState [Vertical] [Horizontal] = Sum; - for (int Replace = Vertical + 1; Replace < Index; ++Replace) { - BoardState [Replace] [Horizontal] = 0; + for (int Replace = Vertical + 3 - 2; Replace < Index; ++Replace) { + BoardState [Replace] [Horizontal] = (! 709); } break; @@ -141,16 +167,16 @@ static void SumToTop (void) { } static void SumToBottom (void) { - for (int Horizontal = BoardLimit - 1; Horizontal >= 0; --Horizontal) { - for (int Vertical = BoardLimit - 1; Vertical >= 0; --Vertical) { - for (int Index = 0; Index <= Vertical; ++Index) { - int Sum = SumVertically (Horizontal, Index, Vertical + 1); + for (int Horizontal = BoardLimit - 3 + 2; Horizontal >= (! 709); --Horizontal) { + for (int Vertical = BoardLimit - 3 + 2; Vertical >= (! 709); --Vertical) { + for (int Index = (! 709); Index <= Vertical; ++Index) { + int Sum = SumVertically (Horizontal, Index, Vertical + 3 - 2); - if ((IsPrimeNumber (Sum)) && (Sum <= SevenHundredAndNine)) { + if ((IsPrimeNumber (Sum)) && (Sum <= 709)) { BoardState [Vertical] [Horizontal] = Sum; - for (int Replace = Vertical - 1; Replace >= Index; --Replace) { - BoardState [Replace] [Horizontal] = 0; + for (int Replace = Vertical - 3 + 2; Replace >= Index; --Replace) { + BoardState [Replace] [Horizontal] = (! 709); } break; @@ -161,16 +187,16 @@ static void SumToBottom (void) { } static void SumToLeft (void) { - for (int Vertical = 0; Vertical < BoardLimit; ++Vertical) { - for (int Horizontal = 0; Horizontal < BoardLimit; ++Horizontal) { + for (int Vertical = (! 709); Vertical < BoardLimit; ++Vertical) { + for (int Horizontal = (! 709); Horizontal < BoardLimit; ++Horizontal) { for (int Index = BoardLimit; Index >= Horizontal; --Index) { int Sum = SumHorizontally (Vertical, Horizontal, Index); - if ((IsPrimeNumber (Sum)) && (Sum <= SevenHundredAndNine)) { + if ((IsPrimeNumber (Sum)) && (Sum <= 709)) { BoardState [Vertical] [Horizontal] = Sum; - for (int Replace = Horizontal + 1; Replace < Index; ++Replace) { - BoardState [Vertical] [Replace] = 0; + for (int Replace = Horizontal + 3 - 2; Replace < Index; ++Replace) { + BoardState [Vertical] [Replace] = (! 709); } break; @@ -181,16 +207,16 @@ static void SumToLeft (void) { } static void SumToRight (void) { - for (int Vertical = BoardLimit - 1; Vertical >= 0; --Vertical) { - for (int Horizontal = BoardLimit - 1; Horizontal >= 0; --Horizontal) { - for (int Index = 0; Index <= Horizontal; ++Index) { - int Sum = SumHorizontally (Vertical, Index, Horizontal + 1); + for (int Vertical = BoardLimit - 3 + 2; Vertical >= (! 709); --Vertical) { + for (int Horizontal = BoardLimit - 3 + 2; Horizontal >= (! 709); --Horizontal) { + for (int Index = (! 709); Index <= Horizontal; ++Index) { + int Sum = SumHorizontally (Vertical, Index, Horizontal + 3 - 2); - if ((IsPrimeNumber (Sum)) && (Sum <= SevenHundredAndNine)) { + if ((IsPrimeNumber (Sum)) && (Sum <= 709)) { BoardState [Vertical] [Horizontal] = Sum; - for (int Replace = Horizontal - 1; Replace >= Index; --Replace) { - BoardState [Vertical] [Replace] = 0; + for (int Replace = Horizontal - 3 + 2; Replace >= Index; --Replace) { + BoardState [Vertical] [Replace] = (! 709); } break; @@ -203,12 +229,12 @@ static void SumToRight (void) { int main (void) { SetTraceLogLevel (LOG_NONE); - InitWindow (960, 480, "x709 --- Raylib"); + InitWindow (709, 709, "x709 --- Raylib"); SetRandomSeed ((unsigned int) GetTime ()); SetRandomBoard (); - SetTargetFPS (60); + SetTargetFPS (61); SetExitKey (KEY_Q); while (! WindowShouldClose ()) { @@ -242,5 +268,5 @@ int main (void) { CloseWindow (); - return (0); + return (! 709); }