//Draws Screen based On Menu Code void drawMenu(bool gettingName, string inputText, const Uint8* keyState){ glEnable2D(); glColor3f(1, 1, 1); glBindTexture(GL_TEXTURE_2D, mTexture[0]); glBegin(GL_QUADS); glTexCoord2d(0, 1); glVertex3d(0, 720, 0); glTexCoord2d(1, 1); glVertex3d(1280, 720, 0); glTexCoord2d(1, 0); glVertex3d(1280, 0, 0); glTexCoord2d(0, 0); glVertex3d(0, 0, 0); glEnd(); glColor3f(0, 0, 0); glRenderText(title, 0, 0, 0, 310, 560, "DOOM in a Room"); if(gettingName) name(inputText); if(!gettingName){ if(keyState[SDL_SCANCODE_M]) menuCode = "menu"; if(menuCode == "menu") menu(); if(keyState[SDL_SCANCODE_H]) menuCode = "highscores"; if(menuCode == "highscores") highscores(); if(keyState[SDL_SCANCODE_C]) menuCode = "controls"; if(menuCode == "controls") controls(); } glDisable2D(); }
void MainWindow::setupActions() { KStandardGameAction::gameNew(m_main, SLOT(newGame()), actionCollection()); KStandardGameAction::restart(m_main, SLOT(restart()), actionCollection()); KStandardGameAction::highscores(m_main, SLOT(highscores()), actionCollection()); KStandardGameAction::quit(this, SLOT(close()), actionCollection()); QAction* action; action = new QAction(i18n("&Single Player"), this); action->setIcon(QIcon::fromTheme( QLatin1String( SimpleMenu::iconLocal))); actionCollection()->addAction(QLatin1Literal("game_local"), action); connect(action, &QAction::triggered, m_main, &PlayField::localGame); action = new QAction(i18n("&Host Game..."), this); action->setIcon(QIcon::fromTheme( QLatin1String( SimpleMenu::iconServer))); actionCollection()->addAction(QLatin1Literal("game_create_server"), action); connect(action, &QAction::triggered, m_main, &PlayField::createServer); action = new QAction(i18n("&Connect to Game..."), this); action->setIcon(QIcon::fromTheme( QLatin1String( SimpleMenu::iconClient))), actionCollection()->addAction(QLatin1Literal("game_create_client"), action); connect(action, &QAction::triggered, m_main, &PlayField::createClient); // settings action = new QAction(i18n("Change &Nickname..."), this); actionCollection()->addAction(QLatin1Literal("options_nickname"), action); connect(action, &QAction::triggered, m_main, &PlayField::changeNick); action = new KToggleAction(i18n("&Play Sounds"), this); action->setChecked(Settings::enableSounds()); actionCollection()->addAction(QLatin1Literal("options_sounds"), action); connect(action, &QAction::triggered, m_main, &PlayField::toggleSounds); // This action will be disabled when a game is being run action = new KToggleAction(i18n("&Adjacent Ships"), this); action->setChecked(Settings::adjacentShips()); actionCollection()->addAction(QLatin1Literal("options_adjacent"), action); connect(action, &QAction::triggered, m_main, &PlayField::toggleAdjacent); // This action will be disabled when a game is being run action = new KToggleAction(i18n("&Multiple Ships"), this); action->setChecked(Settings::severalShips()); actionCollection()->addAction(QLatin1Literal("options_multiple_ships"), action); connect(action, &QAction::triggered, m_main, &PlayField::toggleMultiple); // config end of game message action = new KToggleAction(i18n("Show End-of-Game Message"), this); action->setChecked(true); actionCollection()->addAction(QLatin1Literal("options_show_endgame_message"), action); connect(action, &QAction::triggered, m_main, &PlayField::toggleEndOfGameMessage); // actions for grid action = new KToggleAction(i18n("Show &Left Grid"), this); action->setChecked(true); actionCollection()->addAction(QLatin1Literal("options_showleftgrid"), action); connect(action, &QAction::triggered, m_main, &PlayField::toggleLeftGrid); action = new KToggleAction(i18n("Show &Right Grid"), this); action->setChecked(true); actionCollection()->addAction(QLatin1Literal("options_showrightgrid"), action); connect(action, &QAction::triggered, m_main, &PlayField::toggleRightGrid); setupGUI(); }
// Updates all nescessary sprites, images, buttons etc. void update(void) { static _Bool called = false; GDATAPTR game = get_game_data(); update_background(); if(game->gamestarted && game->paused) { paused(score, survival_time, lives); } else if(lives == 0) { gameover(score, survival_time); } else if(game->gamestarted) { if(!called) { //cpSpaceResizeStaticHash(get_global_cpSpace(), 700.0, 4*10); cpSpaceAddCollisionHandler(get_global_cpSpace(), 1, 2, collision_begin, NULL, NULL, NULL, NULL); cpSpaceAddCollisionHandler(get_global_cpSpace(), 0, 2, collision_static_begin, NULL, NULL, NULL, NULL); cpSpaceAddCollisionHandler(get_global_cpSpace(), 0, 1, collision_static_begin, NULL, NULL, NULL, NULL); called = false; } logic(); update_clouds(); cpSpaceStep(get_global_cpSpace(), 1.0f/60.0f); cpSpaceEachBody(get_global_cpSpace(), &update_sprites, NULL); update_ground(); update_lives(); add_element_to_render_queue(NULL, 0, 0, 0, RCOLOR(0, 0, 0, 255), update_score); add_element_to_render_queue(NULL, 290, 0, 0, RCOLOR(0, 0, 0, 255), update_survivaltime); } else if(game->options) { options(); } else if(game->howtoplay) { howtoplay(); } else if(game->highscores) { highscores(); } }
void MainWindow::setupActions() { KStandardGameAction::gameNew(m_main, SLOT(newGame()), actionCollection()); KStandardGameAction::restart(m_main, SLOT(restart()), actionCollection()); KStandardGameAction::highscores(m_main, SLOT(highscores()), actionCollection()); KStandardGameAction::quit(this, SLOT(close()), actionCollection()); KAction* action; action = new KAction(KIcon( QLatin1String( SimpleMenu::iconLocal) ), i18n("&Single Player"), this); actionCollection()->addAction("game_local", action); connect(action, SIGNAL(triggered()), m_main, SLOT(localGame())); action = new KAction(KIcon( QLatin1String( SimpleMenu::iconServer) ), i18n("&Host Game..."), this); actionCollection()->addAction("game_create_server", action); connect(action, SIGNAL(triggered()), m_main, SLOT(createServer())); action = new KAction(KIcon( QLatin1String( SimpleMenu::iconClient) ), i18n("&Connect to Game..."), this); actionCollection()->addAction("game_create_client", action); connect(action, SIGNAL(triggered()), m_main, SLOT(createClient())); action = new KAction(i18n("Change &Nickname..."), this); actionCollection()->addAction("options_nickname", action); connect(action, SIGNAL(triggered()), m_main, SLOT(changeNick())); action = new KToggleAction(i18n("&Play Sounds"), this); actionCollection()->addAction("options_sounds", action); connect(action, SIGNAL(triggered(bool)), m_main, SLOT(toggleSounds(bool))); // config end of game message action = new KToggleAction(i18n("Show End-of-Game Message"), this); action->setChecked(true); actionCollection()->addAction("options_show_endgame_message", action); connect(action, SIGNAL(triggered(bool)), m_main, SLOT(toggleEndOfGameMessage(bool))); // actions for grid action = new KToggleAction(i18n("Show &Left Grid"), this); action->setChecked(true); actionCollection()->addAction("options_showleftgrid", action); connect(action, SIGNAL(triggered(bool)), m_main, SLOT(toggleLeftGrid(bool))); action = new KToggleAction(i18n("Show &Right Grid"), this); action->setChecked(true); actionCollection()->addAction("options_showrightgrid", action); connect(action, SIGNAL(triggered(bool)), m_main, SLOT(toggleRightGrid(bool))); setupGUI(); }
int level(int pnts, int lvl){ CROCCAT_Talk roccat; roccat.set_ryos_kb_SDKmode(TRUE); if(lvl<LVLANZAHL){ //passiert nix, da noch nicht genügend level erreicht wurden if(pnts< grenze*factor){ return 0; } else{ // schowOnScreen("Congrats, Level %d beaten",lvl); // Textausgabe an bildschrim (printf??) roccat.All_Key_Blinking(300,100); // Heroisches blinken der Tastatur für 3 Sekunden lvl++; grenze=(int)pnts+(grenze*factor); // grenze fürs nächste Level wird erhöht // eraseScreen(); // alle objekte vom schirm löschen, extern definiert // newScreen(); // neue objekte auf den schirm setzen, extern definiert /* ############################################## ## Brauchts das in dieser Datei?? ############## ################################################## switch (lvl){ case 1: // hier beschreibung für lvl 1 break; case 2: // hier für lvl 2 break; case 3: // ... break; } #################################################### */ } } // game vorbei, da level 20 besiegt wurde else{ // schowOnScreen("Congrats, you won the game",lvl); // Textausgabe an bildschrim (printf??) roccat.All_Key_Blinking(300,1000); // Heroisches blinken der Tastatur für 30 Sekunden highscores(pnts); // schreibt die Punkte in Highscore-liste return 1; } roccat.set_ryos_kb_SDKmode(FALSE); }
void MainWindow::setupActions() { // TODO #ifndef Q_OS_QNX // Game KAction* abort = actionCollection()->addAction("game_abort"); abort->setText(i18n("Abort game")); connect(abort, SIGNAL(triggered()), m_main, SLOT(abort())); KStandardGameAction::pause(m_main, SLOT(togglePause()), actionCollection()); KStandardGameAction::highscores(this, SLOT(highscores()), actionCollection()); KStandardGameAction::quit(this, SLOT(close()), actionCollection()); KAction* action; action = new KToggleAction(i18n("&Play Sounds"), this); action->setChecked(KollisionConfig::enableSounds()); actionCollection()->addAction("options_sounds", action); connect(action, SIGNAL(triggered(bool)), m_main, SLOT(enableSounds(bool))); setupGUI(Create | Save | Keys | StatusBar); #endif }
highlight() { if(high==1) { if(prevhigh==2) { ozfilledbox(0,29,102,10,2); } if(prevhigh==5) { ozfilledbox(0,59,102,10,2); } ozfilledbox(0,19,102,10,2); } if(high==2) { if(prevhigh==1) { ozfilledbox(0,19,102,10,2); } if(prevhigh==3) { ozfilledbox(0,39,102,10,2); } ozfilledbox(0,29,102,10,2); } if(high==3) { if(prevhigh==2) { ozfilledbox(0,29,102,10,2); } if(prevhigh==4) { ozfilledbox(0,49,102,10,2); } ozfilledbox(0,39,102,10,2); } if(high==4) { if(prevhigh==3) { ozfilledbox(0,39,102,10,2); } if(prevhigh==5) { ozfilledbox(0,59,102,10,2); } ozfilledbox(0,49,102,10,2); } if(high==5) { if(prevhigh==4) { ozfilledbox(0,49,102,10,2); } if(prevhigh==1) { ozfilledbox(0,19,102,10,2); } ozfilledbox(0,59,102,10,2); } switch(ozngetch()) { case KEY_DOWN: case KEY_PAGEDOWN: { if(high<5) { high+=1; prevhigh=(high-1); highlight(); break; } if(high==5) { high=1; prevhigh=5; highlight(); break; } highlight(); break; } case KEY_UP: case KEY_PAGEUP: { if(high>1) { high-=1; prevhigh=(high+1); highlight(); break; } if(high==1) { high=5; prevhigh=1; highlight(); break; } highlight(); break; } case KEY_LOWER_ENTER: case KEY_UPPER_ENTER: { if(high==1) { playsound(); play(); } if(high==2) { highscores(); } if(high==3) { keys(); } if(high==4) { option(); } if(high==5) { exit(0); } break; } case KEY_LOWER_ESC: case KEY_UPPER_ESC: exit(0); case KEY_LOWER_MENU: keys(); case '1': { playsound(); play(); } case '2': highscores(); break; case '3': keys(); case '4': option(); case '5': exit(0); case KEY_NEWLINE: ozsnap(); break; } main(); }
void newgame() { char d; short i; running = 1; nbullets = cmax / 2; nbugs = 5; if(getlives()) lives = getlives(); else { int fl = senddiff(); if(fl == 1) lives = 15; else if(fl == 2) lives = 10; else if(fl == 3) lives = 8; } if(lives == 0) lives = 15; // lives = 5;//Kitni baar takraye then game over score = 0; level = 25; levels = 1; /*arrow.r and .c are positions of the gun on teh window rows and colmsms*/ arrow.r = rmax / 2; arrow.c = cmax - 3; arrow.w = 3;//width arrow.h = 7;//height arrow.str = " * \n" " ** \n" "*** \n" " \n" "*** \n" " ** \n" " * \n"; bullets = malloc(nbullets * sizeof(object)); for (i = 0; i < nbullets; i++) { newbullet(&bullets[i], 0, 0); } bugs = malloc(nbugs * sizeof(object)); for (i = 0; i < nbugs; i++) { newbug(&bugs[i]); } drawmessage("SEGFAULT SHOOTER", -3); drawmessage("Stop the SEGFAULTS from getting past you", -1); drawmessage("Arrow keys to move, space to shoot", 0); drawmessage("Q to exit", 1); drawmessage("Anything else to start", 2); d = getch(); if (d == 'q') { return; } /*Enables the keyboard arrow keys*/ pthread_t pth; pthread_create(&pth, NULL, input, "get keys"); game(); pthread_cancel(pth); clear(); /* This is printed on the window when game is over*/ drawmessage("Game Over", -1); char string[10] = {'\0'}; sprintf(string, "%d", score); drawmessage(string, 0); drawmessage("Return to continue", 2); while ((d = getch()) && d != '\n') if (d == 'q') return; clear(); highscore(); clear(); highscores(); while ((d = getch()) && d != '\n') if (d == 'q') return; }