From 5007a55cb79d911c84a0a7952f3a794d2cc0fa45 Mon Sep 17 00:00:00 2001 From: fatmeat Date: Sat, 24 May 2025 16:54:44 +0200 Subject: [PATCH] start --- Makefile | 32 ++++++++++++++++++++++++++++++++ source/engine.h | 12 ++++++++++++ source/entity.h | 32 ++++++++++++++++++++++++++++++++ source/main.c | 27 +++++++++++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 Makefile create mode 100644 source/engine.h create mode 100644 source/entity.h create mode 100644 source/main.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b20db7e --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +NAME := game + +SRC_DIR := source/ +OBJ_DIR := obj/ +BUILD_DIR := build + +SRC := $(wildcard $(SRC_DIR)*.c) +OBJ := $(SRC:$(SRC_DIR)%.c=$(OBJ_DIR)%.o) + +CC := gcc +CFLAG := -ggdb -Wall -Wextra -Werror +LFLAG := -lraylib -lopengl32 -lgdi32 -lwinmm -lpthread + +all: $(NAME) + + +$(OBJ_DIR)%.o: $(SRC_DIR)%.c | build_dir + $(CC) $(CFLAG) -c $< -o $@ + +$(NAME): $(OBJ) + $(CC) $(OBJ) $(LFLAG) -o $(BUILD_DIR)/$(NAME) + +build_dir: + mkdir -p $(BUILD_DIR) + mkdir -p $(OBJ_DIR) + +clean: + rm -rf $(OBJ_DIR) $(BUILD_DIR) + +re : clean all + +.PHONY: all exec lib clean build_dir diff --git a/source/engine.h b/source/engine.h new file mode 100644 index 0000000..861c52a --- /dev/null +++ b/source/engine.h @@ -0,0 +1,12 @@ +#ifndef ENGINE_H +#define ENGINE_H + +#pragma once +#include +#include +#include +#include + +#include "entity.h" + +#endif diff --git a/source/entity.h b/source/entity.h new file mode 100644 index 0000000..a8624d4 --- /dev/null +++ b/source/entity.h @@ -0,0 +1,32 @@ +#ifndef ENTITY_H +# define ENTITY_H + +#include + +#define MAX_ENTITY 64 + +typedef struct { + float x[MAX_ENTITY]; + float y[MAX_ENTITY]; + float z[MAX_ENTITY]; +} pos_array; + +typedef struct { + int current[MAX_ENTITY]; + int max{MAX_ENTITY}; +} health_array; + +typedef struct { + uint32_t alive; + uint32_t type; + uint32_t health_idx; + uint32_t pos_idx; + uint32_t ai_idx; + uint32_t inventory_idx; + uint32_t idx; +} entity_metadata; + +entity_metadata entity_table[MAX_ENTITY]; + + +#endif diff --git a/source/main.c b/source/main.c new file mode 100644 index 0000000..f5c8337 --- /dev/null +++ b/source/main.c @@ -0,0 +1,27 @@ +#include "engine.h" + +struct { + int width; + int height; +} context; + +int main(void) { + context.height = 600; + context.width = 800; + Vector2 position = (Vector2){0, 0}; + + + InitWindow(context.width, context.height, "Game"); + + SetTargetFPS(120); + while (!WindowShouldClose()) { + + BeginDrawing(); + ClearBackground(BLACK); + DrawFPS(10, 10); + EndDrawing(); + } + + CloseWindow(); + return (0); +}