feat(game_core): 重构游戏引擎并添加新功能

- 重构了游戏引擎的核心逻辑和架构
- 添加了新的实体组件系统(ECS)
- 实现了简单的碰撞检测和响应
- 新增了地图和子弹功能
- 优化了输入处理和渲染逻辑
- 调整了游戏控制方式
This commit is contained in:
ZZY
2025-07-02 12:14:57 +08:00
parent 89bede93a9
commit b5b2c90e75
32 changed files with 856 additions and 441 deletions

View File

@@ -1,10 +1,10 @@
#ifndef __GE_ENTIRY_H__
#define __GE_ENTIRY_H__
#include <ge_core.h>
#include <utils/ge_vector2i.h>
#include "ge_render_component.h"
#include "ge_physics_component.h"
#include "ge_collision_component.h"
#include <stdint.h>
typedef uint16_t ge_ecs_id_t; // 支持65536个实体
@@ -15,8 +15,8 @@ typedef enum {
GE_COMPONENT_POSITION = 1 << 1,
GE_COMPONENT_TRANSFORM = 1 << 2, // TODO not implimented
GE_COMPONENT_RENDERABLE = 1 << 3,
GE_COMPONENT_PHYSICS_BODY = 1 << 4, // TODO not implimented
GE_COMPONENT_COLLIDER = 1 << 5, // TODO not implimented
GE_COMPONENT_PHYSICS_BODY = 1 << 4,
GE_COMPONENT_COLLIDER = 1 << 5,
GE_COMPONENT_TIMED_LIFE = 1 << 6, // TODO not implimented
} ge_ecs_mask_t;
@@ -24,13 +24,17 @@ typedef enum {
(GE_COMPONENT_POSITION | GE_COMPONENT_RENDERABLE)
#define GE_PHYSICS_MASK \
(GE_COMPONENT_POSITION | GE_COMPONENT_PHYSICS_BODY)
#define GE_COLLIDER_MASK \
(GE_COMPONENT_POSITION | GE_COMPONENT_COLLIDER)
typedef struct ge_entity {
int user_type;
ge_ecs_id_t id;
ge_ecs_mask_t component_mask;
ge_vector2i_t position;
ge_render_component_t renderable;
ge_physics_component_t physics_body;
ge_collision_component_t collision;
} ge_entity_t;
typedef struct {
@@ -43,7 +47,6 @@ typedef struct ge_ecs {
ge_ecs_storage_t storage;
} ge_ecs_t;
static inline ge_ecs_id_t ge_ecs_add_entity(ge_ecs_t* ecs, ge_entity_t** entity) {
ge_ecs_id_t id = ++ecs->storage.count;
if (id >= GE_ECS_MAX) {