GAMEEEEEEEEEE
This commit is contained in:
parent
859e7d7560
commit
e0a42d0262
45 changed files with 2771 additions and 782 deletions
|
|
@ -3,10 +3,16 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
// Forward include raylib (or include it in the .c and keep only forward decls)
|
||||
// Raylib support
|
||||
#include "raylib.h"
|
||||
|
||||
// ODE support
|
||||
#include <ode/ode.h>
|
||||
|
||||
// Logging levels
|
||||
typedef enum suic_log_level {
|
||||
SUIC_LOG_ALL = 0,
|
||||
SUIC_LOG_INFO = 1,
|
||||
|
|
@ -15,11 +21,12 @@ typedef enum suic_log_level {
|
|||
SUIC_LOG_NONE = 4
|
||||
} suic_log_level;
|
||||
|
||||
// Error handling
|
||||
const char *suic_last_error(void);
|
||||
void suic_clear_error(void);
|
||||
|
||||
void suic_set_log_level(suic_log_level level);
|
||||
|
||||
// Vec types
|
||||
typedef struct suic_vec2 {
|
||||
float x, y;
|
||||
} suic_vec2;
|
||||
|
|
@ -28,54 +35,62 @@ typedef struct suic_vec3 {
|
|||
float x, y, z;
|
||||
} suic_vec3;
|
||||
|
||||
// Vector conversion helpers
|
||||
static inline Vector2 suic_to_rl_vec2(suic_vec2 v) {
|
||||
return (Vector2){v.x, v.y};
|
||||
}
|
||||
|
||||
static inline Vector3 suic_to_rl_vec3(suic_vec3 v) {
|
||||
return (Vector3){v.x, v.y, v.z};
|
||||
}
|
||||
|
||||
static inline suic_vec2 suic_from_rl_vec2(Vector2 v) {
|
||||
return (suic_vec2){v.x, v.y};
|
||||
}
|
||||
|
||||
static inline suic_vec3 suic_from_rl_vec3(Vector3 v) {
|
||||
return (suic_vec3){v.x, v.y, v.z};
|
||||
}
|
||||
|
||||
// Must be called before any GPU resources (textures, models) are created.
|
||||
// Window management
|
||||
bool suic_init_window(int width, int height, const char *title);
|
||||
void suic_close_window(void);
|
||||
|
||||
bool suic_window_should_close(void);
|
||||
void suic_set_target_fps(int fps);
|
||||
|
||||
// Frame boundaries (2D)
|
||||
// Drawing (2D)
|
||||
void suic_begin_drawing(void);
|
||||
void suic_end_drawing(void);
|
||||
void suic_clear_background(unsigned char r, unsigned char g, unsigned char b,
|
||||
unsigned char a);
|
||||
void suic_clear_background(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
||||
|
||||
// 3D mode boundaries
|
||||
// 3D Camera
|
||||
typedef struct suic_camera3d {
|
||||
suic_vec3 position;
|
||||
suic_vec3 target;
|
||||
suic_vec3 up;
|
||||
float fovy;
|
||||
int projection; // map to CameraProjection
|
||||
int projection; // CameraProjection
|
||||
} suic_camera3d;
|
||||
|
||||
Camera3D suic_to_rl_camera3d(suic_camera3d cam);
|
||||
|
||||
void suic_begin_mode3d(suic_camera3d cam);
|
||||
void suic_begin_mode3d(float pos_x, float pos_y, float pos_z, float target_x, float target_y, float target_z, float up_x, float up_y, float up_z, float fovy, int projection);
|
||||
void suic_end_mode3d(void);
|
||||
|
||||
// 3D Drawing
|
||||
void suic_draw_cube(float x, float y, float z, float width, float height, float length, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
||||
void suic_draw_cube_wires(float x, float y, float z, float width, float height, float length, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
||||
|
||||
// Input
|
||||
bool suic_is_key_down(int key);
|
||||
bool suic_is_mouse_button_down(int b);
|
||||
suic_vec2 suic_get_mouse_position(void);
|
||||
|
||||
// Images and Textures
|
||||
typedef struct suic_image_handle {
|
||||
Image value;
|
||||
bool valid;
|
||||
} suic_image_handle;
|
||||
|
||||
typedef struct suic_texture_handle {
|
||||
Texture2D value;
|
||||
bool valid;
|
||||
|
|
@ -87,13 +102,12 @@ void suic_image_free(suic_image_handle *img);
|
|||
suic_texture_handle suic_texture_load(const char *path);
|
||||
suic_texture_handle suic_texture_from_image(suic_image_handle img);
|
||||
void suic_texture_free(suic_texture_handle *tex);
|
||||
|
||||
// Drawing a texture (basic)
|
||||
void suic_draw_texture(suic_texture_handle tex, int x, int y, unsigned char r,
|
||||
unsigned char g, unsigned char b, unsigned char a);
|
||||
|
||||
bool suic_audio_init(void); // wraps InitAudioDevice
|
||||
void suic_audio_close(void); // wraps CloseAudioDevice
|
||||
// Audio
|
||||
bool suic_audio_init(void);
|
||||
void suic_audio_close(void);
|
||||
|
||||
typedef struct suic_sound_handle {
|
||||
Sound value;
|
||||
|
|
@ -105,6 +119,7 @@ void suic_sound_play(suic_sound_handle snd);
|
|||
void suic_sound_set_volume(suic_sound_handle snd, float volume);
|
||||
void suic_sound_free(suic_sound_handle *snd);
|
||||
|
||||
// Raycasting
|
||||
typedef struct suic_ray {
|
||||
suic_vec3 origin;
|
||||
suic_vec3 direction;
|
||||
|
|
@ -117,14 +132,102 @@ typedef struct suic_rayhit {
|
|||
suic_vec3 normal;
|
||||
} suic_rayhit;
|
||||
|
||||
// Ray from camera + mouse
|
||||
suic_ray suic_get_mouse_ray(suic_vec2 mouse, suic_camera3d cam);
|
||||
|
||||
// AABB ray test (for chunk culling / picking helpers)
|
||||
typedef struct suic_aabb {
|
||||
suic_vec3 min;
|
||||
suic_vec3 max;
|
||||
} suic_aabb;
|
||||
|
||||
suic_ray suic_get_mouse_ray(suic_vec2 mouse, suic_camera3d cam);
|
||||
suic_rayhit suic_raycast_aabb(suic_ray ray, suic_aabb box);
|
||||
|
||||
// GC-aware allocator (core functionality)
|
||||
void* gc_suic_alloc(size_t size);
|
||||
void suic_gc_free(void* ptr);
|
||||
|
||||
// ODE Physics Engine Support
|
||||
// ODE types (opaque pointers)
|
||||
typedef dWorldID suic_ode_world_id;
|
||||
typedef dSpaceID suic_ode_space_id;
|
||||
typedef dBodyID suic_ode_body_id;
|
||||
typedef dGeomID suic_ode_geom_id;
|
||||
typedef dJointID suic_ode_joint_id;
|
||||
typedef dJointGroupID suic_ode_joint_group_id;
|
||||
|
||||
// Vector types for ODE (matching ODE's dReal which is double)
|
||||
typedef struct suic_ode_vector3 {
|
||||
dReal x, y, z;
|
||||
} suic_ode_vector3;
|
||||
|
||||
typedef struct suic_ode_quaternion {
|
||||
dReal w, x, y, z; // ODE quaternion format: w,x,y,z
|
||||
} suic_ode_quaternion;
|
||||
|
||||
// Basic ODE functions
|
||||
void suic_ode_init(void);
|
||||
void suic_ode_close(void);
|
||||
suic_ode_world_id suic_ode_world_create(void);
|
||||
void suic_ode_world_destroy(suic_ode_world_id world);
|
||||
void suic_ode_world_set_gravity(suic_ode_world_id world, dReal x, dReal y, dReal z);
|
||||
void suic_ode_world_step(suic_ode_world_id world, dReal stepsize);
|
||||
|
||||
// Body management
|
||||
suic_ode_body_id suic_ode_body_create(suic_ode_world_id world);
|
||||
void suic_ode_body_destroy(suic_ode_body_id body);
|
||||
void suic_ode_body_set_position(suic_ode_body_id body, dReal x, dReal y, dReal z);
|
||||
void suic_ode_body_set_linear_vel(suic_ode_body_id body, dReal x, dReal y, dReal z);
|
||||
void suic_ode_body_get_position(suic_ode_body_id body, float *x, float *y, float *z);
|
||||
|
||||
// Mass and geometry
|
||||
void suic_ode_body_set_box_mass(suic_ode_body_id body, dReal density, dReal lx, dReal ly, dReal lz);
|
||||
suic_ode_geom_id suic_ode_create_box_geom(suic_ode_space_id space, dReal lx, dReal ly, dReal lz);
|
||||
suic_ode_geom_id suic_ode_create_plane_geom(suic_ode_space_id space, dReal a, dReal b, dReal c, dReal d);
|
||||
void suic_ode_geom_set_body(suic_ode_geom_id geom, suic_ode_body_id body);
|
||||
void suic_ode_geom_destroy(suic_ode_geom_id geom);
|
||||
|
||||
// Collision space
|
||||
suic_ode_space_id suic_ode_simple_space_create(suic_ode_space_id parent);
|
||||
void suic_ode_space_destroy(suic_ode_space_id space);
|
||||
|
||||
// Collision detection and contact joints
|
||||
void suic_ode_space_collide(suic_ode_world_id world, suic_ode_space_id space, suic_ode_joint_group_id contactgroup);
|
||||
suic_ode_joint_group_id suic_ode_joint_group_create(int max_size);
|
||||
void suic_ode_joint_group_destroy(suic_ode_joint_group_id group);
|
||||
void suic_ode_joint_group_empty(suic_ode_joint_group_id group);
|
||||
|
||||
// Additional body functions
|
||||
void suic_ode_body_get_linear_vel(suic_ode_body_id body, float *x, float *y, float *z);
|
||||
void suic_ode_body_get_rotation(suic_ode_body_id body, float *q_w, float *q_x, float *q_y, float *q_z);
|
||||
void suic_ode_body_set_rotation(suic_ode_body_id body, dReal q_w, dReal q_x, dReal q_y, dReal q_z);
|
||||
|
||||
// Contact properties configuration
|
||||
void suic_ode_set_contact_max_force(dReal force);
|
||||
void suic_ode_set_contact_erp(dReal erp);
|
||||
void suic_ode_set_contact_cfm(dReal cfm);
|
||||
|
||||
// Game object system - unifies physics and rendering
|
||||
typedef struct {
|
||||
suic_ode_body_id body;
|
||||
suic_ode_geom_id geom;
|
||||
float width, height, length; // For box shapes
|
||||
unsigned char r, g, b, a; // Color for rendering
|
||||
int shape_type; // 0=box, 1=sphere, etc.
|
||||
} suic_game_object;
|
||||
|
||||
// Create and manage game objects
|
||||
suic_game_object* suic_game_object_create_box(
|
||||
suic_ode_world_id world,
|
||||
suic_ode_space_id space,
|
||||
float x, float y, float z,
|
||||
float width, float height, float length,
|
||||
float density,
|
||||
unsigned char r, unsigned char g, unsigned char b, unsigned char a
|
||||
);
|
||||
|
||||
void suic_game_object_destroy(suic_game_object* obj);
|
||||
void suic_game_object_set_position(suic_game_object* obj, float x, float y, float z);
|
||||
void suic_game_object_get_position(suic_game_object* obj, float *x, float *y, float *z);
|
||||
void suic_game_object_set_velocity(suic_game_object* obj, float x, float y, float z);
|
||||
void suic_game_object_get_velocity(suic_game_object* obj, float *x, float *y, float *z);
|
||||
void suic_game_object_draw(suic_game_object* obj);
|
||||
|
||||
#endif // LIBSUICMEZ_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue