summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoredGuy <osome3717@gmail.com>2025-07-24 20:37:56 -0700
committerBoredGuy <osome3717@gmail.com>2025-07-24 20:37:56 -0700
commitdc3d98ab47fefc8388455dbbd4d330e81499d95a (patch)
tree39edca664d3aca027181a9aa567d8e81775e8c2a
Initial Commit
-rw-r--r--CMakeLists.txt26
-rw-r--r--include/constants.h7
-rw-r--r--include/game.h39
-rw-r--r--src/game.c38
-rw-r--r--src/main.c21
5 files changed, 131 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..6c10168
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,26 @@
+cmake_minimum_required(VERSION 3.15)
+project(MyBeatemup VERSION 0.0.1 LANGUAGES C)
+
+set(CMAKE_C_STANDARD 11)
+set(CMAKE_C_STANDARD_REQUIRED ON)
+
+find_package(raylib REQUIRED)
+
+add_executable(game
+ "include/game.h"
+ "include/constants.h"
+
+ "src/game.c"
+ "src/main.c"
+)
+
+target_include_directories(game PRIVATE "include")
+target_link_libraries(game raylib)
+
+if (UNIX)
+ target_link_libraries(game m)
+endif()
+
+if (MSVC)
+ target_link_libraries(game winmm)
+endif() \ No newline at end of file
diff --git a/include/constants.h b/include/constants.h
new file mode 100644
index 0000000..2f9625a
--- /dev/null
+++ b/include/constants.h
@@ -0,0 +1,7 @@
+#pragma once
+
+#define WINDOW_WIDTH 1280
+#define WINDOW_HEIGHT 720
+
+#define MAX_ENTITY_COUNT 2048
+#define MAX_AREA_COUNT 4 \ No newline at end of file
diff --git a/include/game.h b/include/game.h
new file mode 100644
index 0000000..9f44f46
--- /dev/null
+++ b/include/game.h
@@ -0,0 +1,39 @@
+#pragma once
+
+#include <raylib.h>
+#include <stdint.h>
+
+#include "constants.h"
+
+#define ENTITY_ALLOCATED 1
+#define ENTITY_VISIBLE (1 << 1)
+#define ENTITY_PHYSICS_ACTIVE (1 << 2)
+
+typedef enum EntityType {
+ Player_Entity
+} EntityType;
+
+typedef struct Entity {
+ int id;
+ EntityType type;
+ uint16_t flags;
+
+ Vector2 position;
+
+ //Physics information
+ Rectangle collider;
+ int numHitBoxes;
+ Rectangle hitBoxes[MAX_AREA_COUNT];
+ int numHurtBoxes;
+ Rectangle hurtBoxes[MAX_AREA_COUNT];
+} Entity;
+
+typedef struct Game {
+ bool paused;
+
+ Entity entities[MAX_ENTITY_COUNT];
+} Game;
+
+void InitGame();
+void UpdateGame(float deltaTime);
+void DrawGame(); \ No newline at end of file
diff --git a/src/game.c b/src/game.c
new file mode 100644
index 0000000..eeabb4d
--- /dev/null
+++ b/src/game.c
@@ -0,0 +1,38 @@
+#include <raylib.h>
+#include <string.h>
+#include "game.h"
+
+Game game;
+
+static inline bool EntityAllocated(const Entity* e) {
+ return (e->flags & ENTITY_ALLOCATED);
+}
+
+void AddEntity(Entity* e) {
+ static int nextId = 0;
+
+ e->id = nextId++;
+ e->flags |= ENTITY_ALLOCATED;
+
+ for(int i = 0; i < MAX_ENTITY_COUNT; i++) {
+ if (!EntityAllocated(&game.entities[i])) {
+ game.entities[i] = *e;
+ }
+ }
+}
+
+void InitGame() {
+ game.paused = false;
+
+ memset(game.entities, 0, sizeof(game.entities));
+}
+
+void UpdateGame(float deltaTime) {
+ (void)deltaTime;
+}
+
+void DrawGame() {
+ BeginDrawing();
+ ClearBackground(RAYWHITE);
+ EndDrawing();
+} \ No newline at end of file
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..f01f61c
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <raylib.h>
+#include "constants.h"
+#include "game.h"
+
+int main() {
+ SetConfigFlags(FLAG_VSYNC_HINT); //Always better than fixed FPS imo
+ InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "My BeatEmup");
+ SetTargetFPS(0);
+
+ InitGame();
+
+ while(!WindowShouldClose()) {
+ UpdateGame(GetFrameTime());
+
+ DrawGame();
+ }
+
+ CloseWindow();
+ return 0;
+} \ No newline at end of file