#include // Useful structures typedef struct { int x; int y; } ScreenPoint; typedef struct { float x; float y; } Vector; // Map-related functions and defines #define POINT_OUT_MAP -1 extern uint16_t* nRC_loadBMP(char *path); extern int nRC_getTile(int *map, ScreenPoint point, ScreenPoint mapDimensions); extern int getTileFront(Vector pos, Vector dir, float speed, int *map, ScreenPoint mapDim); extern int getTileBehind(Vector pos, Vector dir, float speed, int *map, ScreenPoint mapDim); // Various macros #define abs(x) (x < 0 ? -x : x) #define map(x, in_min, in_max, out_min, out_max) ((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min) #define nRC_248mul(a,b) ((a*b) >> 8) #define nRC_248div(a,b) ((a << 8) / b) #define DEG2RAD(x) ((float)(x) * M_PI / 180) #define RAD2DEG(x) ((float)(x) * 180 / M_PI) // Edit them to fit your textures, which must be squares #define TEXTUREW 64 #define TEXTUREH TEXTUREW #define R5G6B5(r,g,b) ((r << 11) | (g << 5) | b) extern void nRC_setPixel(ScreenPoint pixel, int color, char* buffer); #define nRC_drawHorizontalLine(origin, end, constant, color, buffer) nRC_drawLineShared(origin, end, constant, color, buffer, 0) #define nRC_drawVerticalLine(origin, end, constant, color, buffer) nRC_drawLineShared(origin, end, constant, color, buffer, 1) void nRC_drawLineShared(int origin, int end, int constant, int color, char *buffer, int side); extern void nRC_drawLine(ScreenPoint pt1, ScreenPoint pt2, int color, char *buffer); extern void nRC_fillTriangle(ScreenPoint pt1, ScreenPoint pt2, ScreenPoint pt3, int color, char *buffer); extern inline void nRC_clearBuf(char *buffer, int w); extern inline void nRC_dispBuf(char *buffer); extern void nRC_rayCasting(int *map, Vector player, ScreenPoint mapDimensions, Vector dir, Vector planeVec, uint16_t *textures, char *buffer); extern void nRC_moveForward(Vector *pos, Vector *dir, Vector *plane, float speed, int *map, ScreenPoint mapDim); extern void nRC_moveBackward(Vector *pos, Vector *dir, Vector *plane, float speed, int *map, ScreenPoint mapDim); extern void nRC_lookLeft(Vector *dir, Vector *plane, float speed); extern void nRC_lookRight(Vector *dir, Vector *plane, float speed);