-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.h
More file actions
115 lines (75 loc) · 1.79 KB
/
Copy pathmain.h
File metadata and controls
115 lines (75 loc) · 1.79 KB
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
#ifndef sdl2_testing_main_h
#define sdl2_testing_main_h
#include "SDL.h"
#include "SDL_ttf.h"
#include "SDL_image.h"
#include <stdbool.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <stdlib.h>
#define PLAYER_MOVEMENT_SPEED 7
#define SCREEN_WIDTH 480
#define SCREEN_HEIGHT 640
#define ENEMY_HEIGHT 48
#define ENEMY_WIDTH 48
#define PLAYER_HEIGHT 48
#define PLAYER_WIDTH 48
typedef struct Bullet{
float x;
float y;
float dx;
float dy;
float angle;
struct Bullet* next;
struct Bullet* prev;
}Bullet;
typedef struct Player{
float x;
float y;
float firing;
float reloading;
float x_aim;
float y_aim;
float bullet_angle;
float moving;
float face_left;
float face_right;
float alive;
int animFrame;
struct Player* enemy_next;
struct Player* enemy_prev;
}Player;
typedef struct{
SDL_Renderer *renderer;
SDL_Window *window;
float left;
float right;
float up;
float down;
float fire;
int time;
Bullet* start_bullet;
Bullet* end_bullet;
Bullet* start_bullet_enemy;
Bullet* end_bullet_enemy;
SDL_Texture *texture_player[12];
SDL_Texture *texture_enemy[5];
SDL_Texture *background;
SDL_Texture *bullet_texture;
Player* start_enemy;
Player* end_enemy;
int x;
int y;
SDL_Rect camera;
} Application;
// Prototypes
int random_int(int min, int max);
void initSDL(Application *app);
void prepareScene(Application *app);
void presentScene(Application *app);
SDL_Texture *loadTexture(Application *app,char* fileName);
void deleteBullets(Bullet *bullet_1st, Bullet *bullet_2nd, Bullet **bullet_last);
void fireBullet(Application *app, Player *player);
void fireBulletEnemy(Application *app, Player *enemy);
#endif