From 3fde0e7edf310245e5658b767840e742c9341597 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 10 Sep 2015 11:30:41 -0400 Subject: yeah --- src/main.cpp | 196 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 98 insertions(+), 98 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index cb93ff4..b04cb59 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,98 +1,98 @@ -#include -#include - -SDL_Window *window = NULL; -SDL_Surface *renderSurface = NULL; -SDL_GLContext mainGLContext = NULL; - -bool gameRunning = true; - -UIClass ui; - -int main(int argc,char **argv){ - //runs start-up procedures - if(!SDL_Init(SDL_INIT_VIDEO)){ - atexit(SDL_Quit); - if(!(IMG_Init(IMG_INIT_PNG|IMG_INIT_JPG)&(IMG_INIT_PNG|IMG_INIT_JPG))){ - std::cout<<"Could not init image libraries!\n"<draw(); - - /************************** - **** CLOSE THE LOOP **** - **************************/ - - glPopMatrix(); //take the matrix(s) off the stack to pass them to the renderer - SDL_GL_SwapWindow(window); //give the stack to SDL to render it - } - - /************************** - **** CLOSE PROGRAM **** - **************************/ - - //closes the window and frees resources - SDL_GL_DeleteContext(mainGLContext); - SDL_DestroyWindow(window); - return 0; -} +#include +#include + +SDL_Window *window = NULL; +SDL_Surface *renderSurface = NULL; +SDL_GLContext mainGLContext = NULL; + +bool gameRunning = true; + +UIClass ui; +Entities *entit1; +Player player; + +int main(int argc,char **argv){ + // Initialize SDL + if(!SDL_Init(SDL_INIT_VIDEO)){ + atexit(SDL_Quit); + }else{ + std::cout << "SDL was not able to initialize! Error: " << SDL_GetError() << std::endl; + return -1; + } + // Initialize SDL_image + if((IMG_Init(IMG_INIT_PNG|IMG_INIT_JPG)&(IMG_INIT_PNG|IMG_INIT_JPG))){ + atexit(IMG_Quit); + }else{ + std::cout<<"Could not init image libraries!\n"<spawn(0,0); + + World *w=new World(2); + + while(gameRunning){ + ui.handleEvents(); // Handle events + //a matrix is a blank canvas for the computer to draw on, the matrices are stored in a "stack" + //GL_PROJECTION has 2 matrices + //GL_MODELVIEW has 32 matrices + glMatrixMode(GL_PROJECTION); //set the matrix mode as projection so we can set the ortho size and the camera settings later on + glPushMatrix(); //push the matrix to the top of the matrix stack + glLoadIdentity(); //replace the entire matrix stack with the updated GL_PROJECTION mode + glOrtho(-1,1,-1,1,-1,1); //set the the size of the screen + glMatrixMode(GL_MODELVIEW); //set the matrix to modelview so we can draw objects + glPushMatrix(); //push the matrix to the top of the matrix stack + glLoadIdentity(); //replace the entire matrix stack with the updated GL_MODELVIEW mode + glPushMatrix(); //basically here we put a blank canvas (new matrix) on the screen to draw on + glClear(GL_COLOR_BUFFER_BIT); //clear the matrix on the top of the stack + + /************************** + **** RENDER STUFF HERE **** + **************************/ + + w->draw(); + glColor3ub(0,0,0); + glRectf(player.loc.x, player.loc.y, player.loc.x + player.width, player.loc.y + player.height); + + /************************** + **** CLOSE THE LOOP **** + **************************/ + + glPopMatrix(); //take the matrix(s) off the stack to pass them to the renderer + SDL_GL_SwapWindow(window); //give the stack to SDL to render it + } + + /************************** + **** CLOSE PROGRAM **** + **************************/ + + //closes the window and frees resources + SDL_GL_DeleteContext(mainGLContext); + SDL_DestroyWindow(window); + return 0; +} -- cgit v1.2.3