int main(int argc, char** argv) { std::list<std::string> args(argv, argv + argc); showIntro(); parseArguments(args); findDataDirectory(); const EGLint configAttrs[] = { EGL_BUFFER_SIZE, options.bitsPerPixel, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NONE }; const EGLint configAttrs32[] = { EGL_BUFFER_SIZE, 32, EGL_NONE }; const EGLint contextAttrs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; int winWidth = 800; int winHeight = 480; const float w = winWidth, h = winHeight; EGLConfig config32 = 0; EGLint configCount = 0; bool result = nativeCreateDisplay(&ctx.nativeDisplay); ASSERT(result); nativeGetScreenSize(ctx.nativeDisplay, &winWidth, &winHeight); result = initializeEgl(winWidth, winHeight, configAttrs, contextAttrs); ASSERT(result); eglChooseConfig(ctx.dpy, configAttrs32, &config32, 1, &configCount); if (!configCount) { printf("32bpp config not found\n"); } glPixelStorei(GL_UNPACK_ALIGNMENT, 1); ASSERT_GL(); #define ADD_TEST(TEST) runTest(*std::auto_ptr<Test>(new TEST)); #include "tests.inl" #undef ADD_TEST terminateEgl(); }
int main() { char key = 'n', str[10]; int i, score, lives, wandX, playCount, bodyCount, speed; int counts[14][38]; Centipede centipedes[6]; int sparkXs[14]; printf("Speed for demo (1 = fast, 9 = slow): "); scanf("%d", &speed); speed *= 100; init(); bodyCount = score = 0; lives = 3; wandX = 17; showIntro(); startNewScreen(centipedes, counts, sparkXs, score, wandX, &bodyCount); while (key != QUIT) { if(play(centipedes, sparkXs, counts, &score, &lives, &playCount, &bodyCount)) { do { key = getKey(); if (key == RIGHT || key == LEFT) moveWand(key, &wandX); else if(key == ' ') fireWand(wandX, sparkXs); } while(advanceTime(speed) && key != QUIT); } // if not killed and still a centipede after moving spark and centipede else // life lost or last centipede part shot intermission(centipedes, &bodyCount, wandX, lives, &key); } // while key != QUIT return 0; } // main()
int main() { char key = 'n'; int score, speed; Tetromino tetromino; printf("Speed for demo (1 = fast, 9 = slow): "); scanf("%d", &speed); speed *= 100; printf("Seed: "); scanf("%d", &seed); init(); score = 0; showIntro(); startNewScreen(score, &tetromino); while (key != QUIT) { if(play(&score, &tetromino)) { do { key = getKey(); if (key == RIGHT || key == LEFT || key == UP || key == DOWN) changeTetromino(&tetromino, key); } while(advanceTime(speed) && key != QUIT); } // if not killed and still a centipede after moving spark and centipede else // tetromino cannot move { intermission(); startNewScreen(score, &tetromino); } } // while key != QUIT return 0; } // main()
int main(int argc, char *argv[]) { allegInitializations(); loadEssentials(); int i = 0; MENUBUTTON aButton[5]; initializeButton(&aButton[0], 359, 356, 305, 55, "Menu_Images/Check Box.bmp"); initializeButton(&aButton[1], 359, 432, 305, 55, "Menu_Images/Check Box.bmp"); initializeButton(&aButton[2], 359, 507, 305, 55, "Menu_Images/Check Box.bmp"); initializeButton(&aButton[3], 359, 583, 305, 55, "Menu_Images/Check Box.bmp"); initializeButton(&aButton[4], 359, 659, 305, 55, "Menu_Images/Check Box.bmp"); int buttonClicked = 0; menuBuffer = create_bitmap(1024,768); BITMAP *menuBackground[7]; menuBackground[0] = makeBitmap("Menu_Images/Menu Background 04.bmp"); menuBackground[1] = makeBitmap("Menu_Images/Menu Background 05.bmp"); menuBackground[2] = makeBitmap("Menu_Images/Menu Background 06.bmp"); menuBackground[3] = makeBitmap("Menu_Images/Menu Background 07.bmp"); menuBackground[4] = makeBitmap("Menu_Images/Menu Background 08.bmp"); menuBackground[5] = makeBitmap("Menu_Images/Menu Background 09.bmp"); menuBackground[6] = makeBitmap("Menu_Images/Menu Background 10.bmp"); BITMAP *highlighter = makeBitmap("Menu_Images/Menu Selector.bmp"); // Load our picture BITMAP *mouse = makeBitmap("Menu_Images/Mouse.bmp"); // Load our picture BITMAP *mouseH = makeBitmap("Menu_Images/MouseH.bmp"); // Load our picture SAMPLE *menuClick[5]; menuClick[0] = makeSample("Menu_Sounds/Menu Select 1.wav"); menuClick[1] = makeSample("Menu_Sounds/Menu Select 2.wav"); menuClick[2] = makeSample("Menu_Sounds/Menu Select 3.wav"); menuClick[3] = makeSample("Menu_Sounds/Menu Select 4.wav"); menuClick[4] = makeSample("Menu_Sounds/Menu Select 5.wav"); double startTime = 0; SAMPLE *menuButtonClick[5]; menuButtonClick[0] = makeSample("Menu_Sounds/New Game.wav"); menuButtonClick[1] = makeSample("Menu_Sounds/Load Game.wav"); menuButtonClick[2] = makeSample("Menu_Sounds/Options.wav"); menuButtonClick[3] = makeSample("Menu_Sounds/Credits.wav"); menuButtonClick[4] = makeSample("Menu_Sounds/Quit Game.wav"); SAMPLE *menuAmbient = makeSample("Menu_Sounds/Menu Ambient.wav"); int randomizer = 0; srand(time(0)); showIntro(); draw_sprite(menuBuffer, menuBackground[0], 0, 0); draw_sprite(menuBuffer, highlighter, 6, 186); blit(menuBuffer, screen, 0,0,0,0,1024,768);//Draw the buffer to the screen play_sample(menuAmbient, 255, 0, 1000, 1); while (true) { if (fireCounter != fireCheck) { randomizer = rand() % 7; fireCheck = fireCounter; } draw_sprite(menuBuffer, menuBackground[randomizer], 0, 0); draw_sprite(menuBuffer, mouse, mouse_x, mouse_y); if (mouse_b) { draw_sprite(menuBuffer, mouseH, mouse_x, mouse_y); for (i = 0; i <= 4; i++) { if (menu_mouseIsOver(&aButton[i])) { buttonClicked = i; } } switch (buttonClicked) { case 0: play_sample(menuButtonClick[0], 200, 0, 1000, 0); stop_sample(menuClick[randomizer]); stop_sample(menuAmbient); goToNewGameMenu(); play_sample(menuAmbient, 255, 0, 1000, 1); buttonClicked = -1; break; case 1: play_sample(menuButtonClick[1], 200, 0, 1000, 0); //loadGame(); break; case 2: play_sample(menuButtonClick[2], 200, 0, 1000, 0); break; case 3: play_sample(menuButtonClick[3], 50, 0, 1000, 0); break; case 4: stop_sample(menuAmbient); play_sample(menuButtonClick[4], 255, 0, 1000, 0); startTime = time(0); while (startTime + 4 > time(0)) { } return 0; break; default: stop_sample(menuClick[randomizer]); randomizer = rand() % 5; play_sample(menuClick[randomizer], 255, 0, 500, 0); break; } } else { buttonClicked = -1; } blit(menuBuffer, screen, 0,0,0,0,1024,768);//Draw the buffer to the screen clear_bitmap(menuBuffer); // Clear the contents of the buffer bitmap } }END_OF_MAIN()