player rotates and moves, rays for raycasting on map
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
# include <unistd.h> // for sleep()
|
||||
# include <stdlib.h> // for atoi()
|
||||
# include <stdio.h> // for printf()
|
||||
# include <math.h> // for M_PI, cos(), sin()
|
||||
|
||||
# include "colors.h"
|
||||
# include "memorybook.h"
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
# define CUBE3D_MACRO_H
|
||||
|
||||
# define MAX_NB_KEY 3
|
||||
# define SCREEN_DIST 50
|
||||
# define SCREEN_SIZE 100
|
||||
# define SCREEN_DEF 50
|
||||
|
||||
# define ARROW_LEFT 65361
|
||||
# define ARROW_UP 65362
|
||||
|
||||
@@ -32,24 +32,42 @@ int keyrelease(int keycode, t_game *game);
|
||||
// key_do_action.c
|
||||
void keypress_do_action(t_game *game);
|
||||
// key_is_action_1.c
|
||||
int is_esc(int *k_hook);
|
||||
int is_go_left(int *k_hook);
|
||||
int is_go_right(int *k_hook);
|
||||
int is_go_forward(int *k_hook);
|
||||
int is_go_backward(int *k_hook);
|
||||
int is_esc(int *k_hook, int *is_action);
|
||||
int is_go_left(int *k_hook, int *is_action);
|
||||
int is_go_right(int *k_hook, int *is_action);
|
||||
int is_go_forward(int *k_hook, int *is_action);
|
||||
int is_go_backward(int *k_hook, int *is_action);
|
||||
// key_is_action_2.c
|
||||
int is_turn_left(int *k_hook, int *is_action);
|
||||
int is_turn_right(int *k_hook, int *is_action);
|
||||
|
||||
|
||||
// -------------------------------
|
||||
// SRC/DRAW
|
||||
// SRC/PLAYER
|
||||
// -------------------------------
|
||||
// draw.c
|
||||
void draw(t_game *game);
|
||||
// player_moves.c
|
||||
void plr_posx_decrement(t_game *game);
|
||||
void plr_posy_decrement(t_game *game);
|
||||
void plr_posx_increment(t_game *game);
|
||||
void plr_posy_increment(t_game *game);
|
||||
// player_rotates.c
|
||||
void plr_turn_right(t_game *game);
|
||||
void plr_turn_left(t_game *game);
|
||||
// player_limits.c
|
||||
void plr_limits(t_game *game, int x, int y);
|
||||
int plr_out_limits(t_game *game, int x, int y);
|
||||
int is_wall(t_game *game, int cell_x, int cell_y);
|
||||
|
||||
// -------------------------------
|
||||
// SRC/DRAW
|
||||
// -------------------------------
|
||||
// draw.c
|
||||
void draw_pixel(t_game *game, int x, int y, int color);
|
||||
void rotate(t_game *game, int *x, int *y);
|
||||
void rotate_double(t_game *game, double *x, double *y);
|
||||
void draw_line(t_game *game, int start_x, int start_y, int end_x, int end_y, int color);
|
||||
void draw(t_game *game);
|
||||
// draw_window.c
|
||||
void draw_rays(t_game *game);
|
||||
void draw_map(t_game *game);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
#ifndef CUBE3D_STRUCT_H
|
||||
# define CUBE3D_STRUCT_H
|
||||
|
||||
typedef struct s_vec
|
||||
{
|
||||
int start_x;
|
||||
int start_y;
|
||||
int end_x;
|
||||
int end_y;
|
||||
} t_vec;
|
||||
|
||||
typedef struct s_game
|
||||
{
|
||||
// window
|
||||
@@ -8,7 +16,27 @@ typedef struct s_game
|
||||
void *win_ptr;
|
||||
int win_size_x;
|
||||
int win_size_y;
|
||||
// rays
|
||||
t_vec screen_dist;
|
||||
t_vec screen_size;
|
||||
t_vec ray;
|
||||
// tmp
|
||||
int ray_highlight;
|
||||
int ray_activ;
|
||||
// map
|
||||
int map_size_x;
|
||||
int map_size_y;
|
||||
char **map;
|
||||
int cell;
|
||||
// rot
|
||||
int rot;
|
||||
double cosi;
|
||||
double cosj;
|
||||
double sini;
|
||||
double sinj;
|
||||
// player
|
||||
double plr_exact_x;
|
||||
double plr_exact_y;
|
||||
int plr_x;
|
||||
int plr_y;
|
||||
// key hook
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
#ifndef MEMORYBOOK_H
|
||||
# define MEMORYBOOK_H
|
||||
|
||||
typedef void(*t_mb_func_exit)(void*);
|
||||
|
||||
typedef struct s_exit
|
||||
{
|
||||
t_mb_func_exit f;
|
||||
void *param;
|
||||
} t_exit;
|
||||
|
||||
void mb_init(void(*f)(void*), void *param);
|
||||
void *mb_alloc(size_t size);
|
||||
void mb_add(void *addr);
|
||||
|
||||
Reference in New Issue
Block a user