-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.cpp
149 lines (132 loc) · 18 KB
/
Game.cpp
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
#include "Game.h"
//The window we'll be rendering to
SDL_Window* gWindow = NULL;
//The window renderer
SDL_Renderer* gRenderer = NULL;
TTF_Font* gFont = NULL;
//Scene textures
WTexture gPlayer1Texture;
WTexture gPlayer2Texture;
WTexture gBackgroundTexture;
WTexture gRoadTexture;
WTexture gProfTexture;
WTexture gBuildingTexture;
WTexture gGrassTexture;
WTexture gTask1;
WTexture gTask2;
//Locations
std::pair<int, int> locPoints[7] = {{708, 428}, {408,516}, {252,420}, {84,660}, {540,552}, {396,648}, {348,312}};
std::string tasks[7] = {"Collect CMP Notes from Scoops", "Buy ORS from Apollo", "Get your cycle repaired", "Get milk from mother dairy", "Play in the Sports Ground", "Visit the Research Park", "Eat at Satpura Night Mess"};
//Map
int map[70][100] = {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
bool init(){
//Initialization flag
bool success = true;
//Initialize SDL
if( SDL_Init( SDL_INIT_VIDEO ) < 0 ){
printf( "SDL could not initialize! SDL Error: %s\n", SDL_GetError() );
success = false;
}
else{
//Set texture filtering to linear
if( !SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1" ) ){
printf( "Warning: Linear texture filtering not enabled!" );
}
//Create window
gWindow = SDL_CreateWindow( "2PlayerMazeGame", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
if( gWindow == NULL ){
printf( "Window could not be created! SDL Error: %s\n", SDL_GetError() );
success = false;
}
else{
//Create vsynced renderer for window
gRenderer = SDL_CreateRenderer( gWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC );
if( gRenderer == NULL ){
printf( "Renderer could not be created! SDL Error: %s\n", SDL_GetError() );
success = false;
}
else{
//Initialize renderer color
SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
//Initialize PNG loading
int imgFlags = IMG_INIT_PNG;
if( !( IMG_Init( imgFlags ) & imgFlags ) ){
printf( "SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError() );
success = false;
}
//Initialize SDL_ttf
if( TTF_Init() == -1 ){
printf( "SDL_ttf could not initialize! SDL_ttf Error: %s\n", TTF_GetError() );
success = false;
}
else{
gFont = TTF_OpenFont("Resources/Vera.ttf", 24);
if (gFont == NULL) {
fprintf(stderr, "error: font not found\n");
exit(EXIT_FAILURE);
}
}
}
}
}
return success;
}
bool loadMedia(){
//Loading success flag
bool success = true;
if( !gPlayer1Texture.loadFromFile(gRenderer, "Resources/minion2.png" ) ){
printf( "Failed to load dot texture!\n" );
success = false;
}
if( !gPlayer2Texture.loadFromFile(gRenderer, "Resources/minion.png" ) ){
printf( "Failed to load dot texture!\n" );
success = false;
}
if( !gBackgroundTexture.loadFromFile(gRenderer, "Resources/backg.png" ) ){
printf( "Failed to load background texture image!\n" );
success = false;
}
if( !gRoadTexture.loadFromFile(gRenderer, "Resources/smallroad.png" ) ){
printf( "Failed to load tile texture image!\n" );
success = false;
}
if(!gProfTexture.loadFromFile(gRenderer, "Resources/professor.png")){
printf("Failed to load guard texture image!\n");
success = false;
}
if( !gBuildingTexture.loadFromFile(gRenderer, "Resources/build.png" ) ){
printf( "Failed to load tile texture image!\n" );
success = false;
}
if( !gGrassTexture.loadFromFile(gRenderer, "Resources/smallgrass.png" ) ){
printf( "Failed to load tile texture image!\n" );
success = false;
}
if( !gTask1.loadFromFile(gRenderer, "Resources/point.bmp" ) ){
printf( "Failed to load tile texture image!\n" );
success = false;
}if( !gTask2.loadFromFile(gRenderer, "Resources/point.bmp" ) ){
printf( "Failed to load tile texture image!\n" );
success = false;
}
return success;
}
void close(){
//Free loaded images
gPlayer1Texture.free();
gPlayer2Texture.free();
gBackgroundTexture.free();
gRoadTexture.free();
gProfTexture.free();
gBuildingTexture.free();
gGrassTexture.free();
//Destroy window
SDL_DestroyRenderer( gRenderer );
SDL_DestroyWindow( gWindow );
gWindow = NULL;
gRenderer = NULL;
//Quit SDL subsystems
IMG_Quit();
SDL_Quit();
}