int main( int argc, char* argv[] ) { //Create the game framework Initialise(SCREEN_X, SCREEN_Y, false); initGame(); do { g_iFrameCounter++; if(g_iFrameCounter > 5000) { g_iFrameCounter = 0; } ClearScreen(); updateGame(); drawGame(); if( checkExit() ) { break; } } while( FrameworkUpdate() == false ); destroyGame(); Shutdown(); return 0; }
// entry point of the program int main( int arc, char* argv[] ) { // First we need to create our Game Framework Initialise(SCREEN_X, SCREEN_Y, false,"Shoot em up" ); initGame(); initMenu(); initBoss(); initGameOver(); gameProcess = &menuState; do { frameCounter++; if(frameCounter > 5000) frameCounter = 0; gameProcess(); // function pointer to run game } while ( FrameworkUpdate() == false ); // clean up memory destroyGame(); destroyMenu(); destroyBoss(); destroyGameOver(); Shutdown(); return 0; }
int main(){ FrameworkInitialise("HelloWorld",1280,720,false); FrameworkBGColour(0.2f,0.4f,0.8f,1.0f); Sprite sprCarpet = SpriteLoad("./Images/Carpet.png",32,32,16,16); Font fntCourierNew = FontLoad("./Fonts/CourierNew.fnt"); //UPDATE while (FrameworkUpdate()){ //CLEAR AND DELTASET FrameworkClearScreen(); DeltaTimeSet(); count++; FPS = FPSGet(); for (int index = 1;index <= count; index++){ SpriteMove(sprCarpet,rand()%1280-640,rand()%720-360,rand()%99+1); SpriteDraw(sprCarpet); } if (FPS > 59.9f && FPS < 60.1f){ std::cout << "FPS :" << FPS << " sprite count :" << count << " triangle count : " << count*2 << std::endl; } if (FPS > 29.9f && FPS < 30.1f){ std::cout << "FPS :" << FPS << " sprite count :" << count << " triangle count : " << count*2 << std::endl; } DrawInt(fntCourierNew,GetInstanceCount(),0,360,0,true); } FrameworkShutdown(); return 1+1-1-1; }
int main( int argc, char* argv[] ) { //Framework Init Initialise(1024, 768); //Python Interpreter Initialization PythonManager Slither = PythonManager::Instance(); Slither.Initialize("./scripts"); Slither.AddTable("AIE", AIE_Functions); Slither.ImportScript("BlueS"); //Game Update Function PyObject * PyFunc_UpdateGame = Slither.GetFunction("BlueS", "UpdateGame"); do { Slither.ReloadScript("BlueS"); PyFunc_UpdateGame = Slither.GetFunction("BlueS", "UpdateGame"); Slither.CallFunction(PyFunc_UpdateGame, NULL); } while ( FrameworkUpdate() == false ); Slither.Finalize(); Shutdown(); return 0; }
int main( int argc, char* argv[] ) { Initialise(1280, 780); Game game; do { game.UpdateGame(); } while (FrameworkUpdate() == false && game.GetPlay()); Shutdown(); return 0; }
void BeerPongGame::Run() { do { ClearScreen(); //reload the settings file if 'R' is pressed if ( IsKeyDown(KEY_R) ) { settings->ReloadIniFile(); } if(stateSelection != currentState->stateSelection) { delete currentState; switch(stateSelection) { case MENU: currentState = new Menu(); break; case PLAYING_GAME: currentState = new PlayGame(this); break; case GAME_OVER: currentState = new GameOver(winner); break; case INSTRUCTIONS: currentState = new Instructions(); case SHUTTING_DOWN: ShutDownGame(); default: break; } } //Returns active current states - nice & tidy currentState->Update(); currentState->Draw(); inputHelper.Update(); if (stateSelection != SHUTTING_DOWN) FrameworkUpdate(); } while ( stateSelection != SHUTTING_DOWN ); }
int main(int argc, char* argv[]) { //\ Lets initialise the AIE Framework and give the window it creates an appropriate title Initialise(iScreenWidth, iScreenHeight, false, "One of Piece"); SetBackgroundColour(SColour(0x00, 0x00, 0x00, 0xFF)); AddFont("./fonts/invaders.fnt"); g_AssetManager.Load("Player", "./images/invaders/luffyPlayer.png", 40, 64); g_AssetManager.Load("Bullet", "./images/invaders/chopperBullet.png", 24, 36); g_AssetManager.Load("Enemy", "./images/invaders/tumblrEnemy.png", 36, 42); g_AssetManager.Load("BG", "./images/invaders/OPbackground.png", iScreenWidth, iScreenHeight); g_AssetManager.Load("GameBG", "./images/invaders/Logo (2).png", iScreenWidth, iScreenHeight); g_AssetManager.Load("VicBG", "./images/invaders/Luffy_One_Piece_Chibi.png", 400, 500); new Player(); Entity::init(); GameState ecurrentState = gs_MENU; ScoreDB &ref = ScoreDB::getInstance(); ref.Open(); //ScoreData myScore = { 0, "Your Timer: " }; do { ClearScreen(); float fDeltaT = GetDeltaTime(); SetFont("./fonts/invaders.fnt"); Playgame(fDeltaT); std::string timeFrame = "DeltaTime: "; timeFrame.append(std::to_string(fDeltaT)); SetFont(nullptr); } while (FrameworkUpdate() == false && running); ref.Close(); g_AssetManager.FreeAll(); Shutdown(); return 0; }
int main( int argc, char* argv[] ) { Initialise( iScreenWidth, iScreenHeight, false, "Just Another Retro Pew Pew" ); SetBackgroundColour( SColour( 000, 000, 000, 000 ) ); // player.SetSpriteID(CreateSprite( "./images/player.png", player.GetWidth(), player.GetHeight(), true)); GameStates eCurrentState = eMAIN_MENU; do { ClearScreen(); float fDeltaT = GetDeltaTime(); switch (eCurrentState) { case eMAIN_MENU: UpdateMainMenu(); if( IsKeyDown( KEY_ENTER) ) { eCurrentState = eGAMEPLAY; } break; case eGAMEPLAY: UpdateGameState(); if( IsKeyDown( KEY_ESCAPE) ) { eCurrentState = eMAIN_MENU; } break; default: break; } } while ( FrameworkUpdate() == false ); Shutdown(); return 0; }
int main(int argc, char **argv) { Initialise(800, 750, false); texture = CreateTexture("crate_sideup.png"); //CreateFont(); while(FrameworkUpdate()) { ClearScreen(); //DrawString("This works fine i hope", 550, 550, 16); DrawTexture(texture, 100, 100, 128, 128); } DestroyTexture(texture); Shutdown(); return 0; }
int main( int argc, char* argv[] ) { int iLevelWidth = 1024; int iLevelHeight = 768; Initialise(iLevelWidth, iLevelHeight, false, "Game!"); Engine Game; Game.ChangeState(IntroState::Instance()); do { Game.Update(); } while ( FrameworkUpdate() == false ); Shutdown(); return 0; }
int main( int argc, char* argv[] ) { const int iScreenWidth = 1680; const int iScreenHeight = 1050; Initialise( iScreenWidth, iScreenHeight, false); uiBgImage = CreateSprite("./images/Blue Eye.png", iScreenWidth, iScreenHeight, false); Vector2D playerPosition(840, 625); Vector2D playerSpeed(0,0); Sprite Player(playerPosition, playerSpeed, 100, 100, -1); do { DrawSprite(uiBgImage); } while ( FrameworkUpdate() == false ); Shutdown(); return 0; }
int main( int argc, char* argv[] ) { const int iScreenWidth = 1680; const int iScreenHeight = 1050; Initialise( iScreenWidth, iScreenHeight, false, "Game" ); uiBgImage = CreateSprite("./images/Blue Eye.png", iScreenWidth, iScreenHeight, false); Player MainCharacter; do { DrawSprite(uiBgImage); MainCharacter.Move(); MainCharacter.Control(); MainCharacter.Draw(); } while ( FrameworkUpdate() == false ); Shutdown(); return 0; }
int main(int argc, char *argv[]) { //\================================================================================================ //\ Initialise Python //\================================================================================================ Py_Initialize(); //\================================================================================================ //\Add our current directory to the path lookup for Python imports //\================================================================================================ PySys_SetArgv(argc, argv); //PyRun_SimpleString( "from sys import path\nfrom os import getcwd\nprint \"Current Dir\" \, getcwd()\npath.append( getcwd() + \"/scripts\" )\n" ); PyObject* sysPath = PySys_GetObject((char*)"path"); PyList_Append(sysPath, PyString_FromString("./scripts")); //\================================================================================================ //\Import the AIE C Functions into Python so that we can call them from there //\ we will need to add "import AIE" to any Python files that we wish to use these functions in //\================================================================================================ Py_InitModule("AIE", AIE_Functions); //\================================================================================================ //\ Here we are loading our Python Entry point this is the name of the game.py file that we will be //\ using for this project. //\ ** feel free to change this to anything you would like to, "game" is purely intended as a //\ suitable example. //\================================================================================================ PyObject* pModule = ImportPythonModule( "game" ); if (pModule != NULL) { //\============================================================================================ //\ Here we are attempting to resolve a function to call inside our python file //\ In this scenario we are looking for the main function inside our game.py file //\============================================================================================ if( AIE::InitialiseFramework( pModule ) ) { AIE::Load(pModule); do { ClearScreen(); float fDeltaTime = GetDeltaTime(); AIE::UpdatePython( pModule, fDeltaTime ); }while( !FrameworkUpdate() ); AIE::ShutdownFramework( pModule ); } Py_DECREF(pModule); } Py_Finalize(); if( g_pWindowTitle ) { delete[] g_pWindowTitle; } std::cin.get(); return 0; }
int main( int argc, char* argv[] ) { Initialise(iScreenWidth, iScreenHeight, false, "Space Invaders"); SetBackgroundColour(SColour(0x00, 0x00, 0x00, 0xFF)); //player settings player.SetSize(64.0f, 32.0f); player.iSpriteID = CreateSprite("./images/cannon.png", player.fWidth, player.fHeight, true); player.SetMovementExtremes(0.0f, iScreenWidth); player.SetMovementKeys(65, 68); player.x = iScreenWidth * 0.5f; player.y = 88.0f; //create Marquee sprite iArcadeMarquee = CreateSprite("./images/Space-Invaders-Marquee.png", iScreenWidth, iScreenHeight, true); //enemy creation CreateEnemies(); enemyDirection = eRIGHT; nextDirection = eRIGHT; //font setting AddFont(pInvadersFont); //game state declaration GAMESTATES eCurrentState = eMAIN_MENU; //Game Loop do { float fDeltaT = GetDeltaTime(); switch (eCurrentState) { case eMAIN_MENU: UpdateMainMenu(); //input if (IsKeyDown(257) && !IsKeyDown(256)) { eCurrentState = eGAMEPLAY; ResetEnemies(); } break; case eGAMEPLAY: UpdateGameState(fDeltaT); //ChangeState if (IsKeyDown(256)) { eCurrentState = eMAIN_MENU; } break; default: break; } //clear screen ClearScreen(); } while(!FrameworkUpdate()); Shutdown(); return 0; }
int main( int arc, char* argv[] ) { // First we need to create our Game Framework Initialise( width, height, false ); // Now load some sprites unsigned int BackgroundSprite = CreateSprite( "images/background.png", 1280, 780, false ); unsigned int PaddleLeftSprite = CreateSprite( "images/Paddle.png", 32, 64, true ); unsigned int PaddleRightSprite = CreateSprite( "images/Paddle.png", 32, 64, true ); unsigned int BallSprite = CreateSprite( "images/Ball.png", 32, 32, true ); unsigned int Header = CreateSprite( "images/Header.png", 444, 128, true ); //setup all the variables int paddleleftx = 100; int paddlelefty = height/2; int paddleleftyvar = 0; int paddlerightx = width-100; int paddlerighty = height/2; int paddlerightyvar = 0; if (xspeed<0){ bPaddle = 0;} else if (xspeed>0){ bPaddle = 1; } int iOption = 1; int iOptiony = height/2; //if the ball is in the up/down area, reset it again while (xspeed>-2 && xspeed <2){ srand((unsigned)time(0)); xspeed = -5 +(rand() % 10); } while (yspeed>-2 && yspeed <2){ srand((unsigned)time(0)); yspeed = -5 +(rand() % 10); } glClearColor(0.0f,0.0f,0.0f,0); do{ fDeltaTime = (clock() - fLastTime)/(float)CLOCKS_PER_SEC; fLastTime = clock(); if (!IsKeyDown(GLFW_KEY_SPACE)){ bCanCheck[0]=true; } if (!IsKeyDown(GLFW_KEY_ENTER)){ bCanCheck[1]=true; } if (!IsKeyDown(GLFW_KEY_BACKSPACE)){ bCanCheck[2]=true; } if (!IsKeyDown(GLFW_KEY_UP)){ bCanCheck[3]=true; } if (!IsKeyDown(GLFW_KEY_DOWN)){ bCanCheck[4]=true; } switch (Menu){ /////////////////////////////////////////////////////////////////////////////////////////////////////GAME CASE//////////////////////////////////////////////////////////////////////////////////////////////////////////// case 0: //make sure the game doesnt "flash" with keypress's on menus by clearing all old objects ClearScreen(); //controls & movement if ( IsKeyDown('W') && paddlelefty>64) {paddleleftyvar--;} if ( IsKeyDown('S') && paddlelefty<height-64) {paddleleftyvar++;} if ( IsKeyDown(GLFW_KEY_UP) && paddlerighty>64 ) {paddlerightyvar--;} if ( IsKeyDown(GLFW_KEY_DOWN) && paddlerighty<height-64){paddlerightyvar++;} //left if (paddlelefty>=64 && paddlelefty<=height-64){ paddlelefty += paddleleftyvar * 10.0f * fDeltaTime; }else { paddleleftyvar = 0; if (paddlelefty>height/2) {paddlelefty=height-64;}else{paddlelefty=64;} } //right if (paddlerighty>=64 && paddlerighty<=height-64){ paddlerighty += paddlerightyvar * 10.0f * fDeltaTime; }else { paddlerightyvar=0; if (paddlerighty>height/2) {paddlerighty=height-64;}else{paddlerighty=64;} } ballx += xspeed * 100.0f * fDeltaTime; bally += yspeed * 100.0f * fDeltaTime; //ball collisions //outside left/right and top/bottom bounce //add to score if (ballx>=width){iScore[1]++;} if (ballx<=0) {iScore[0]++;} //reset room if (ballx<=0 || ballx>=width){ BallReset(); } if (bally<=0 || bally>=height){ yspeed *= -1; } //stop the ball going to fast if (xspeed>10) {xspeed=10; } if (xspeed<-10){xspeed=-10;} if (yspeed>10) {yspeed=10; } if (yspeed<-10){yspeed=-10;} //paddle left if (ballx<=paddleleftx+16 && bPaddle == 0){ if (bally<paddlelefty-28 && bally>paddlelefty-64){ xspeed *= -3 * 100.0f * fDeltaTime; yspeed *= 2 * 100.0f * fDeltaTime; }else if (bally<paddlelefty+28 && bally>paddlelefty-28){ yspeed *= -1 * 100.0f * fDeltaTime; xspeed *= -1 * 100.0f * fDeltaTime; }else if (bally<paddlelefty+64 && bally>paddlelefty+28){ xspeed *= -3 * 100.0f * fDeltaTime; yspeed *= -2 * 100.0f * fDeltaTime; } bPaddle = 1; } //paddle right if (ballx>=paddlerightx-16 && bPaddle == 1){ if (bally<paddlerighty-28 && bally>paddlerighty-64){ xspeed *= -3; yspeed *= 2; }else if (bally<paddlerighty+28 && bally>paddlerighty-28){ yspeed *= -1; xspeed *= -1; }else if (bally<paddlerighty+64 && bally>paddlerighty+28){ xspeed *= -3; yspeed *= -2; } bPaddle = 0; } //draw the instances DrawSprite(BackgroundSprite); MoveSprite( BackgroundSprite, 0, 0); DrawSprite(PaddleLeftSprite); DrawSprite(PaddleRightSprite); DrawSprite(BallSprite); //draw the middle DrawLine(width/2, 0, width/2, height, SColour(0x00,0x00,0x00,0xAA) ); //move the instances MoveSprite( PaddleLeftSprite, paddleleftx, paddlelefty ); MoveSprite( PaddleRightSprite, paddlerightx, paddlerighty); MoveSprite( BallSprite, ballx, bally ); //convert the int's to strings and draw thw score DrawInt(iScore[0],(width/4)*3, 32); DrawInt(iScore[1],(width/4), 32); //if someone has won, change the screen to say so. for (int i = 0; i<=1; i++){ if (iScore[i] >= 10){ winner = i; Menu = 2; } } //debug information if (debug==true){ //hitlines DrawHitline(paddleleftx+16,paddlelefty); DrawHitline(paddlerightx-16,paddlerighty); //vars std::cout << "paddlelefty : " << paddlelefty<< std::endl; std::cout << "paddleleftyvar : " << paddleleftyvar<< std::endl; std::cout << "paddlerighty : " << paddlerighty<< std::endl; std::cout << "paddlerightyvar : " << paddlerightyvar<< std::endl; std::cout << "ballx : " << ballx<< std::endl; std::cout << "bally : " << bally<< std::endl; std::cout << "xspeed : " << xspeed<< std::endl; std::cout << "yspeed : " << yspeed<< std::endl; } //Checks to set the debug to show or no if (IsKeyDown(GLFW_KEY_BACKSPACE) && bCanCheck[2] == true){ if (debug==true ){ debug=false; bCanCheck[2]=false; }else if (debug==false){ debug=true; bCanCheck[2]=false; } } //add to the timer break; ///////////////////////////////////////////////////////////////////////////////////////////////////MAIN MENU////////////////////////////////////////////////////////////////////////////////////////////////////////////// case 1: ClearScreen(); //sets the screen to black //draws the information DrawSprite(BackgroundSprite); MoveSprite( BackgroundSprite, 0, 0); DrawSprite(Header); MoveSprite( Header, width/2, height/8 ); //fake objects MoveSprite( BallSprite, width/2, iOptiony ); DrawSprite(BallSprite); MoveSprite( PaddleLeftSprite, 100, height/2 ); DrawSprite(PaddleLeftSprite); MoveSprite( PaddleRightSprite, width-100, height/2 ); DrawSprite(PaddleRightSprite); DrawString( "Scores", width/2+32, height/2-48 ); DrawString( "Play Game", width/2+32, height/2-16 ); DrawString( "Quit", width/2+32, height/2+16 ); DrawString( "Controls", (width/2)+32, height/2+48 ); switch (iOption){ case 0: iOptiony = (height/2)-32; break; case 1: iOptiony = (height/2); break; case 2: iOptiony = (height/2)+32; break; case 3: iOptiony = (height/2)+64; break; default: break; } if (IsKeyDown(GLFW_KEY_DOWN) && bCanCheck[4] == true){ bCanCheck[4]=false; iOption++; if (iOption>3){iOption=0;} } if (IsKeyDown(GLFW_KEY_UP) && bCanCheck[3] == true){ bCanCheck[3]=false; iOption--; if (iOption<0){iOption=3;} } if (IsKeyDown(GLFW_KEY_ENTER) && bCanCheck[1] == true){ bCanCheck[1] = false; switch (iOption){ case 0: Menu = 2;//goto the highscores break; case 1: //reset the winner and score winner=-1; iScore[0]=0; iScore[1]=0; //reset the ball BallReset(); //reset the paddles paddlelefty = height/2; paddleleftyvar = 0; paddlerighty = height/2; paddlerightyvar = 0; Menu = 0;//goto the game break; case 2: bQuitGame = true; break; case 3: Menu = 3;//goto the Controls Page break; } } //go to game when pressed break; ////////////////////////////////////////////////////////////////////////////////////////////////////////WIN SCREEN//////////////////////////////////////////////////////////////////////////////////////////////////////// case 2: //draw the win screen ClearScreen(); DrawSprite(BackgroundSprite); MoveSprite( BackgroundSprite, 0, 0); DrawSprite(Header); MoveSprite( Header, width/2, height/8 ); //draw the background pong items MoveSprite( BallSprite, width/2, height/2-32 ); DrawSprite(BallSprite); MoveSprite( PaddleLeftSprite, 100, height/2 ); DrawSprite(PaddleLeftSprite); MoveSprite( PaddleRightSprite, width-100, height/2 ); DrawSprite(PaddleRightSprite); //draw old menu DrawString( "Play Game", width/2+32, height/2-16 ); DrawString( "Controls", (width/2)+32, height/2+48 ); DrawString( "Quit", (width/2)+32, height/2+16 ); //draw new items with some indentation DrawString( " Scores", width/2+32, height/2-48 ); switch (winner){ case 0: DrawString(" Player One Wins", (width/2)+32, height/2-112 ); break; case 1: DrawString(" Player Two Wins", (width/2)+32, height/2-112 ); break; } DrawString(" Enter to return to the main menu.", (width/2)+32, height/2-80 ); //back to the main menu if (IsKeyDown(GLFW_KEY_ENTER) && bCanCheck[1] == true){ //goto the main menu Menu = 1; iOptiony = 1; bCanCheck[1] = false; } if (IsKeyDown(GLFW_KEY_DOWN) && bCanCheck[4] == true){ //goto the main menu Menu = 1; iOptiony = 1; bCanCheck[4] = false; } break; ///////////////////////////////////////////////////////////////////////////////////////////////////////////CONTROLS////////////////////////////////////////////////////////////////////////////////////////////////////// case 3: ClearScreen(); //draw the pong background DrawSprite(BackgroundSprite); MoveSprite( BackgroundSprite, 0, 0); DrawSprite(Header); MoveSprite( Header, width/2, height/8 ); MoveSprite( BallSprite, width/2, iOptiony ); DrawSprite(BallSprite); MoveSprite( PaddleLeftSprite, 100, height/2 ); DrawSprite(PaddleLeftSprite); MoveSprite( PaddleRightSprite, width-100, height/2 ); DrawSprite(PaddleRightSprite); //draw old menu DrawString( "Scores", width/2+32, height/2-48 ); DrawString( "Play Game", width/2+32, height/2-16 ); DrawString( "Quit", (width/2)+32, height/2+16 ); //draw new items with some indentation DrawString( " Controls", (width/2)+32, height/2+48 ); DrawString( " Payer Left, W is up, S is down.", (width/2)+32, height/2+80 ); DrawString( " Player Right, Arrow Up is up, Arrow Down is down.",width/2+32, height/2+112 ); DrawString( " Enter to return to main menu.", width/2+32, height/2+144 ); //check if up or enter is pressed to go back if (IsKeyDown(GLFW_KEY_ENTER) && bCanCheck[1] == true){ //goto the main menu Menu = 1; iOptiony = 1; bCanCheck[1] = false; } if (IsKeyDown(GLFW_KEY_UP) && bCanCheck[3] == true){ //goto the main menu Menu = 1; iOptiony = 1; bCanCheck[3] = false; } break; /////////////////////////////////////////////////////////////////////////////////////////////////////DESTROY EVERYTHING////////////////////////////////////////////////////////////////////////////////////////////////// } } while ( FrameworkUpdate() == false && !bQuitGame == true); //destroy all objects clearing them on game exit DestroySprite(PaddleLeftSprite); DestroySprite(PaddleRightSprite); DestroySprite(BallSprite); DestroySprite(Header); DestroySprite(BackgroundSprite); Shutdown(); //programming signature std::cout << "So long, and thanks for all the fish!"; return 0; }
///// ////////////////////////////////////////////////////////////////////////// // This function can be called from Python to force an update to the framework. ////////////////////////////////////////////////////////////////////////// PyObject* AIE_Update(PyObject *self, PyObject *args) { FrameworkUpdate(); Py_RETURN_NONE; }
PyObject* LMF_FrameworkUpdate(PyObject *self, PyObject *args){ int Updated = FrameworkUpdate(); return Py_BuildValue("i", Updated); }