1010#include < iostream>
1111#include < utility>
1212
13+ #include " GameBoard.h"
14+ #include " UserInput.h"
15+ #include " Player.h"
16+ #include " Renderer.h"
17+
1318void initGame () {
1419
1520}
@@ -33,43 +38,6 @@ int updateViewport(int width, int height) {
3338 glMatrixMode (GL_MODELVIEW);
3439}
3540
36- bool handleMouseButtonEvent (const SDL_MouseButtonEvent& event) {
37-
38- return true ;
39- }
40-
41- bool handleKeyboardEvent (const SDL_KeyboardEvent& event) {
42-
43- return true ;
44- }
45-
46- bool handleQuitEvent (const SDL_QuitEvent& event) {
47- return false ;
48- }
49-
50- // Returns true if the program should continue running, false if it should exit
51- bool handleEvent (const SDL_Event& event) {
52- switch (event.type ) {
53- case SDL_MOUSEBUTTONDOWN:
54- case SDL_MOUSEBUTTONUP:
55- return handleMouseButtonEvent (event.button );
56- case SDL_KEYUP:
57- case SDL_KEYDOWN:
58- return handleKeyboardEvent (event.key );
59- case SDL_QUIT:
60- return handleQuitEvent (event.quit );
61- }
62- return true ;
63- }
64-
65- void render (SDL_Window* displayWindow) {
66- glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
67-
68- glFlush ();
69- SDL_GL_SwapWindow (displayWindow);
70- }
71-
72-
7341int main (int argc, char *argv[]) {
7442 SDL_Init (SDL_INIT_VIDEO);
7543 SDL_Window* displayWindow;
@@ -86,18 +54,23 @@ int main(int argc, char *argv[]) {
8654
8755 SDL_GLContext glContext = SDL_GL_CreateContext (displayWindow);
8856
89- initGame ();
9057 initOpenGL ();
9158
92- updateViewport (800 , 600 );
59+ updateViewport (1024 , 768 );
60+
61+ Player testPlayer;
62+ GameBoard testBoard;
9363
9464 bool running = true ;
9565 while (running) {
9666 SDL_Event event;
9767 while (SDL_PollEvent (&event)) {
98- running = handleEvent ( event);
68+ running = acceptInput (testBoard, testPlayer, event);
9969 }
100- render (displayWindow);
70+
71+
72+
73+ SDL_GL_SwapWindow (displayWindow);
10174 SDL_Delay (100 );
10275 }
10376
0 commit comments