38 lines
1.1 KiB
C
38 lines
1.1 KiB
C
// playerController.h
|
|
#ifndef PLAYER_CONTROLLER_H
|
|
#define PLAYER_CONTROLLER_H
|
|
|
|
#include "raylib.h"
|
|
#include "chunkStructures.h"
|
|
|
|
typedef struct {
|
|
Vector3 mapPosition; // Player's world position (camera position)
|
|
Vector2 playerOrientation; // Yaw (x) and pitch (y), in radians
|
|
Vector3 forward; // Direction vector computed from yaw/pitch
|
|
Vector3 right; // Right vector
|
|
float moveSpeed; // Movement speed
|
|
Camera3D camera;
|
|
} Player;
|
|
|
|
void UpdatePlayer(Player *player);
|
|
|
|
typedef struct {
|
|
bool hit;
|
|
Vector3 position;
|
|
Vector3 normal;
|
|
int blockID;
|
|
float t;
|
|
} RaycastHit;
|
|
|
|
RaycastHit RaycastChunk(const Chunk *chunk, Vector3 origin, Vector3 direction, float maxDistance);
|
|
|
|
RaycastHit GetPlayerRaycastHit(Player *player, Chunk *chunk, float maxDistance);
|
|
|
|
void UpdateFreeCamera(Camera3D *cam, float speed, float *yawOut, float *pitchOut);
|
|
|
|
void DrawFaceHighlight(Vector3 blockPos, Vector3 normal);
|
|
|
|
void HandleBlockInteraction(Player *player, Chunk *chunk, RaycastHit hit, int blockSelection);
|
|
|
|
#endif
|