void scoreUpdate() { //check for clash of pawn and bad-ball int i; for(i=0;i<MAXBAD;i++) { if(bad[i].isClash(pawn)) { //game over FIXME: add a good interface for start,stop and restart game gameover=1; gameinit(); } } // clash of good-ball add to point for(i=0;i<MAXGOOD;i++) { if(good[i].isClash(pawn)) { score+=1; printf("%d~\n",score); pawn.setRadius(0.25+(score/10.0)); good[i].init(1); } } }
//--------------------------------------------------------------------------- //Hauptprogramm int main (int argc, char *argv[]) { uv_main::konfig.load_file("config.txt"); uv_main::mainwindow = uv_main::konfig.get_mainwindow_attribute(); uv_main::mainwindow.set_callback(mainloop); uv_main::fps = uv_fpscounter::make_attribut(&uv_main::mainwindow, uv_main::mainwindow.get_w()-100, 0, 0, 0, uv_text::make_attribut(0, 0, 0, 0, 0, 16, "Frames", "Wait...", "Test.ttf", uv_color::make_color(255, 255, 255)),"FPS Counter"); uv_main::menu = uv_container::make_attribut(&uv_main::mainwindow); uv_main::game = uv_container::make_attribut(&uv_main::mainwindow); uv_main::game.set_visible(0); uv_main::menu.set_visible(1); aboutinit(); menueinit(); gameinit(); optionsinit(); // uv_main::options.set_visible(1); // uv_main::mainwindow.set_on_top_widget(&uv_main::options); //TEST /* uv_dropdown drop; vector<string> lolo; lolo.push_back("hellou"); lolo.push_back("hellaau"); lolo.push_back("hilleu"); lolo.push_back("hollau"); drop = uv_dropdown::make_attribut(&uv_main::menu,&uv_main::mainwindow,60,60,200,40,"", lolo, "");*/ ///TEST uv_main::mainwindow.run(); uv_main::konfig.save_file("config.txt"); ki_thread::kill_thread(); return 0; };
// chiude e reinizializza le risorse del gioco void gamereinit() { // chiudo quello che è aperto.. gameclose(); // ..e reinizializzo gameinit(); }
int main(int argc, char const *argv[]) { initscr(); raw(); noecho(); curs_set(0); keypad(stdscr,TRUE); getmaxyx(stdscr,row,col); srand(time(NULL)); if (gameinit()) Winner(); else Loser(); getch(); endwin(); return 0; }
int main() { WINDOW* menuWin; int ch, numAsteroids, maxy, maxx, gameover=0, score=0; spaceship aSpaceship; gameinit(); getmaxyx(stdscr, maxy, maxx); aSpaceship.starty=0.95*maxy; aSpaceship.startx=maxx/2; aSpaceship.height=2; printMenu(menuWin, maxy, maxx, &gameover, &numAsteroids); asteroid Asteroids[numAsteroids]; makeAsteroid(Asteroids, numAsteroids, maxy, maxx); while (ch != KEY_F(1) && gameover==0) { clear(); moveSpaceship(&aSpaceship, &ch, maxx); createSpaceship(&aSpaceship); moveAsteroid(Asteroids, maxy, maxx, numAsteroids); attron(COLOR_PAIR(4)); mvprintw(2, maxx-10, "%s", "SCORE:"); mvprintw(3, maxx-10, "%d", score++); attroff(COLOR_PAIR(4)); wrefresh(stdscr); usleep(DELAY); gameover=checkGameover(Asteroids, aSpaceship, numAsteroids); } while (ch != KEY_F(1)) { gameoverScreen(score, &ch); } endwin(); }
int main(int argc,char **argv) { scrwidth=640; scrheight=480; glutInit(&argc,argv); glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE); glutInitWindowSize(scrwidth,scrheight); glutInitWindowPosition(50,50); glutCreateWindow("ClearBall"); init(); gameinit(); glutDisplayFunc(game); glutPassiveMotionFunc(pawnupdate); glutTimerFunc(500,ballupdate,0); glutReshapeFunc(resize); glutSetCursor(GLUT_CURSOR_NONE); glutMainLoop(); }
int main() { gameinit(); Print("start\n", 0, 0); gameloop(); }
int main(int argc, char* argv[]) { // inizializzazione gameinit(); // main loop while (!quit) { SDL_Event e; // processo eventi SDL short newinput = 0; while (SDL_PollEvent(&e)) { switch (e.type) { case SDL_QUIT: quit = 1; break; case SDL_VIDEORESIZE: if(gameState == GAME_STOPPED) { // il resize a partita in corso non è supportato, // si ridimensiona solo a partita terminata scrW = e.resize.w; scrH = e.resize.h; gamereinit(); } break; } // aggiorno eventuale input newinput = getInput(&e, &input, scrW, scrH); } // nessun altro evento: procedo con simulazione if (newinput) { // c'è del nuovo input: lo processo if (gameState == GAME_RUNNING) { if (queryKey(&input, KM_CONTROL, ESC)) { // ESCAPE e gioco in corso: pausa gameState = GAME_PAUSED; } } else { updateMenu(&input); } } Uint32 timeNow = SDL_GetTicks(); while (nstep * PHYS_SAMPLING_STEP < timeNow) { nstep++; if (gameState == GAME_RUNNING) updateScene(&input); if(!newinput) { // piccolo hack: se non arrivano eventi non ho modo di sapere che il // mouse si è fermato! Occorre far decadere col tempo le coordinate relative if(input.keys.value[TRIG_RIGHT_HORZ] == 0) input.cursor.xRel *= 0.87f; if(input.keys.value[TRIG_RIGHT_VERT] == 0) input.cursor.yRel *= 0.87f; } } // disegno nuovo frame renderFrame(); } //main loop // chiudi tutto gameclose(); return 0; }