-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFoo-Tutorial.cpp
More file actions
65 lines (55 loc) · 1.44 KB
/
Foo-Tutorial.cpp
File metadata and controls
65 lines (55 loc) · 1.44 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
//Alex Seagle 3-28-2019 10:35 A.M. to 10:57 A.M.
//Modified LazyFoo Tutorial01. Outputs a purple window for 5 seconds.
//Modified LazyFoo Tutorial03. Outputs purple window until user quits. 1:37 P.M.
////to 1:58 P.M.
//
//
#include <SDL2/SDL.h>
#include<iostream>
const int SCREEN_W = 640;
const int SCREEN_H = 480;
using namespace std;
enum KeyPressSurfaces{
KEY_PRESS_SURFACE_DEFAULT,
KEY_PRESS_SURFACE_UP,
KEY_PRESS_SURFACE_DOWN,
KEY_PRESS_SURFACE_LEFT,
KEY_PRESS_SURFACE_RIGHT,
KEY_PRESS_SURFACE_TOTAL
};
int main(int argc, char* argv[]){
SDL_Window* window = NULL;
SDL_Surface* screenSurface = NULL;
if(SDL_Init(SDL_INIT_VIDEO) < 0){
cout << "SDL could not initilize. SDL_Error: " << endl;
cout << SDL_GetError() << endl;
}
else{
window = SDL_CreateWindow("SDL Tutorial", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, SCREEN_W, SCREEN_H, SDL_WINDOW_SHOWN);
if(window == NULL){
cout << "Window could not be created. SDL_Error:" << endl;
cout << SDL_GetError() << endl;
}
else{
bool quit = false;
SDL_Event e;
while(!quit){
while(SDL_PollEvent(&e) != 0){
if(e.type == SDL_QUIT){
quit = true;
}
}
screenSurface = SDL_GetWindowSurface(window);
//Purple window
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format,
0xFF, 0x00, 0xFF));
SDL_UpdateWindowSurface(window);
// SDL_Delay(5000);
}
}
}
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}