Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //==========main.cpp===========
- #define GL_GLEXT_PROTOTYPES
- #define GLEW_STATIC
- #include <iostream>
- #include <algorithm>
- #include <math.h>
- #include <stdlib.h>
- #include <time.h>
- #include <string>
- #include <vector>
- #include <fstream>
- #include <sstream>
- #include "SDL.h"
- #include "SDL_image.h"
- //#include <GL/glext.h>
- #include "SDL_opengl.h"
- #include "globals.h"
- #include "Object.h"
- #include "Interface.h"
- #include "AI.h"
- #include <typeinfo>
- #include "Eval.h"
- bool A_UP, A_DOWN, A_LEFT, A_RIGHT, A_ATTACK, A_JUMP, A_DEFEND, A_SPECIAL; //key presses
- SDL_Event event;
- bool RUNNING = true;
- std::string OBJECTSTOLOAD= "";
- int PLAYER1CONTROLS[]= {82, 81, 80, 79, 6, 27, 29, 25};
- int PLAYER2CONTROLS[]= {12, 14, 13, 15, 8, 26, 20, 21};
- bool PAUSE=false;
- bool FULL_SCREEN=false;
- char* CAPT = "A-Engine";
- struct comp_by_zpos
- {
- //bool operator() (const objcopy * lhs, const objcopy * rhs) { return lhs->posz < rhs->posz; }
- bool operator() (const objcopy * lhs, const objcopy * rhs)
- {
- if (lhs->rndrbackid!=4321 && rhs->rndrbackid!=4321)
- {
- if (lhs->deleteobj)
- return true;
- else if (rhs->deleteobj)
- return false;
- if (lhs->rndrngpriority!=rhs->rndrngpriority)
- {
- return lhs->rndrngpriority > rhs->rndrngpriority;
- }
- else
- {
- return lhs->posz <= rhs->posz;
- }
- }
- if (lhs->rndrbackid!=4321) return false;
- if (rhs->rndrbackid!=4321) return true;
- if (lhs->deleteobj&&rhs->deleteobj) return false;
- if (lhs->deleteobj) return false;
- if (rhs->deleteobj) return true;
- if (lhs->rndrngpriority!=rhs->rndrngpriority)
- {
- return lhs->rndrngpriority > rhs->rndrngpriority;
- }
- else
- {
- return lhs->posz <= rhs->posz;
- }
- }
- };
- int Menus(SDL_Window * MainSurf, LOAD * LOADED);
- /*struct comp_by_zpos{
- bool operator() (const int lhs[2], const int rhs[2]) { return lhs[1] < rhs[1]; }
- };*/
- int main(int argc,char* args[])
- {
- SDL_Init( SDL_INIT_EVERYTHING );
- A_UP=false;
- A_DOWN=false;
- A_LEFT=false;
- A_RIGHT=false;
- A_ATTACK=false;
- A_JUMP=false;
- A_DEFEND=false;
- A_SPECIAL=false;
- SDL_Window *MainSurf = SDL_CreateWindow(CAPT, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SFWIDTH, SFHEIGHT, SDL_WINDOW_OPENGL);
- //ini OPENGL
- SDL_GL_CreateContext(MainSurf);
- glMatrixMode( GL_PROJECTION);
- glLoadIdentity();
- glClearColor( 0.f, 0.f, 0.f, 1.f);
- glEnable( GL_TEXTURE_2D );
- glViewport(0, 0, SFWIDTH, SFHEIGHT);
- glOrtho(0.0f, SFWIDTH, SFHEIGHT, 0.0f, -1.0f, 1.0f);
- glMatrixMode( GL_MODELVIEW );
- glLoadIdentity();
- glEnable( GL_BLEND );
- glDisable( GL_DEPTH_TEST );
- glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
- LoadTxt Load_Txt(LOADTXTDIR);
- //SDL_SetWindowFullscreen(MainSurf, (255, 255, 255)); //fullscreen
- LOAD LOADED;
- LOADED.initHeavy(LOADTXTDIR);
- Menus(MainSurf, &LOADED);
- LOADED.LoadObjsForGame(Load_Txt, OBJECTSTOLOAD, 0, &LOADED);
- LOADED.LoadSettigns_OnScreenObjs();
- AI_Stuff AI;
- //glMatrixMode(GL_PROJECTION);
- //glLoadIdentity();
- //glOrtho( 0, SFWIDTH * 2, SFHEIGHT * 2, 0.0, 1.0, -1.0 );
- /*for (int x=0; x<LOADED.OBJID_INDEX; x++){
- LOADED.OBJECTS[LOADED.IDS[x]].LOADED=&LOADED;
- }*/
- for (int x=1000; x<1011; x++)
- {
- LOADED.OBJECTS[x].LOADED=&LOADED;
- }
- const Uint8 *keystates = SDL_GetKeyboardState(NULL);
- int countahframe = SDL_GetTicks();
- bool PAUSE=false, PAUSENOW=false, SKIPFRAME=false;
- while (RUNNING == true)
- {
- /*if (!PAUSENOW || (PAUSENOW&&SKIPFRAME)){ //RENDER BEHIND THE BG
- if (LOADED.OBJSBEHIND_INDEX>0){
- for (int a=0; a <= SFHEIGHT; a++){
- for (int b=0; b<LOADED.OBJSBEHIND_INDEX;b++){
- if (LOADED.OBJSBEHIND[b]!=4321){
- if ( LOADED.ON_SCREEN_OBJS[LOADED.OBJSBEHIND[b]]->posz == a && LOADED.ON_SCREEN_OBJS[LOADED.OBJSBEHIND[b]]->deleteobj==false)
- }
- }
- }
- }
- }*/
- if (!PAUSENOW || (PAUSENOW&&SKIPFRAME))
- {
- for (int b=LOADED.OBJID_INDEX-LOADED.OBJSBEHIND_INDEX; b<LOADED.OBJID_INDEX; b++)
- {
- if (LOADED.ON_SCREEN_OBJS[b]->deleteobj==false)
- {
- LOADED.OBJECTS[LOADED.ON_SCREEN_OBJS[b]->id].Blit(LOADED.ON_SCREEN_OBJS[b]);
- }
- }
- }
- if(!PAUSENOW || (PAUSENOW&&SKIPFRAME)) LOADED.BACKGROUNDS[LOADED.CURRBG].Blit(&LOADED);
- for (int object_copy_indx=0; object_copy_indx < LOADED.ON_SCREEN_OBJCOUNT; object_copy_indx++)
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].index=object_copy_indx;
- switch(LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].playerno)
- {
- case 1:
- A_RIGHT = keystates[ SDL_SCANCODE_RIGHT ];
- A_LEFT = keystates[ SDL_SCANCODE_LEFT ];
- A_UP = keystates[ SDL_SCANCODE_UP ];
- A_DOWN = keystates[ SDL_SCANCODE_DOWN ];
- A_ATTACK = keystates[ SDL_SCANCODE_C ];
- A_DEFEND = keystates[ SDL_SCANCODE_X ];
- A_JUMP = keystates[ SDL_SCANCODE_Z ];
- A_SPECIAL = keystates[ SDL_SCANCODE_V ];
- break;
- case 2:
- A_RIGHT = keystates[ SDL_SCANCODE_L ];
- A_LEFT = keystates[ SDL_SCANCODE_J ];
- A_UP = keystates[ SDL_SCANCODE_I ];
- A_DOWN = keystates[ SDL_SCANCODE_K ];
- A_ATTACK = keystates[ SDL_SCANCODE_E ];
- A_DEFEND = keystates[ SDL_SCANCODE_W ];
- A_JUMP = keystates[ SDL_SCANCODE_Q ];
- A_SPECIAL = keystates[ SDL_SCANCODE_R ];
- break;
- default:
- A_RIGHT = false;
- A_LEFT = false;
- A_UP = false;
- A_DOWN = false;
- A_ATTACK = false;
- A_DEFEND = false;
- A_JUMP = false;
- A_SPECIAL = false;
- break;
- }
- if (!LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].iscom)
- {
- if (A_UP)
- {
- if (LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_UP_C) LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_UP_C=false;
- if (LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].Tu)
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_UP_C=true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].Tu=false;
- }
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_UP= true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_DOWN= false;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].DASHL=0;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].DASHR=0;
- }
- else
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].Tu=true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_UP= false;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_UP_C=false;
- }
- if (A_DOWN)
- {
- if (LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_DOWN_C) LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_DOWN_C=false;
- if (LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].Td)
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_DOWN_C=true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].Td=false;
- }
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_DOWN= true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_UP=false;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].DASHL=0;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].DASHR=0;
- }
- else
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].Td=true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_DOWN= false;
- }
- if (A_LEFT)
- {
- if (LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_LEFT_C) LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_LEFT_C=false;
- if (LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].Tl)
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_LEFT_C=true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].Tl=false;
- }
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_LEFT= true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_RIGHT=false;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].DshClksIntrvlL=SDL_GetTicks();
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].DshClksIntrvlR=0;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].DASHR=0;
- }
- else if (!A_LEFT && LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_LEFT)
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].Tl=true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_LEFT= false;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_LEFT_C=false;
- if (!LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_LEFT)
- if (SDL_GetTicks()-LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].DshClksIntrvlL<110)
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].DASHL=1;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].DASHR=0;
- }
- }
- if (A_RIGHT)
- {
- if (LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_RIGHT_C) LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_RIGHT_C=false;
- if (LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].Tr)
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_RIGHT_C=true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].Tr=false;
- }
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_RIGHT=true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_LEFT=false;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].DshClksIntrvlR=SDL_GetTicks();
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].DshClksIntrvlL=0;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].DASHL=0;
- }
- else if (!A_RIGHT && LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_RIGHT)
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].Tr=true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_RIGHT=false;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_RIGHT_C=false;
- if(!LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_RIGHT)
- if (SDL_GetTicks()-LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].DshClksIntrvlR<110)
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].DASHR=1;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].DASHL=0;
- }
- }
- if (A_ATTACK)
- {
- if (LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_ATTACK_C) LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_ATTACK_C=false;
- if (LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].TA)
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_ATTACK_C=true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].TA=false;
- }
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_ATTACK=true;
- }
- else
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].TA=true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_ATTACK=false;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_ATTACK_C=false;
- }
- if (A_DEFEND)
- {
- if (LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_DEFEND_C) LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_DEFEND_C=false;
- if (LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].TD)
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_DEFEND_C=true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].TD=false;
- }
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_DEFEND=true;
- }
- else
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].TD=true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_DEFEND=false;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_DEFEND_C=false;
- }
- if (A_JUMP)
- {
- if (LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_JUMP_C) LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_JUMP_C=false;
- if (LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].TJ)
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_JUMP_C=true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].TJ=false;
- }
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_JUMP=true;
- }
- else
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].TJ=true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_JUMP=false;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_JUMP_C=false;
- }
- if (A_SPECIAL)
- {
- if (LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_SPECIAL_C) LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_SPECIAL_C=false;
- if (LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].TS)
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_SPECIAL_C=true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].TS=false;
- }
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_SPECIAL=true;
- }
- else
- {
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].TS=true;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_SPECIAL=false;
- LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].P_SPECIAL_C=false;
- }
- }
- if (LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].iscom)
- {
- if (AI._current_target==4321)
- {
- AI.setTarget(LOADED.ON_SCREEN_OBJS[object_copy_indx], &LOADED);
- }
- AI.playAI(&LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx], &LOADED);
- }
- if( SDL_PollEvent(&event))
- {
- if (event.type == SDL_QUIT || keystates[ SDL_SCANCODE_ESCAPE ])
- {
- RUNNING = false;
- }
- }
- LOADED.ON_SCREEN_OBJS[object_copy_indx]=&LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx];
- }
- if (!PAUSENOW || (PAUSENOW&&SKIPFRAME))
- {
- for (int object_copy_indx=0; object_copy_indx<LOADED.ON_SCREEN_OBJCOUNT; object_copy_indx++) //UPDATING THE STATES AND BLITTING THE SHADOWN
- {
- if (!LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].deleteobj)
- {
- LOADED.OBJECTS[LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].id].UpdateStat(&LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx]);
- }
- }
- for (int object_copy_indx=0; object_copy_indx<LOADED.ON_SCREEN_OBJCOUNT; object_copy_indx++) //CHECKING FOR COLLISIONS
- {
- if (!LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].deleteobj)
- {
- LOADED.OBJECTS[LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].id].CheckCollision(&LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx]);
- }
- }
- for (int object_copy_indx=0; object_copy_indx<LOADED.ON_SCREEN_OBJCOUNT; object_copy_indx++) //UPDATING THE MOVEMENTS AND VELCOCITIES
- {
- if (!LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].deleteobj)
- {
- LOADED.OBJECTS[LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].id].UpdateMove(&LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx]);
- LOADED.OBJECTS[LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx].id].BlitShadow(&LOADED.ON_SCREEN_REAL_OBJS[object_copy_indx]);
- }
- }
- }
- if (!SKIPFRAME)
- if ( (SDL_GetTicks()-countahframe) < (1000/LOADED.FPS) )
- {
- SDL_Delay((1000/LOADED.FPS) - (SDL_GetTicks()-countahframe));
- SDL_SetWindowTitle(MainSurf, (stringify(1000/(SDL_GetTicks()-countahframe)).c_str()));
- }
- else
- {
- SDL_SetWindowTitle(MainSurf, (stringify(1000/(SDL_GetTicks()-countahframe)).c_str()));
- }
- countahframe = SDL_GetTicks();
- for (int crsid=0; crsid <100; crsid++)
- {
- if (LOADED.CATCHINGIDS[crsid][6]>0 &&LOADED.CATCHINGIDS[crsid][6]!=4321 )
- {
- LOADED.CATCHINGIDS[crsid][6]=LOADED.CATCHINGIDS[crsid][6]==4321?4321:LOADED.CATCHINGIDS[crsid][6]-1;
- }
- }
- for (int a=LOADED.ON_SCREEN_OBJCOUNT-1; a >=0; a--)
- {
- if (LOADED.ON_SCREEN_REAL_OBJS[a].deleteobj && LOADED.ON_SCREEN_REAL_OBJS[a].deleted==false)
- {
- if (LOADED.ON_SCREEN_REAL_OBJS[a].rndrbackid!=4321)
- LOADED.OBJSBEHIND_INDEX--;
- LOADED.DELETED_OBJS[LOADED.D_O_INDEX++]=a;
- LOADED.ON_SCREEN_REAL_OBJS[a].deleted=true;
- }
- }
- std::sort((LOADED.ON_SCREEN_OBJS).begin(), (LOADED.ON_SCREEN_OBJS).begin()+(LOADED.ON_SCREEN_OBJCOUNT), comp_by_zpos());
- if (!PAUSENOW || (PAUSENOW&&SKIPFRAME))
- {
- for (int b=0; b<LOADED.ON_SCREEN_OBJCOUNT; b++)
- {
- if (LOADED.ON_SCREEN_OBJS[b]->deleteobj==false && LOADED.ON_SCREEN_OBJS[b]->rndrbackid==4321)
- {
- LOADED.OBJECTS[LOADED.ON_SCREEN_OBJS[b]->id].Blit(LOADED.ON_SCREEN_OBJS[b]);
- }
- }
- }
- SKIPFRAME=false;
- if (keystates[ SDL_SCANCODE_F1 ])
- {
- PAUSE=PAUSE==PAUSENOW?!PAUSE:PAUSE;
- Sleep(200);
- }
- if (keystates[ SDL_SCANCODE_F2 ])
- {
- SKIPFRAME=true;
- Sleep(200);
- }
- if (keystates[ SDL_SCANCODE_F3 ])
- {
- if (FULL_SCREEN)
- SDL_SetWindowFullscreen(MainSurf, (255, 255, 255));
- else
- SDL_SetWindowFullscreen(MainSurf, (255, 255, 255)); //fullscreen
- FULL_SCREEN=!FULL_SCREEN;
- }
- SDL_GL_SwapWindow(MainSurf);
- std::cout <<"Number Of Objects: "<< LOADED.ON_SCREEN_OBJCOUNT<<std::endl;
- PAUSENOW=PAUSE;
- }
- SDL_Quit();
- return 0;
- }
- int Menus(SDL_Window *MainSurf, LOAD * LOADED)
- {
- LoadMenuStuff Interface( LOADED );
- const Uint8 *keystates = SDL_GetKeyboardState(NULL);
- int countahframe = SDL_GetTicks();
- for (int a=0; a<4; a++)
- {
- for (int b=0; b<8; b++)
- {
- LOADED->PKEYS[a][b]=false;
- }
- }
- while (true)
- {
- LOADED->PKEYS[0][0] = keystates[ SDL_SCANCODE_UP ];
- LOADED->PKEYS[0][1] = keystates[ SDL_SCANCODE_DOWN ];
- LOADED->PKEYS[0][2] = keystates[ SDL_SCANCODE_LEFT ];
- LOADED->PKEYS[0][3] = keystates[ SDL_SCANCODE_RIGHT ];
- LOADED->PKEYS[0][4] = keystates[ SDL_SCANCODE_C ];
- LOADED->PKEYS[0][5] = keystates[ SDL_SCANCODE_X ];
- LOADED->PKEYS[0][6] = keystates[ SDL_SCANCODE_Z ];
- LOADED->PKEYS[0][7] = keystates[ SDL_SCANCODE_V ];
- LOADED->PKEYS[1][0] = keystates[ SDL_SCANCODE_I ];
- LOADED->PKEYS[1][1] = keystates[ SDL_SCANCODE_K ];
- LOADED->PKEYS[1][2] = keystates[ SDL_SCANCODE_J ];
- LOADED->PKEYS[1][3] = keystates[ SDL_SCANCODE_L ];
- LOADED->PKEYS[1][4] = keystates[ SDL_SCANCODE_E ];
- LOADED->PKEYS[1][5] = keystates[ SDL_SCANCODE_W ];
- LOADED->PKEYS[1][6] = keystates[ SDL_SCANCODE_Q ];
- LOADED->PKEYS[1][7] = keystates[ SDL_SCANCODE_R ];
- LOADED->PKEYS[2][4] = keystates[ SDL_SCANCODE_M ];
- LOADED->PKEYS[3][4] = keystates[ SDL_SCANCODE_N ];
- if( SDL_PollEvent(&event)) //check for input
- {
- if (event.type == SDL_QUIT)
- {
- RUNNING = false;
- SDL_Quit();
- return 1;
- }
- }
- Interface.Update_Interface( LOADED );
- SDL_GL_SwapWindow(MainSurf);
- glBindTexture( GL_TEXTURE_2D, NULL );
- glColor4f(0, 0, 0, 255);
- glBegin(GL_QUADS);
- glVertex2f(0, 0);
- glVertex2f(SW, 0);
- glVertex2f(SW, SH);
- glVertex2f(0, SH);
- glEnd();
- if ( (SDL_GetTicks()-countahframe) < (1000/LOADED->FPS) )
- {
- SDL_Delay((1000/LOADED->FPS) - (SDL_GetTicks()-countahframe));
- SDL_SetWindowTitle(MainSurf, (stringify(1000/(SDL_GetTicks()-countahframe)).c_str()));
- }
- else
- {
- SDL_SetWindowTitle(MainSurf, (stringify(1000/(SDL_GetTicks()-countahframe)).c_str()));
- }
- countahframe = SDL_GetTicks();
- if (Interface.LOADNOW)
- {
- OBJECTSTOLOAD=Interface._objectstoload;
- return 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement