Trace Engine
A Raycaster Engine in C
Loading...
Searching...
No Matches
map.h File Reference

Go to the source code of this file.

Data Structures

struct  trc_grid_position_t
 

Macros

#define MAP_CELL_SIZE   64
 
#define FIRST_LEVEL   1 /** Index of the level loaded when the game starts (0 <= index < LEVEL_COUNT) */
 
#define LEVEL_COUNT   2 /** Total number of levels */
 

Enumerations

enum  structures_t {
  UNDEFINED = -1 , AIR , STONE , WOOD ,
  DOOR
}
 

Functions

trc_world_position_t to_world_pos (const trc_grid_position_t grid_pos)
 
trc_grid_position_t to_grid_pos (const trc_world_position_t world_pos)
 
trc_world_position_t map_pos_to_real_pos (const trc_world_position_t map_pos)
 
void change_to_map (const int level_idx)
 
void update_map_wall_at (const trc_grid_position_t position, const structures_t new_wall)
 
structures_t get_map_wall_at (const trc_grid_position_t position)
 
structures_t get_map_floor_at (const trc_grid_position_t position)
 
structures_t get_map_ceiling_at (const trc_grid_position_t position)
 
int get_map_offset_from_id (const int level_idx)
 
trc_world_position_t get_map_size_from_id (const int level_idx)
 
trc_world_position_t get_camera_spwan_from_id (const int level_idx)
 
void draw_map_2D (void)
 

Macro Definition Documentation

◆ FIRST_LEVEL

#define FIRST_LEVEL   1 /** Index of the level loaded when the game starts (0 <= index < LEVEL_COUNT) */

◆ LEVEL_COUNT

#define LEVEL_COUNT   2 /** Total number of levels */

◆ MAP_CELL_SIZE

#define MAP_CELL_SIZE   64

Size of the squares that forms the map, usually is good to have it (aprox) 3 times the player collision size

Enumeration Type Documentation

◆ structures_t

Structures that can form the map

Enumerator
UNDEFINED 
AIR 

This structure is for error managing

STONE 

Nothing, the squares where the entities can move

WOOD 
DOOR 

Function Documentation

◆ change_to_map()

void change_to_map ( const int  level_idx)

Updates the current map info to the map of the level_idx level

◆ draw_map_2D()

void draw_map_2D ( void  )

Draw in the screen a 2D matrix of squares, white being wall and blakc being floor

◆ get_camera_spwan_from_id()

trc_world_position_t get_camera_spwan_from_id ( const int  level_idx)

Returns the player spawn point of the level_idx level, in the form of a trc_world_position_t

Parameters
level_idxThe index of the level to get (from 0 to LEVEL_COUNT)

◆ get_map_ceiling_at()

structures_t get_map_ceiling_at ( const trc_grid_position_t  position)

Returnss the ceiling structure of the current map at the given position

◆ get_map_floor_at()

structures_t get_map_floor_at ( const trc_grid_position_t  position)

Returnss the floor structure of the current map at the given position

◆ get_map_offset_from_id()

int get_map_offset_from_id ( const int  level_idx)

Returns the level offset for the maps list, to get the map of that level

Parameters
level_idxThe index of the level to get (from 0 to LEVEL_COUNT)

◆ get_map_size_from_id()

trc_world_position_t get_map_size_from_id ( const int  level_idx)

Returns the map size of the level_idx level, in the form of a trc_world_position_t, where x and y are the dimensions

Parameters
level_idxThe index of the level to get (from 0 to LEVEL_COUNT)

◆ get_map_wall_at()

structures_t get_map_wall_at ( const trc_grid_position_t  position)

Returns the wall structure of the current map at the given position

◆ map_pos_to_real_pos()

trc_world_position_t map_pos_to_real_pos ( const trc_world_position_t  map_pos)

Returns the windows position for the middle of the map square

◆ to_grid_pos()

trc_grid_position_t to_grid_pos ( const trc_world_position_t  world_pos)

Given a trc_grid_position_t (with floats) returns the corresponding cell position in the current map

◆ to_world_pos()

trc_world_position_t to_world_pos ( const trc_grid_position_t  grid_pos)

Given a position in a grid (with integers) returns the trc_grid_position_t with the values pointing to the same cell in the map (in the center of the cell, to be precise)

◆ update_map_wall_at()

void update_map_wall_at ( const trc_grid_position_t  position,
const structures_t  new_wall 
)

Replaces the wall structure of the current map at the given position with the given new_wall