void frontendDemoStep() { if(!sc_demoLocal) { gameSetup(); gc_level = cc_numLevels - 1; sc_demoLocal = 1; } if(1 == sc_demoLocal) { levelSetup(); sc_demoLocal = 2; } if(2 == sc_demoLocal) { char AIResult = gamePlay(NO); if(gSTATE_Play != AIResult) sc_demoLocal = 3; } if(3 == sc_demoLocal) { if(crash(NO)) { gc_applesToGetThisLevel = ApplesPerLevel; if(++gc_level >= cc_numLevels) gc_level = 0; sc_demoLocal = 1; } } }
// program code aways begins at the top of main() int main(){ //The next line is a function drom core.cpp // it sets up Allegro for graphics and keyboard techInit(); gameSetup(); // this next while loop while(key[KEY_ESC] == false){ updatePaddlePosition(); moveBall(); if(numberOfBricksRemaining() == 0) { resetBricks(); } drawingThings(); // this line draws the screenBuffer to the screen // by drawing to off-screen memory first, then // copying the new total image to screen all at once, // we can avoid any flickering/flashing from the player // seeing characters drawn sequentially. // The technique us called double buffering. updateScreen(); // is the game going too fast on your awesome modern hardware? // Experiment with numbers 0-15 here to slow down the application: rest(1); } return 0; } END_OF_MAIN()// putting this line after the main() function
// JFL 30 Jul 06 int qeMain(int argc,chr *argv[]) { int fail = 0; // failure // // INIT // //qePrintf("%s / %s / %s\n",__FILE__,glGetString(GL_VERSION),qeVersion()); if(gameInit() < 0) // initialize game { fail=1; } // if if(fail) // check for catastrophic failure in init { goto BAIL; // end } // if // // BODY // // add a function object to engine if(!qeObjAddFnc(gameMainLoop)) { BRK(); // error goto BAIL; // end } gameSetup(); // setup game objects qeForever(); // turn over control to the engine until the program exits BAIL: // // FINAL // gameFinal(); // cleanup and free game objects if(qefnCheckForCleanExit() <0 ) { BRK(); // check qelog.txt for problem } // if return 0; } // qeMain()
// program code aways begins at the top of main() int main(){ //The next line is a function drom core.cpp // it sets up Allegro for graphics and keyboard techInit(); gameSetup(); while(key[KEY_ESC] == false){ movePlayer(); moveShot(); drawThings(); updateScreen(); // is the game going too fast on your awesome modern hardware? // Experiment with numbers 0-15 here to slow down the application: rest(1); } return 0; } END_OF_MAIN()// putting this line after the main() function
/** * \brief The main game loop. This just cycles endlessly, it uses the game's 'state' to determine which screen to show and what to do. */ int main(){ //looping back and forth forever (cards against humanity reference) while(1) { //some basic prep work performed once before our custom intro if(game_state == INTRO) { initialSetup(); initIntro(); } //perform custom intro while(game_state == INTRO) { //wait until the next frame WaitVsync(1); drawIntro(); processIntro(); } //prep the main menu if(game_state == MAIN_MENU) { FadeOut(0,true); ClearVram(); SetTileTable(title_tiles); SetFontTilesIndex(TITLE_TILES_SIZE); drawMainMenu(); FadeIn(0,false); } //draw menu and handle input while(game_state == MAIN_MENU) { WaitVsync(1); drawMenuCursor(); processMainMenu(); } if(game_state== GAME) { //run our setup for the main game ClearVram(); FadeOut(0,true); gameSetup(); FadeIn(0,false); } //when we're in the gameplay portion, draw and accept input for the game while(game_state == GAME) { WaitVsync(1); processScrollSpeed(); //scrolls screen as appropriate updateCity(); //offsets city for parallax processControls(); //accepts and processes controller input processPlayerMotion(); //update player position processSprites(); //updates and moves player image to player position } if(game_state == HIGH_SCORES) { FadeOut(0,true); SetTileTable(title_tiles); SetFontTilesIndex(TITLE_TILES_SIZE); drawLocalHighScoreMenu(); //draw up the high score screen FadeIn(0,false); deathclock=120; //reset death timer to 2 seconds if(score > topscores[9]) { LoadScore(0, 9); //load top 10 saved high scores SaveScore(score); //save our current score if it's high enough drawLocalHighScoreMenu(); //draw up the high score screen } } //draw and accepts input for the local high score screen while(game_state == HIGH_SCORES) { WaitVsync(1); processHighScoreMenu(); } } }
char loadStateLogicV1(FILE* fp) { //Clear the screen and set up some temp variables arraySetup(); elementSetup(); gameSetup(); int i, j, elementIndex, elementHash, sizeX, sizeY, fileMaxSpecials, tempSpecialVal, charsRead, failed; struct Element* tempElement; int tempParticle; char buffer[64]; char lookAhead; if(fp != NULL) { // Get the saveload version code if((charsRead = fscanf(fp, "%s\n\n", &buffer)) == EOF || charsRead < 1) { return FALSE; } if(strcmp(buffer, SAVELOAD_VERSION_CODE) != 0) { return FALSE; } // Get the max specials at the time of this file if((charsRead = fscanf(fp, "%d\n\n", &fileMaxSpecials)) == EOF || charsRead < 1) {return FALSE;} // Get the dimensions if((charsRead = fscanf(fp, "%d %d\n\n", &sizeX, &sizeY)) == EOF || charsRead < 2) {return FALSE;} //Make sure saves are portable from different dimensions if(sizeX > workWidth) { sizeX = workWidth; } if(sizeY > workHeight) { sizeY = workHeight; } while(!feof(fp)) { failed = FALSE; // Check for all particles used if(loq <= 0) {return TRUE;} // Scan in the initial character // If there is nothing, we're done if((charsRead = fscanf(fp, "%c", &lookAhead)) == EOF || charsRead < 1) {return TRUE;} // Basic particle if(lookAhead == 'B') { // Try to read in a particle tempParticle = avail[loq-1]; if((charsRead = fscanf(fp, "(%f %f %d %d %c %d)", &(a_x[tempParticle]), &(a_y[tempParticle]), &(a_xVel[tempParticle]), &(a_yVel[tempParticle]), &(a_heat[tempParticle]), &elementIndex)) == EOF || charsRead < 6) {continue;} a_element[tempParticle] = elements[elementIndex]; } // Custom particle else if(lookAhead == 'C') { // Try to read in a particle tempParticle = avail[loq-1]; if((charsRead = fscanf(fp, "(%f %f %d %d %c %lu)", &(a_x[tempParticle]), &(a_y[tempParticle]), &(a_xVel[tempParticle]), &(a_yVel[tempParticle]), &(a_heat[tempParticle]), &elementHash)) == EOF || charsRead < 6) {continue;} // Find custom with that hash, and set the index elementIndex = findElementFromHash(elementHash); if (elementIndex) { a_element[tempParticle] = elements[elementIndex]; } else { // Don't fail now, we need to finish reading in all specials, etc. so that // we don't corrupt the stream. Instead, finish reading in, then don't actually // allocate the element. failed = TRUE; } } // Empty location else if(lookAhead == 'E') { continue; } else { // Ignore whitespace and other characters continue; } // Save the integral coordinates for writing to allCoords i = (int)a_x[tempParticle]; j = (int)a_y[tempParticle]; if (i >= sizeX || j >= sizeY) { return FALSE; } // Check that our lookahead is correct if((charsRead = fscanf(fp, "%c", &lookAhead)) != EOF && charsRead == 1 && lookAhead == '[') { int k; for (k = 0; k < fileMaxSpecials; k++) { if((charsRead = fscanf(fp, "%d ", &tempSpecialVal)) == EOF || charsRead < 1) { failed = TRUE; break; } if (k < MAX_SPECIALS) { a_specialVals[tempParticle][k] = tempSpecialVal; } } // Skip past the closing ']' fseek(fp, 1, SEEK_CUR); } else { // Put the lookAhead char back on the stream fseek(fp, -1, SEEK_CUR); failed = TRUE; } // If reading in failed, initialize to cleared if (failed) { clearSpecialValsToElementDefault(tempParticle); } // Only finish creating the particle if we succeed if (!failed) { // Remove the particle from avail loq--; // Make the particle set a_set[tempParticle] = TRUE; // Set the allCoords and bitmap color allCoords[getIndex(i, j)] = tempParticle; setBitmapColor(a_x[tempParticle], a_y[tempParticle], a_element[tempParticle]); } } return TRUE; } return FALSE; }
char loadStateLogicV0(FILE* fp) { //Clear the screen and set up some temp variables arraySetup(); elementSetup(); gameSetup(); int numElementsSaved, i, j, elementIndex, lowerElementIndex, higherElementIndex, sizeX, sizeY, fileMaxSpecials, tempSpecialVal, charsRead, failed; struct Element* tempElement; int tempParticle; char lookAhead; if(fp != NULL) { __android_log_write(ANDROID_LOG_INFO, "LOG", "Loading custom elements in the save"); // Get the number of custom elements saved in the file if((charsRead = fscanf(fp, "%d\n\n", &numElementsSaved)) == EOF || charsRead < 1) { return FALSE; } // Get the max specials at the time of this file if((charsRead = fscanf(fp, "%d\n\n", &fileMaxSpecials)) == EOF || charsRead < 1) {return FALSE;} int* tempMap; int* tempElMap; tempElMap = (int*)malloc ( MAX_ELEMENTS * sizeof(int) ); tempMap = (int*)malloc( numElementsSaved * 3 * sizeof(int) ); elements = realloc( elements, (numElements + numElementsSaved) * sizeof( struct Element* ) ); for(i = 0; i < numElementsSaved; i++) { if((charsRead = fscanf(fp, "%d", &elementIndex) == EOF || charsRead < 1)) {return FALSE;} tempElement = (struct Element*) malloc(sizeof(struct Element)); if((charsRead = fscanf(fp, "%s", &tempElement->name)) == EOF || charsRead < 1) {return FALSE;} if((charsRead = fscanf(fp, "%d", &tempElement->state)) == EOF || charsRead < 1) {return FALSE;} if((charsRead = fscanf(fp, "%d", &tempElement->startingTemp)) == EOF || charsRead < 1) {return FALSE;} if((charsRead = fscanf(fp, "%d", &tempElement->lowestTemp)) == EOF || charsRead < 1) {return FALSE;} if((charsRead = fscanf(fp, "%d", &tempElement->highestTemp)) == EOF || charsRead < 1) {return FALSE;} if((charsRead = fscanf(fp, "%d", &lowerElementIndex)) == EOF || charsRead < 1) {return FALSE;} if((charsRead = fscanf(fp, "%d", &higherElementIndex)) == EOF || charsRead < 1) {return FALSE;} if((charsRead = fscanf(fp, "%d", &tempElement->red)) == EOF || charsRead < 1) {return FALSE;} if((charsRead = fscanf(fp, "%d", &tempElement->green)) == EOF || charsRead < 1) {return FALSE;} if((charsRead = fscanf(fp, "%d", &tempElement->blue)) == EOF || charsRead < 1) {return FALSE;} if((charsRead = fscanf(fp, "%d", &tempElement->density)) == EOF || charsRead < 1) {return FALSE;} if((charsRead = fscanf(fp, "%d", &tempElement->fallVel)) == EOF || charsRead < 1) {return FALSE;} if((charsRead = fscanf(fp, "%d", &tempElement->inertia)) == EOF || charsRead < 1) {return FALSE;} int j; char collision; int special, specialVal; tempElement->collisions = malloc (NUM_BASE_ELEMENTS * sizeof(char)); // Load collisions for (j = 0; j < NUM_BASE_ELEMENTS; j++) { __android_log_write(ANDROID_LOG_INFO, "LOG", "Loading collisions"); charsRead = fscanf(fp, "%d", &collision); if (charsRead < 1 || charsRead == EOF) { tempElement->collisions[j] = 0; } else { tempElement->collisions[j] = collision; } } // Load specials for (j = 0; j < fileMaxSpecials; j++) { __android_log_write(ANDROID_LOG_INFO, "LOG", "Loading specials"); charsRead = fscanf(fp, "%d %d", &special, &specialVal); if (j < MAX_SPECIALS) { if (charsRead < 2 || charsRead == EOF) { tempElement->specials[j] = SPECIAL_NONE; tempElement->specialVals[j] = 0; } else { tempElement->specials[j] = special; tempElement->specialVals[j] = specialVal; } } } tempMap[3*i] = elementIndex; tempMap[3*i + 1] = lowerElementIndex; tempMap[3*i + 2] = higherElementIndex; tempElMap[elementIndex] = i + numElements; elements[elementIndex] = tempElement; } for (i = 0; i < numElementsSaved; i++) { elements[ tempMap[3*i] ]->lowerElement = tempMap[3*i + 1] > NUM_BASE_ELEMENTS ? elements[ tempElMap[tempMap[3*i + 1]] ] : elements[tempMap[3*i + 1]]; elements[ tempMap[3*i] ]->lowerElement = tempMap[3*i + 2] > NUM_BASE_ELEMENTS ? elements[tempElMap[tempMap[3*i + 2]] ]: elements[tempMap[3*i + 2]]; } free(tempMap); free(tempElMap); numElements += numElementsSaved; __android_log_write(ANDROID_LOG_INFO, "LOG", "Done loading custom elements in the save"); // Get the dimensions if((charsRead = fscanf(fp, "%d %d\n\n", &sizeX, &sizeY)) == EOF || charsRead < 2) {return FALSE;} //Make sure saves are portable from different dimensions if(sizeX > workWidth) { sizeX = workWidth; } if(sizeY > workHeight) { sizeY = workHeight; } while(!feof(fp)) { // Check for all particles used if(loq <= 0) {return TRUE;} // Scan in the initial character if((charsRead = fscanf(fp, "%c", &lookAhead)) == EOF || charsRead < 1) {return FALSE;} // If it's not '(' then something is malformed, move on if(lookAhead != '(') {continue;} // Go back to before the open paren fseek(fp, -1, SEEK_CUR); // Try to read in a particle tempParticle = avail[loq-1]; if((charsRead = fscanf(fp, "(%f %f %d %d %c %d)", &(a_x[tempParticle]), &(a_y[tempParticle]), &(a_xVel[tempParticle]), &(a_yVel[tempParticle]), &(a_heat[tempParticle]), &elementIndex)) == EOF || charsRead < 6) {continue;} // We succeeded, so decrement loq to remove the particle from being available loq--; // Save the integral coordinates for writing to allCoords i = (int)(a_x[tempParticle]); j = (int)(a_y[tempParticle]); if (i >= sizeX || j >= sizeY) { return FALSE; } // Keep the element handy if (elementIndex >= numElements) { return FALSE; } tempElement = elements[elementIndex]; // Read in special vals failed = FALSE; // Check that our lookahead is correct if((charsRead = fscanf(fp, "%c", &lookAhead)) != EOF && charsRead == 1 && lookAhead == '[') { int k; for (k = 0; k < fileMaxSpecials; k++) { if((charsRead = fscanf(fp, "%d ", &tempSpecialVal)) == EOF || charsRead < 1) { failed = TRUE; break; } if (k < MAX_SPECIALS) { a_specialVals[tempParticle][k] = tempSpecialVal; } } // Skip past the closing ']' fseek(fp, 1, SEEK_CUR); } else { // Put the lookAhead char back on the stream fseek(fp, -1, SEEK_CUR); failed = TRUE; } // If reading in failed, initialize to cleared if (failed) { clearSpecialValsToElementDefault(tempParticle); } // Set the element and make the particle set a_element[tempParticle] = tempElement; a_set[tempParticle] = TRUE; // Set the allCoords and bitmap color allCoords[getIndex(i, j)] = tempParticle; setBitmapColor(a_x[tempParticle], a_y[tempParticle], tempElement); } return TRUE; } return FALSE; }
/* * Main Game Loop */ int main() { // Use the name of your pixel buffer DMA core pixel_buffer =alt_up_pixel_buffer_dma_open_dev("/dev/pixel_buffer_dma_0"); initVGA(); usleep(5000000); ps2 = alt_up_ps2_open_dev("/dev/ps2_0"); ps2->timeout = 2000000; alt_up_ps2_clear_fifo(ps2); alt_up_ps2_init(ps2); unsigned char byte1; while(alt_up_ps2_read_data_byte(ps2, &byte1)!=0); char_lcd_dev = alt_up_character_lcd_open_dev ("/dev/character_lcd_0"); alt_up_character_lcd_init (char_lcd_dev); char_buffer = alt_up_char_buffer_open_dev("/dev/char_drawer"); alt_up_char_buffer_init(char_buffer); alt_up_sd_card_dev *device_reference = NULL; struct Env* p = initEnv(); initGameInfo(); struct Collidable* collisionChecker = initCollidable(); addCollisionToEnv(p, collisionChecker); promptSDcard(p, device_reference); usleep(1000); alt_up_char_buffer_string(char_buffer, "Loading ", 40, 30); unsigned end_time, start_time; int count = 0; lock = 0; struct animation* starAnimation = loadSDImageSeq("ST0.BMP", 2, 8); struct animation* star2Animation = loadSDImageSeq("ST00.BMP", 3, 7); struct animation* alien0 = loadSDImageSeq("A100.BMP", 2, 2); //2 images where first 2 characters are prefix struct animation* alien1 = loadSDImageSeq("A000.BMP", 2, 15); struct animation* ship0 = loadSDImageSeq("S00.BMP", 2, 16); struct animation* ship1 = loadSDImageSeq("S10.BMP", 2, 27); struct animation* bossAnimate = loadSDImageSeq("BO00.BMP", 2, 28); struct animation* ship2 = loadSDImageSeq("S20.BMP", 2, 35); struct animation* ship3 = loadSDImageSeq("S30.BMP", 2, 30); struct animation* ship4 = loadSDImageSeq("S40.BMP", 2, 10); struct animation* explode1 = initAnimation((int*)explode01, 1); addImage(explode1, initAnimation((int*)explode02, 0)); addImage(explode1, initAnimation((int*)explode03, 0)); addImage(explode1, initAnimation((int*)explode04, 0)); addImage(explode1, initAnimation((int*)explode05, 0)); struct animation** shipAnimationCollection = (struct animation**)malloc(sizeof(struct animation*)*5); shipAnimationCollection[0] = ship0; shipAnimationCollection[1] = ship1; shipAnimationCollection[2] = ship2; shipAnimationCollection[3] = ship3; shipAnimationCollection[4] = ship4; initWeapon(collisionChecker, p); struct Cursor* mouse = initCursor(p, collisionChecker); addToEnv(p, mouse->super); addObjToCollide(collisionChecker, mouse->super); setCursor(p, mouse); struct KeyController* keyController = initKeyController(); struct SwitchController* switchController = initSwitchController(); struct CursorController* ctrl = initCursorController(mouse->super, switchController, keyController); alt_up_char_buffer_string(char_buffer, "Loading Sounds ", 30, 30); audioController = initAudioController(); loadSound( audioController, LOOP_ONE ); loadSound( audioController, LASER_SOUND ); alt_irq_register(AUDIO_IRQ, audioController, (void*) audio_ISR); alt_irq_enable(AUDIO_IRQ); play_background_loop( audioController, LOOP_ONE ); enableAudioController( audioController ); printhex(info.score); mainMenu(mouse, ctrl, p); disableAudioController(audioController); stop_background_loop(audioController); unloadSoundById(audioController, LASER_SOUND); unloadSoundById(audioController, LOOP_ONE); alt_up_char_buffer_string(char_buffer, "Loading Sounds ", 30, 30); //loadSound(audioController, WIN_SOUND); //loadSound(audioController, LOSE_SOUND); loadSound( audioController, TOWER_UPGRADE_SOUND ); loadSound( audioController, LOOP_TWO ); play_background_loop(audioController, LOOP_TWO); enableAudioController( audioController ); alt_up_char_buffer_clear(char_buffer); //usleep(1000); struct Alien* testAlienCollection[60]; gameSetup(p, shipAnimationCollection, mouse, starAnimation, star2Animation); usleep(500000); //time delay for panel to be drawn // char LPS[50]; float lps_; int n = 0; for(n = 0; n < 20; n++) { testAlienCollection[n] =initAlien(n, 10*n, 10, alien0, explode1, "IdontKnow", 1.4, 150, 500, collisionChecker); addToEnvNR(p, testAlienCollection[n]->super); } for(n = 0; n < 20; n++) { testAlienCollection[n+20] =initAlien(10*n, n, 10, alien1, explode1, "whatName", 1.4, 190, 850, collisionChecker); addToEnvNR(p, testAlienCollection[n+20]->super); } for(n = 0; n < 20; n++) { testAlienCollection[n+40] =initAlien(10*n, n, 20, bossAnimate, explode1, "IamBoss", 1.6, 800, 1500, collisionChecker); testAlienCollection[n+40]->score = 300; addToEnvNR(p, testAlienCollection[n+40]->super); } int stage = 0; /* * Game Starts!!!!!! */ alt_alarm_start (&alarm,alt_ticks_per_second(),my_alarm_callback,(void*)p); int startTimer = 0; char second_row1[15]; alt_up_character_lcd_set_cursor_pos(char_lcd_dev, 0, 1); sprintf(second_row1, "wave# %d ", stage); alt_up_character_lcd_string(char_lcd_dev, second_row1); while(1) { alt_timestamp_start(); start_time = (unsigned)alt_timestamp(); /*-----------------------------------------------------------------------------------------------*/ checkCollision(collisionChecker); //a major function that check each collision happen between each object updateCursorController(ctrl, 1); count++; if (startTimer > count) info.startButton = false; else { if(stage == 7) info.isWin = true; else if(startTimer == count){ //play_background_loop(audioController, LOOP_TWO); enableAudioController( audioController ); } } if (info.startButton){ disableAudioController(audioController); //stop_background_loop(audioController); startTimer = count + 15000; checkStages(testAlienCollection, stage%7, collisionChecker); stage++; //if(stage > 6) stage = 0; info.startButton = false; alt_up_character_lcd_set_cursor_pos(char_lcd_dev, 0, 1); sprintf(second_row1, "wave# %d ", stage); alt_up_character_lcd_string(char_lcd_dev, second_row1); } if(info.isEnd || info.isWin) { disableAudioController(audioController); stop_background_loop(audioController); endGame(testAlienCollection, collisionChecker, p, mouse, ctrl, keyController); } /*-----------------------------------------------------------------------------------------------*/ end_time = (unsigned)alt_timestamp(); lps_ = (float)alt_timestamp_freq()/(float)(end_time - start_time); sprintf(LPS, "The current LPS is %.2f", lps_); alt_up_char_buffer_string(char_buffer, LPS, 3, 2); } return 0; }
// JFL 22 Jul 09 // JS 21 Apr 12; Added court, paddles, and ball objects // JS 22 Apr 12; Added many object and collision resolution // JS 24 Apr 12; Implemented winning condition int gameMainLoop() { int errorCode = 0; // in case functions return errors // Game object pointers Camera *cam; HeadsUp *hud; InputController *inpCtrl; Court *court; Paddle *paddles[NUM_PLYRS]; Ball *ball; CollisionController *collCtrl; // // UPDATE // // Get input from Keyboard and QE if(inpCtrl = Game.inpCtrl) { inpCtrl->update(); } // if // Update state of the HUD if(hud = Game.hud) { hud->update(); } // if // Only update game-playing state if currently in play if(Game.inPlay) { // Check collisions if(collCtrl = Game.collCtrl) { collCtrl->update(); } // if // Update and resolve paddles for(int i=0; i<NUM_PLYRS; i++) { if(paddles[i] = Game.paddles[i]) { errorCode = paddles[i]->update(); // Print error if any if (errorCode != 0) { qePrintf("**Error: Paddle%d's *inpCtrl invalid!", i); } // if // Resolve collision of the paddles if(collCtrl && errorCode == 0) { if(collCtrl->phw[i]) { errorCode = collCtrl->resolvePaddle(i); // Print error if any if (errorCode != 0) { qePrintf("**CollCtrl's *xyzPad%d invalid!", i); } // if } // if } // if } // if } // for // Update and resolve ball if(ball = Game.ball) { ball->update(); // Resolve collision of ball if(collCtrl) { if(collCtrl->bhp[IDNX_PLY_1] || // After hitting Player1 collCtrl->bhp[IDNX_PLY_2] || // After hitting Player2 collCtrl->bhhw || // After hitting horizontal walls collCtrl->bhbw) // After hitting side walls { errorCode = collCtrl->resolveBall(); // Print error if any if (errorCode != 0) { qePrintf("**CollCtrl's *xyzBal invalid!"); } // if } // if } // if } // if ball } // if inPlay // // WIN CONDITION CHECK // // Check to see if the game is over (If someone gets 3 points) if(Game.scores[IDNX_PLY_1] == 3 || Game.scores[IDNX_PLY_2] == 3) { // Not the first game anymore, regardless Game.firstGame = false; // Game is not in play anymore (until game is restarted) Game.inPlay = false; // Play game end sound Game.sndId = qeSndPlay(snd[SDR_INDX_STR_END_GAME].name); // Manage scores of each paddle for(int i=0; i<NUM_PLYRS; i++) { // Record last scores Game.lastScores[i] = Game.scores[i]; // Clear scores, to prevent this routine from running concurrently Game.scores[i] = 0; } // for } // if // // RESET CONDITONS // // Implement soft reset (spacebar) if(inpCtrl && inpCtrl->pressedSpace()) { // Play game end sound Game.sndId = qeSndPlay(snd[SDR_INDX_STR_END_GAME].name); // Reposition ball's position if(ball = Game.ball) { ball->xyz.x = 0; ball->xyz.z = 0; } // if // Pause game very briefly qeSleep(0.5); // Manage scores of each paddle for(int i=0; i<NUM_PLYRS; i++) { // Record last scores Game.lastScores[i] = Game.scores[i]; // Clear scores, to prevent this routine from running concurrently Game.scores[i] = 0; // Reset the z-position of each paddle if(paddles[i] = Game.paddles[i]) { paddles[i]->xyz.z = PADDLE_INIT_Z; } // if } // for // Skip rest of game loop goto END_RESET; } // if // Implement hard reset (pressing "1") if(inpCtrl && inpCtrl->pressedOne()) { // Play game end sound Game.sndId = qeSndPlay(snd[SDR_INDX_STR_END_GAME].name); // Pause game qeSleep(1.5); // Reinitialize game gameFinal(); gameInit(); gameSetup(); // Skip rest of game loop goto END_RESET; } // if // // DRAW // // DRAW 3D // set 3D camera if((cam=Game.cam) && !(qeInpButton(QEINPBUTTON_ZERO)&2)) { cam->apply(); // set the camera } // if // DRAW COURT, PADDLES, BALL // Draw court if(court=Game.court) { court->draw(); } // if // Draw paddles for(int i=0; i<NUM_PLYRS; i++) { if(paddles[i] = Game.paddles[i]) { paddles[i]->draw(); } // if } // for // Draw ball if(ball=Game.ball) { ball->draw(); } // if // DRAW HUD qefnSysCamBitmap(); // set camera (also turns off depth testing) if((hud=Game.hud)) { hud->draw(); } // if END_RESET: return 0; } // gameMainLoop()
void Game::gameRun() { gameSetup(); }
void Title::update() { if (c_Easing::isEnd(color_b)) { update_count++; if (update_count == 1) { end_flag = false; next_count = 0; ui.setup(); ui.titleSetup(); gameSetup(); ui.player = entities.getObject<Player>(); ui.enemyholder = entities.getObject<EnemyHolder>(); if (SoundGet.find("TitleBGM")->isEnabled()) SoundGet.find("TitleBGM")->stop(); else SoundGet.find("TitleBGM")->start(); SoundGet.find("TitleBGM")->setLoopEnabled(true); } ui.titleUpdate(); gameUpdate(); //bool set1 //bool set2 //bool set3 //↓のif文の中で引数をtrueにする if (ui.getTutoFirtsFlag()) { if (LEAPHANDS.GetHandCenterPosToRatio().y >= 0.14f || env.isPress(KeyEvent::KEY_0)) { tutorial_flag[0] = true; } } if (tutorial_flag[1] == false) if (ui.getTutoSecondFlag()) { if (player->isCharaDashing()) { tutorial_flag[1] = true; } } if (ui.getTutoThirdFlag()) { if (enemyholder->remainingEnemy() < 4) { tutorial_flag[2] = true; } } } if (end_flag == true && end_count == 1) { ui.ui_data["黒板"]->Active(); ui.ui_data["黒板"]->setEnd(); } if (tutorial) { ui.tuto1(tutorial_flag[0]); if (tutorial_flag[0]) { ui.tuto2(tutorial_flag[1]); } if (tutorial_flag[1]) { ui.tuto3(tutorial_flag[2]); } if (tutorial_flag[2]) { ui.tuto4(end_flag); } } if (env.isPush(KeyEvent::KEY_BACKSPACE)) { SoundGet.find("TitleBGM")->stop(); SoundGet.find("Start")->start(); end_flag = true; } }
void mainLoop() { bool bAllDone = NO; gc_gameState = gSTATE_Frontend; while(!bAllDone) { platBeginFrame(); switch(gc_gameState) { case gSTATE_Frontend: gc_gameState = frontend(); break; case gSTATE_GameSetup: gameSetup(); gc_gameState = gSTATE_LevelSetup; // break; case gSTATE_LevelSetup: levelSetup(); gc_gameState = gSTATE_Play; break; case gSTATE_Play: gc_gameState = gamePlay(YES); break; case gSTATE_Crash: gc_gameState = gSTATE_CrashAnim; // break; case gSTATE_CrashAnim: if(crash(YES)) { if(gc_lives) { --gc_lives; gc_gameState = gSTATE_LevelSetup; } else gc_gameState = gSTATE_GameOver; } break; case gSTATE_ExitLevel: if(exitLevel()) gc_gameState = gSTATE_LevelSetup; break; case gSTATE_GameOver: if(gameOver()) gc_gameState = gSTATE_Frontend; break; case gSTATE_AllDone: bAllDone = YES; break; } platSyncEndFrame(); } }