-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
118 lines (92 loc) · 1.75 KB
/
main.cpp
File metadata and controls
118 lines (92 loc) · 1.75 KB
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
#include "main.h"
bool ENDGAME=false;
Timer delta;
extern Player player;
/*
//The attributes of the screen
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
const int SCREEN_BPP = 32;
//The surfaces that will be used
SDL_Surface *message = NULL;
SDL_Surface *background = NULL;
SDL_Surface *screen = NULL;
SDL_PixelFormat *fmt;
SDL_Surface *load_image( std::string filename )
{
//Temporary storage for the image that's loaded
SDL_Surface* loadedImage = NULL;
//The optimized image that will be used
SDL_Surface* optimizedImage = NULL;
//Load the image
loadedImage = SDL_LoadBMP( filename.c_str() );
//If nothing went wrong in loading the image
if( loadedImage != NULL )
{
//Create an optimized image
optimizedImage = SDL_ConvertSurface(loadedImage,fmt,0);
//Free the old image
SDL_FreeSurface( loadedImage );
}
//Return the optimized image
return optimizedImage;
}
*/
/*
class Tile
{
private:
int x;
int y;
bool solid;
public:
Tile();
bool is_solid();
};
Tile::Tile()
{
x = 0;
y = 0;
solid = false;
}
bool Tile::is_solid()
{
return solid;
}
*/
void CallUpdate()
{
ProcessInput(player);
ApplyPhysics(player, delta.get_ticks());
SetCamera(player);
//Restart delta timer
delta.start();
}
void CallDraw()
{
GraphicsUpdate();
}
int main( int argc, char* argv[] )
{
// Initialize SDL.
if (SDL_Init(SDL_INIT_VIDEO) < 0)
return 1;
GraphicsSetup();
LoadLevel();
player.set_pos(50,50);
player.set_direction(true);
// start delta timer
// used to change velocity of objects according to time (not fps)
delta.start();
// main loop
while (!ENDGAME)
{
CallUpdate();
CallDraw();
}
// clean up
GraphicsExit();
// close SDL
SDL_Quit();
return 0;
}