-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.cpp
62 lines (41 loc) · 1.11 KB
/
init.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
#include "init.h"
void initSDL(void)
{
int rendererFlags, windowFlags;
rendererFlags = SDL_RENDERER_ACCELERATED;
windowFlags = 0;
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
printf("Couldn't initialize SDL: %s\n", SDL_GetError());
exit(1);
}
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) == -1)
{
printf("Couldn't initialize SDL Mixer\n");
exit(1);
}
Mix_AllocateChannels(MAX_SND_CHANNELS);
app.window = SDL_CreateWindow("Jet Fighter Update 22024531 Phạm Tiến Sơn", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, windowFlags);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
app.renderer = SDL_CreateRenderer(app.window, -1, rendererFlags);
IMG_Init(IMG_INIT_PNG | IMG_INIT_JPG);
SDL_ShowCursor(0);
}
void initGame(void)
{
initBackground();
initStarfield();
initSounds();
initFonts();
initHighscoreTable();
// loadMusic("music/UndertaleMegalovania.mp3");
loadMusic("music/Meteor - Death Race (Round 2) (128 kbps).mp3");
playMusic(1);
}
void cleanup(void)
{
SDL_DestroyRenderer(app.renderer);
SDL_DestroyWindow(app.window);
SDL_Quit();
}