This commit is contained in:
fatmeat 2025-05-24 16:54:44 +02:00
commit 5007a55cb7
4 changed files with 103 additions and 0 deletions

32
Makefile Normal file
View File

@ -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

12
source/engine.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef ENGINE_H
#define ENGINE_H
#pragma once
#include <raylib.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "entity.h"
#endif

32
source/entity.h Normal file
View File

@ -0,0 +1,32 @@
#ifndef ENTITY_H
# define ENTITY_H
#include <stdint.h>
#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

27
source/main.c Normal file
View File

@ -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);
}