Skip to content

Commit

Permalink
Replaced my gui items (buttons mainly) with raygui buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-oliviero committed May 18, 2021
1 parent 5ed4d9c commit 6947e96
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
21 changes: 8 additions & 13 deletions gameplay.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "lib/raylib/include/raylib.h"
#include "lib/raygui/src/raygui.h"
#include <unistd.h>
#include <stdio.h>
#include "include/main.h"

extern int game_grid[9];
Expand Down Expand Up @@ -53,24 +55,17 @@ int checkwinner()
}

void endGame()
{ // button to continue the game after a match ends
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(RAYWHITE, .5f)); // for obfuscation effect, idk how to use shaders or something
// drawing actual button
{
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(BLACK, .8f)); // for obfuscation effect, idk how to use shaders or something
Rectangle restart_btn = {SCR_WIDTH / 5, SCR_HEIGHT / 3, SCR_WIDTH / 5 * 3, SCR_HEIGHT / 10};
DrawRectangleRounded(restart_btn, .7f, 20, DARKGRAY);
DrawRectangleRoundedLines(restart_btn, .7f, 100, 5, RED);
char restart_text[32] = "Draw...";

// write text in the button, needs some fixes for big nicknames
if (winner == 1)
DrawText(TextFormat("%s (X) won!", user0), MeasureText("(X) won!", 20) + restart_btn.x, SCR_HEIGHT / 2.7f, 20, BLACK); //SCR_WIDTH / 3.3f, SCR_HEIGHT / 2.7f, 20, BLACK);
sprintf(restart_text, "Player 1 (X) WON!");
else if (winner == 2)
DrawText(TextFormat("%s (O) won!", user1), MeasureText("(O) won!", 20) + restart_btn.x, SCR_HEIGHT / 2.7f, 20, BLACK); //SCR_WIDTH / 3.3f, SCR_HEIGHT / 2.7f, 20, BLACK);
else if (winner == 3)
DrawText("Draw...", SCR_WIDTH / 2.45f, SCR_HEIGHT / 2.74f, 30, BLACK);
sprintf(restart_text, "Player 2 (O) WON!");

if (CheckCollisionPointRec(GetMousePosition(), restart_btn) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{
if (GuiToggle(restart_btn, restart_text, ready))
ready = 1;
usleep(150000);
}
}
1 change: 1 addition & 0 deletions gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ void join_window()

void matchInfo()
{ // draw match info
GuiTextAlignment align = 1;
if (turn)
DrawText(TextFormat("It's %s (X) turn!", user0), MeasureText("It's (X) turn!", 20), block * 3 + 10, 20, BLACK);
else
Expand Down

0 comments on commit 6947e96

Please sign in to comment.