This repository has been archived by the owner on Jan 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
init.c
82 lines (71 loc) · 1.94 KB
/
init.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
/*
* Ativayeban, initialisation code file
* Copyright (C) 2014 Nebuleon Fumika <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <stdbool.h>
#include <stddef.h>
#include "SDL.h"
#include "SDL_image.h"
#include "main.h"
#include "init.h"
#include "platform.h"
#include "player.h"
#include "title.h"
void Initialize(bool* Continue, bool* Error)
{
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0)
{
*Continue = false; *Error = true;
printf("SDL initialisation failed: %s\n", SDL_GetError());
SDL_ClearError();
return;
}
else
printf("SDL initialisation succeeded\n");
Screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_HWSURFACE |
#ifdef SDL_TRIPLEBUF
SDL_TRIPLEBUF
#else
SDL_DOUBLEBUF
#endif
);
if (Screen == NULL)
{
*Continue = false; *Error = true;
printf("SDL_SetVideoMode failed: %s\n", SDL_GetError());
SDL_ClearError();
return;
}
else
printf("SDL_SetVideoMode succeeded\n");
PlayerSpritesheet = IMG_Load("penguin_ball.png");
if (PlayerSpritesheet == NULL)
{
*Continue = false; *Error = true;
printf("IMG_Load failed: %s\n", SDL_GetError());
SDL_ClearError();
return;
}
SDL_ShowCursor(0);
InitializePlatform();
// Title screen. (-> title.c)
ToTitleScreen();
}
void Finalize()
{
SDL_Quit();
}