-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathso_long.h
160 lines (160 loc) · 4.19 KB
/
so_long.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#ifndef SO_LONG_H
#define SO_LONG_H
#include <mlx.h>
#include "./src/libft/libft.h"
//#include "./src/get_next_line/get_next_line.h"
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdbool.h>
#include <errno.h>
#include <pthread.h>
#include <time.h>//Utilizada para la parte bonus, ANIMACIONES.
#include <math.h>//Utilizada para el algoritmo a Star.
#include <X11/Xlib.h>//Utilizada para la gestion del multihilo.
#define BUFFER_SIZE 5000
#define FRAMES_PER_CHANGE 60
#define BPP 64
// Variables globales
extern clock_t lastKeyPressTime;
extern const int MIN_DELAY;
// STRUCTS
typedef struct{
char *map_name;
int lines;
int columns;
int coins;
int exitp;
int startp;
int zeros;
int ones;
int enemies;
char *mapstruct[BUFFER_SIZE];
void *mlx;
void *mlx_win;
void *wall_ptr;
void *wall_sprite_1;
void *wall_sprite_2;
void *floor_ptr;
void *exit_ptr;
void *coin_ptr;
void *coin_sprite_1;
void *coin_sprite_2;
void *coin_sprite_3;
int width;
int height;
int exit_x;
int exit_y;
int moves;
int coins_gained;
int endian;
clock_t env_animation;//parte bonus
int is_w_pressed;
}map;
typedef struct{
void *ptr;
int width;
int height;
void *img;
int x;
int y;
float xT;
float yT;
int moves;
int endian;
int stepanimation;
char value;
int is_wall;
clock_t walktimer;
bool iswalking;
}entity;
typedef struct{
void *zero_ptr;
void *one_ptr;
void *two_ptr;
void *three_ptr;
void *four_ptr;
void *five_ptr;
void *six_ptr;
void *seven_ptr;
void *eight_ptr;
void *nine_ptr;
void *move_ptr;
int width;
int height;
int widthmove;
int heightmove;
}counter;
typedef struct {
map *map;
entity *player;
entity *ditto;
entity *snorlax;
counter *count;
// Agrega aquí todas las variables que necesitas
} in;
typedef struct {
in *tempfw;
entity *tempentity;
int coordx;
int coordy;
} tempcajon;
int ft_printf(const char *fmt, ...);
void ft_putstr_fd(char *s, int fd);
int ft_strncmp(const char *s1, const char *s2, size_t n);
void check_argc(int argc);
int check_file_extension(char *filename, char *extension);
int process_map_file(in *fw);
int line_counter(int fd);
int process_line(int fd, in *fw);
int check_line(char *buffer, int *i, in *fw);
int map_validator(char *buffer, in *fw);
int first_line_analyzer(char *buffer, in *fw);
int body_line_analyzer(char *buffer, in *fw);
void search_entitys(in *fw, char letter, int e, int num);
int last_line_analyzer(char *buffer, in *fw);
int search_items(char item, in *fw);
int path_finder(in *fw);
int dfs(int row, int col, int **visited, in *fw);
int mlx_process(in *fw);
void put_imgs(in *fw);
int key_hook(int keycode, in *fw);
void free_mapstruct(in *fw);
int loop_hook(in *fw);// PROBANDO
void wall_animation(in *fw);
void coin_animation(in *fw);
void check_coins(in *fw);
void draw_image(in *fw, void *img_ptr, int start_x, int start_y);
int check_e(in *fw);
void perror(const char *s);
char *strerror(int errnum);
int get_pixel_color(void *img_ptr, int x, int y);
void handlemove(in *fw, entity *entity, int coordx, int coordy);
int handlekeys(in *fw, char key);
int check_move(in *fw, int coordX, int coordY);
char *getdirectionimage1(entity *entity, int coordx, int coordy);
char *getdirectionimage2(entity *entity, int coordx, int coordy);
float getsumax(int coordx, float lx);
float getsumay(int coordy, float lx);
char *getdirectionstatic(entity *entity, int coordx, int coordy);
int drawcharacter(in *fw, entity *entity, int coordx, int coordy);
void initplayer(in *fw, entity *entity, int coordx, int coordy);
char convertirKeyCodeALetra(int keycode);
int timer(clock_t inicio, double tiempo_deseado);
int hasEnoughTimeElapsed(void);
int moveEnemyTowardsPlayer(in *fw, entity *enemy, entity *player);
char* put_values(char *cadena, entity *entity);
char get_low(char letter);
int getRandomBoolean(void);
void *bucle_asincrono(void* arg);
//prueba
int key_release(int keycode, in *fw);
bool iswall(in *fw, entity *enemy, int posx, int posy);
int is_entity(in *fw, int y, int x, int first_time);
void put_item_to_buffer(in *fw, int *buffer_data, int y, int x);
//int put_counter(in *fw);
int agregarCeros(in *fw);
void draw_counter(in *fw, void *img_ptr, int start_x, int start_y);
void put_number(in *fw, int number, int position);
#endif