int main ( int argc, char *argv[] ) { GameEngine game; // initialisation du jeu game.Init( "Ultimate Abyss" ); // load the intro //game.ChangeState(new Start()); //game.ChangeState(new Field()); game.ChangeState(new Menu()); // main loop while ( game.Running() ) { game.HandleEvents(); game.Update(); game.Draw(); SDL_Delay(1000/game.getFramesPerSecond()); } // cleanup the engine game.Cleanup(); return 0; }
int main(int argc, char** argv) { GameEngine *engine = GameEngine::CreateInstance(); engine->Initialize(); while(true) { engine->Update(); engine->Draw(); } engine->Shutdown(); return 0; }
int main( int argc, char *argv[] ) { GameEngine game; if(!game.Init( "Pong v3" )) { printf( "Game failed to initialize\n"); } game.ChangeState( IntroState::Instance() ); while( game.Running() ) { game.HandleEvents(); game.Update(); game.Draw(); } game.Cleanup(); return 0; }
int main(int argc, char* argv[]) { gameEngine.Init(); //Sets up allegro libraries and implements drivers gameEngine.PushState(new MenuState); while(gameEngine.Running()) { gameEngine.HandleEvents(); gameEngine.Update(); gameEngine.Draw(); al_wait_for_event(gameEngine.redrawQueue, NULL); al_flush_event_queue(gameEngine.redrawQueue); } gameEngine.Cleanup(); return 0; }
int main(int argc, char** argv) { printf("Start"); srand(time(NULL)); // Init engine GameEngine game; game.Init("isoMap V0.1", 1280, 960, 0, false); // Set state game.ChangeState(PlayState::Instance()); while (game.Running()) { if (game.DoLoop()) { game.HandleEvents(); game.Update(); game.Draw(); } } game.Cleanup(); return 0; }
void DrawScreen(SDL_Surface* screen,TTF_Font *font, GameEngine& ge,int i_counter) { if(SDL_MUSTLOCK(screen)) { if(SDL_LockSurface(screen) < 0) return; } //clear: SDL_FillRect(screen,NULL, 0x000000); float r_widht=(float)WIDTH/(float)GE_WIDTH; float r_height=(float)HEIGHT/(float)GE_HEIGHT; //TestText: SDL_Surface *text; SDL_Color text_color = {255, 255, 255}; text = TTF_RenderText_Solid(font,"Bla",text_color); SDL_Rect pos; pos.x=10; pos.y=120; if (SDL_BlitSurface(text, NULL, screen, &pos) != 0) { cerr << "SDL_BlitSurface() Failed: " << SDL_GetError() << endl; } for( MyML bla :ge.Draw().E("T1").Array("Player")){ float posx=INT(bla.A("Pos.x")); //.attributes["posx"]); float posy=INT(bla.A("Pos.y"));//attributes["posy"]); float oldposx=INT(bla.A("Gui.OldPos.x")); float oldposy=INT(bla.A("Gui.OldPos.y")); int c=StringToInt(bla.A("color")); float draw_pos_x=0,draw_pos_y=0; draw_pos_x=oldposx+((float)i_counter/30)*(posx-oldposx); draw_pos_y=oldposy+((float)i_counter/30)*(posy-oldposy); //cout<<"posx: "<<(int)posx<<" oldposx: "<<(int)oldposx<<" draw_x: "<<(int)draw_pos_x<<endl; float x=draw_pos_x; float y=draw_pos_y; x*=r_widht; y*=r_height; fill_circle(screen , (int)x,(int)y, 10,c); //draw id: SDL_Surface *text;{ SDL_Color text_color = {255, 255, 255}; text = TTF_RenderText_Solid(font,bla.A("id").c_str(),text_color); } SDL_Rect textpos;{ textpos.x=(int)x;textpos.y=(int)y; } if (SDL_BlitSurface(text, NULL, screen, &textpos) != 0) { cerr << "SDL_BlitSurface() Failed: " << SDL_GetError() << endl; } //fill_circle(screen , 10,10, 5, 0xff00ff); } // for( MyML bla :ge.Draw().E("T2").E_all("Player")){ // cout<<"HIER KOMM ICH NIE HIN"<<endl; // float posx=StringToInt(bla.E("Pos").A("x"));//.attributes["posx"]); // float posy=StringToInt(bla.E("Pos").A("y"));//.attributes["posy"]); // int c=StringToInt(bla.A("color")); // posx*=r_widht; // posy*=r_height; // fill_circle(screen , (int)posx,(int)posy, 10,c); // //fill_circle(screen , 10,10, 5, 0xff00ff); // } { try{ float posx=INT(ge.Draw().A("Ball.Pos.x")); float posy=INT(ge.Draw().A("Ball.Pos.y")); float oldposx=INT(ge.Draw().A("Ball.Gui.OldPos.x")); float oldposy=INT(ge.Draw().A("Ball.Gui.OldPos.y")); int c=StringToInt(ge.Draw().A("Ball.color")); float draw_pos_x=0,draw_pos_y=0; draw_pos_x=oldposx+((float)i_counter/30)*(posx-oldposx); draw_pos_y=oldposy+((float)i_counter/30)*(posy-oldposy); //cout<<"posx: "<<(int)posx<<" oldposx: "<<(int)oldposx<<" draw_x: "<<(int)draw_pos_x<<endl; // float x=posx; // float y=posy; float x=draw_pos_x; float y=draw_pos_y; x*=r_widht; y*=r_height; //cout<< posx<<","<<posy<<endl; fill_circle(screen , (int)x,(int)y, 5,c); }catch(MyMLException& e){ //nicht so wild... cout<<"Konnte den Ball nicht malen: "<<e.Error() <<endl; } } //fill_circle(screen , 10,10, 5, 0xff00ff); if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen); SDL_Flip(screen); }