-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfundamentals.c
172 lines (144 loc) · 3.96 KB
/
fundamentals.c
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
161
162
163
164
165
166
167
168
169
170
171
172
/*
includes
the header files,
definitions,
global variables and game state varibles declaration,
BITMAP and SOUND variables declaration,
struct variable declaration for cock and bats,
function prototypes,
Allegro's specific function for speed maintenance
*/
#include <allegro.h>
#include <math.h>
#define false 0
#define true 1
#define _left 1
#define _right -1
#define multiplayer 2
#define singleplayer 1
#define game_graphics_mode GFX_AUTODETECT_WINDOWED
#define fullscreen_selected 1
#define resolution_high 1
int left_edge, right_edge;
int server = 0;
int player1_has_served = 0;
int player2_has_served = 0;
int serve_started = 0;
int reached_top;
int serve_turn;
int game_runs_as;
int i;
char name[2][20];
int player1_has_returned_cock = 0;
int player2_has_returned_cock = 0;
int endLine_left;
int endline_right;
/*##### BITMAP VARIABLES ####################*/
SAMPLE *select_sound;
SAMPLE *menu_sound;
SAMPLE *whistle_sound;
SAMPLE *returnL_sound;
SAMPLE *returnR_sound;
BITMAP *buffer;
BITMAP *scoreboard;
BITMAP *court;
BITMAP *bat1;
BITMAP *bat2;
BITMAP *pic_cock;
BITMAP *exit_image;
BITMAP *net;
BITMAP *hand1;
BITMAP *hand1_arm;
BITMAP *menu_buffer;
BITMAP *back;
BITMAP *list;
BITMAP *hand;
BITMAP *cursor;
BITMAP *about;
BITMAP *instruction;
BITMAP *choice;
BITMAP *game_mode;
BITMAP *options_back;
BITMAP *list_start;
BITMAP *list_instructions;
BITMAP *list_gameOptions;
BITMAP *list_aboutGame;
/**************************************/
/*##### STRUCTURES ###################*/
struct Player{
int x;
int y;
int x_while_serving;
int y_while_serving;
int y_predicted;
int power_while_serving;
int angle;
int score;
int power;
} player1, player2;
struct Cock{
int x;
int y;
int move_x;
int move_y;
int angle;
int deflector;
int speed_changer;
int artificial_deviation1;
int artificial_deviation2;
} cock;
/**************************************/
/*##### FUNCTION PROTOTYPES #########*/
/*****/ void welcome_screen();
/*****/ void display_menu();
/*****/ void menu_selectItem();
/*****/ void choose_game();
/*****/ void menu_selectStart();
/*****/ void menu_selectInstructions();
/*****/ void menu_selectGameOptions();
/*****/ void customize_keyboard();
/*****/ void menu_selectAboutGame();
/*****/ void menu_selectExit();
/*****/ int mouseinside();
/*****/ void game_mode_choose();
/*****/ void run_game();
/*****/ void continue_game();
/*****/ void initialize_game();
/*****/ void set_initial_values();
/*****/ void load_images();
/*****/ void draw_court();
/*****/ void draw_buffer();
/*****/ void check_keyboard_entry();
/*****/ void control_bats();
/*****/ void play_menu_sound();
/*****/ void play_select_sound();
/*****/ void play_whistle_sound();
/*****/ void play_player1_return_sound();
/*****/ void play_player2_return_sound();
/*****/ void deinitialize_game();
/*****/ void display_exit_screen();
/*****/ void check_collision();
/*****/ void check_net_cross();
/*****/ int cock_reaches_player1();
/*****/ int cock_reaches_player2();
/*****/ int player1_check_hit();
/*****/ int player2_check_hit();
/*****/ void player1_return_cock();
/*****/ void player2_return_cock();
/*****/ void player1_drop_cock();
/*****/ void player2_drop_cock();
/*****/ void update_cock_position();
/*****/ void draw_bats_and_cock();
/*****/ void draw_speed_meter();
/*****/ void game_over();
/*****/ void serve();
/*****/ void reset();
/*****/ void display_game_status();
/*************************************/
/*##### SPEED LIMITING TECHNIQUE #######*/
volatile long speed_limit = 0;
void speed_limiter(){
speed_limit++;
}
END_OF_FUNCTION(speed_limiter);
/****************************************/