-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworld.h
57 lines (49 loc) · 1.79 KB
/
world.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
#ifndef WORLD_H
#define WORLD_H
#include "ressources.h"
#define RESULT_FILE "../result/result.txt"
#define NB_LEVELS 3
#define DIRT_SIZE 32
#define TREE_SIZE 96
#define N_WIDTH_DIRT_SPRITE 6
#define N_HEIGHT_DIRT_SPRITE 5
enum GameState {
Menu = -1,
Alive = 0,
Dead = 1,
Win = 2,
Finished = 3,
Quit = 4
};
typedef struct level_s
{
char** level_tab;
int nb_ligne_level_tab;
int nb_col_level_tab;
}level_t;
typedef struct world_s{
int player_spawn_x,player_spawn_y;
char need_player_pos_update;
Uint32 start_level_time,end_level_time;
int* levels_times; /* linked list of all the time for completing each level */
level_t** cur_level; /* pointer to the level pointer (part of the levels array) */
level_t** last_level; /* Level before pause */
char game_state; /* -1 = Menu; 0 = alive; 1 = Dead; 2 = Win; 3 = Quit */
level_t** levels; /* linked list of level pointer */
}world_t;
world_t* init_world();
void world_event(SDL_Event *event,world_t *world , ressources_t* ressources);
void mouse_menu_events(SDL_MouseButtonEvent button,world_t* world, ressources_t* ressources);
void render_sky(SDL_Renderer* renderer, ressources_t* ressources);
void render_worlds(SDL_Renderer* renderer,ressources_t* ressources,world_t* world);
void render_main_menu_text(SDL_Renderer *renderer,ressources_t *ressources);
char get(world_t* world,const int i,const int j);
char is_empty(world_t* world,const int i, const int j);
char get_collision(world_t* world,const int i, const int j);
void spike_collision(world_t* world);
void flag_collision(world_t* world);
void death(SDL_Renderer* renderer, world_t* world,ressources_t* ressources);
void won(SDL_Renderer* renderer,world_t* world,ressources_t* ressources);
void free_levels(world_t* world);
int fin(world_t* world);
#endif