forked from housq/RiverRaid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
45 lines (36 loc) · 1.06 KB
/
main.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
#define SDL_MAIN_HANDLED
#include "SDL2/SDL.h"
#include "RRApp.h"
#include <cstdlib>
#include <cstdio>
#include <iostream>
enum userEvents{UPDATE_EVENT};
Uint32 PushUpdateEvent(Uint32 interval, void *param) {
SDL_Event event;
event.type = SDL_USEREVENT;
event.user.code = UPDATE_EVENT;
event.user.data1 = 0;
event.user.data2 = 0;
SDL_PushEvent(&event);
return interval;
}
int main()
{
Uint32 width = 800;
Uint32 height = 600;
SDL_Init( SDL_INIT_EVERYTHING );
SDL_Window *g_window = SDL_CreateWindow("River Raid"
, SDL_WINDOWPOS_CENTERED
, SDL_WINDOWPOS_CENTERED
, width
, height
, SDL_WINDOW_SHOWN);
SDL_Renderer * g_renderer = SDL_CreateRenderer(g_window, -1, 0);
SDL_SetRenderDrawColor(g_renderer, 14, 98, 176, 255);
RRApp app(g_window, g_renderer);
int delay = 1000/60; // 1000 milis in a second, divide by 60 - the framerate
SDL_AddTimer(delay, PushUpdateEvent, NULL);
app.mainLoop();
SDL_Quit();
return 0;
}