-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.c
97 lines (74 loc) · 1.5 KB
/
core.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
#include"core.h"
#include"player.h"
/*
* SDL Variables
*/
// Window pointer
extern SDL_Window *window;
// Renderer pointer
extern SDL_Renderer *renderer;
// Window screen pointer (this is the screen actually displayed)
extern SDL_Surface *screen;
// Surface used for debug information
SDL_Surface *debugScreen;
// The clear color used on the renderer
SDL_Color clearColor = {0, 0, 0};
// The color used text
SDL_Color textColor = {255, 255, 255};
// The TTF font being used
extern TTF_Font *font;
/*
* System Running Variables
*/
bool running = true;
/*
* Player variables
*/
//The player
Player player;
/*
* World variables
*/
//The world
World world;
void initGame()
{
initSDL();
initWorld();
}
void runGame()
{
player.x = player.y = 100;
player.w = player.h = 12;
player.name = "Mike";
player.moveSpeed = 2.0f;
while(running)
{
//Get Input
if(getInput() == -1)
{
running = false;
}
//Update
//Render
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer);
//SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
renderWorld(renderer, &world);
//Display Debug Information
/*
debugScreen = TTF_RenderText_Solid(font, "This is a test", textColor);
SDL_Texture *temp;
temp = SDL_CreateTextureFromSurface(renderer, debugScreen);
SDL_RenderCopy(renderer, temp, NULL, NULL);
SDL_RenderPresent(renderer);
SDL_DestroyTexture(temp);
*/
}
//SDL_FreeSurface(txtSurface);
closeGame();
}
void closeGame()
{
closeSDL();
}