diff options
| author | Devyn Challman <devyn@challman.org> | 2026-03-27 11:59:34 -0700 |
|---|---|---|
| committer | Devyn Challman <devyn@challman.org> | 2026-03-27 11:59:34 -0700 |
| commit | a0f8dc499b60bb326a8765bf435c4a4344df0b20 (patch) | |
| tree | d84c22704dc7c46de472da96d42bb0e46ef52b06 | |
| parent | 458fc3d29e3baa7b69c3fbf82dc1470bd4fe9d36 (diff) | |
add basic raylib client
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Makefile | 7 | ||||
| -rw-r--r-- | client/main.c | 58 |
3 files changed, 63 insertions, 4 deletions
@@ -3,3 +3,5 @@ a.out *~ build/ bin/ +.* +compile_commands.json @@ -6,11 +6,12 @@ SERVER_TARGET = bin/server SERVER_SRC = $(shell find server -name "*.c") SERVER_OBJ = $(SERVER_SRC:server/%.c=$(SERVER_BUILD)/%.o) - CLIENT_BUILD = build/client CLIENT_TARGET = bin/client CLIENT_SRC = $(shell find client -name "*.c") CLIENT_OBJ = $(CLIENT_SRC:client/%.c=$(CLIENT_BUILD)/%.o) +CLIENT_CFLAGS = $(CFLAGS) $(shell pkg-config --cflags raylib) +CLIENT_LDFLAGS = $(shell pkg-config --libs raylib) all: $(SERVER_TARGET) $(CLIENT_TARGET) @@ -25,7 +26,7 @@ $(SERVER_TARGET): $(SERVER_OBJ) $(CLIENT_TARGET): $(CLIENT_OBJ) mkdir -p bin - $(CC) $(CFLAGS) $(CLIENT_OBJ) -o $(CLIENT_TARGET) + $(CC) $(CLIENT_CFLAGS) $(CLIENT_OBJ) $(CLIENT_LDFLAGS) -o $(CLIENT_TARGET) $(SERVER_BUILD)/%.o: server/%.c mkdir -p $(dir $@) @@ -33,7 +34,7 @@ $(SERVER_BUILD)/%.o: server/%.c $(CLIENT_BUILD)/%.o: client/%.c mkdir -p $(dir $@) - $(CC) $(CFLAGS) -c $< -o $@ + $(CC) $(CLIENT_CFLAGS) -c $< -o $@ clean: rm -rf build bin diff --git a/client/main.c b/client/main.c index 237c8ce..a38f470 100644 --- a/client/main.c +++ b/client/main.c @@ -1 +1,57 @@ -int main() {} +#include "raylib.h" +#include <stdio.h> + +int main() { + const int screenWidth = 800; + const int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "Pants - MMO"); + + SetTargetFPS(60); + + char* message = "Welcome to Pants a game by Matthew & Devyn Challman"; + int fontSize = 25; + + int messageWidth = MeasureText(message, fontSize); + int messagePosX = (screenWidth - messageWidth) / 2; + int messagePosY = (screenHeight - fontSize) / 2; + + int buttonW = 150; + int buttonH = 50; + int buttonPosX = (screenWidth - buttonW) / 2; + int buttonPosY = (screenHeight - buttonH) / 2 + 100; + + char *connect = "Connect"; + int connectWidth = MeasureText(connect, fontSize); + int connectPosX = (screenWidth - connectWidth) / 2; + int connectPosY = (screenHeight - fontSize) / 2 + 100; + + while (!WindowShouldClose()) { + + bool connecting = false; + if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) { + struct Vector2 mousePos = GetMousePosition(); + + if (mousePos.x >= buttonPosX && mousePos.x <= buttonPosX + buttonW && + mousePos.y >= buttonPosY && mousePos.y <= buttonPosY + buttonH) { + + connecting = true; + } + } + + BeginDrawing(); + ClearBackground(RAYWHITE); + DrawText(message, messagePosX, messagePosY, fontSize, LIGHTGRAY); + DrawRectangle(buttonPosX, buttonPosY, buttonW, buttonH, GREEN); + + if(connecting) + DrawText(connect, connectPosX, connectPosY, fontSize, RED); + else + DrawText(connect, connectPosX, connectPosY, fontSize, BLUE); + + DrawFPS(0,0); + EndDrawing(); + } + + return 0; +} |