-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.cpp
67 lines (52 loc) · 1.41 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
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 {
//Create Window
window = SDL_CreateWindow( "Learning", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
if (window == NULL ) {
printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
success = false;
} else {
//Get window surface
screenSurface = SDL_GetWindowSurface( window );
//Fill the surface white
SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0xFF, 0xFF ) );
//UPdate the surface
SDL_UpdateWindowSurface( window );
//Wait two seconds
}
}
return success;
}
bool loadMedia()
{
//Loading success flag
bool success = true;
//Load splash image
helloWorld = SDL_LoadBMP( "assets/hello_world.bmp" );
if( helloWorld == NULL ) {
printf( "Unable to load image %s! SDL Error: %s\n", "assets/hello_world.bmp", SDL_GetError() );
success = false;
}
return success;
}
void close()
{
//Deallocate surface
SDL_FreeSurface( helloWorld );
helloWorld = NULL;
//Destroy Window
SDL_DestroyWindow( window );
window = NULL;
//Quite SDL subsystems
SDL_Quit();
}
void game::game() {
screen = Screen();
}