Trace Engine
A Raycaster Engine in C
Loading...
Searching...
No Matches
raycaster.c File Reference
#include "raycaster.h"
#include <stdlib.h>
#include <math.h>
#include <pthread.h>
#include "log.h"
#include "graphics.h"
#include "game_state.h"
#include "trigonometry.h"
#include "render.h"
#include "trc_camera.h"
#include "map.h"

Macros

#define NUM_THREADS   4
 
#define RATIO_ANGLE_RAYS   (get_ammount_of_rays() / (float) FOV) /** Relation between AMMOUNT_OF_RAYS and FOV, for making the right steps between every ray */
 
#define RAY_COLOR   (rgb_t) {80, 80, 80} /** Color of the rays represented as a line */
 

Functions

int get_ammount_of_rays (void)
 
void cast_rays_from_to (int start, int end)
 
void * multithreading_casting (void *arg)
 
void cast_rays (void)
 
void init_raycaster (void)
 
void quit_raycaster (void)
 

Variables

ray_trays
 
pthread_t threads [NUM_THREADS]
 
int threads_ids [NUM_THREADS]
 

Macro Definition Documentation

◆ NUM_THREADS

#define NUM_THREADS   4

◆ RATIO_ANGLE_RAYS

#define RATIO_ANGLE_RAYS   (get_ammount_of_rays() / (float) FOV) /** Relation between AMMOUNT_OF_RAYS and FOV, for making the right steps between every ray */

◆ RAY_COLOR

#define RAY_COLOR   (rgb_t) {80, 80, 80} /** Color of the rays represented as a line */

Function Documentation

◆ cast_rays()

void cast_rays ( void  )

Cast the 2D top-down vision rays for the player and calls the 3D render

◆ cast_rays_from_to()

void cast_rays_from_to ( int  start,
int  end 
)

◆ get_ammount_of_rays()

int get_ammount_of_rays ( void  )

Returns the current ammount of rays for current FOV and resolution

◆ init_raycaster()

void init_raycaster ( void  )

Initialize the raycaster

Note
Don't forget to use quit_raycaster after

◆ multithreading_casting()

void * multithreading_casting ( void *  arg)

◆ quit_raycaster()

void quit_raycaster ( void  )

Safely delete and disable the raycaster

Variable Documentation

◆ rays

ray_t* rays

◆ threads

pthread_t threads[NUM_THREADS]

◆ threads_ids

int threads_ids[NUM_THREADS]