Trace Engine
A Raycaster Engine in C
Loading...
Searching...
No Matches
trc_transform.c File Reference
#include "trc_transform.h"
#include "trigonometry.h"
#include "map.h"

Functions

trc_world_position_t get_collision_axis (const trc_transform_t transform, const trc_world_position_t velocity)
 
void move_and_collide (trc_transform_t *transform, const trc_world_position_t velocity)
 
void move_and_slide (trc_transform_t *transform, const trc_world_position_t velocity)
 
void rotate_transform (trc_transform_t *transform, const float rotation_delta)
 

Function Documentation

◆ get_collision_axis()

trc_world_position_t get_collision_axis ( const trc_transform_t  transform,
const trc_world_position_t  velocity 
)

Utility function only visible for transform_t

It returns the given velocity but masked with the current collision status

For example, if a collision for the given transform is happening in the x axis, but not in the y axis, and velocity is (a, b), the returning vale will be (0, b). If no collision is detected, the function will return (a, b), and so on.

◆ move_and_collide()

void move_and_collide ( trc_transform_t transform,
const trc_world_position_t  velocity 
)

Moves the given transform in the specified direction, unless there is a wall within a distance equal to the transform's size

If that occurs, the transform will stop moving entirely

The velocity vector specifies both the direction and the speed of the transform

◆ move_and_slide()

void move_and_slide ( trc_transform_t transform,
const trc_world_position_t  velocity 
)

Moves the given transform in the specified direction, unless there is a wall within a distance equal to the transform's size

If that occurs, the transform will slide across the wall (losing velocity according with the collision angle)

The velocity vector specifies both the direction and the speed of the transform

◆ rotate_transform()

void rotate_transform ( trc_transform_t transform,
const float  rotation_delta 
)

Rotates the transform direction in the given signed angle

Note
The direction is determined by the sign of rotation_velocity, if it's positive then the rotation will be anti-clockwise, if it's negative then it'll be clockwise