void main() { initgraph(640, 480); setcaption("贪吃蛇游戏 作者;电子141丶赵磊"); setfont(100,80,"宋体"); xyprintf(90,100,"贪吃蛇"); setfont(20,10,"宋体"); xyprintf(90,350,"暂停:空格键 方向:上 下 左 右"); xyprintf(90,300,"按任意键开始游戏!!! 通关有奖励!!!"); getch(); closegraph(); initgraph(640, 480); rectangle(10,10,500,470); gameplay(); getch(); closegraph(); }
int game() { Window window("R-Type CLIENT"); OnLevel gameplay(gameUpdateHandler); Level level("../Data/level1.xml"); try { srand(time(NULL)); gameplay.loadLevel(&level); gameplay.timer.removeEvent("mobSpawn"); gameplay.timer.removeEvent("meteoraSpawn"); window.attachGameplay(dynamic_cast<IGameplay *>(&gameplay)); window.launchWindow(); while (window.isOpen()) { window.callGameplay(); window.draw(gameplay); } } catch (const RTypeException &err) { std::cerr << "RType Exception: " << err.what() << std::endl; system("pause"); return (1); } catch (const std::exception &err) { std::cerr << "std::exception: " << err.what() << std::endl; system("pause"); return (1); } return (0); }
void showGameplay() { sf::Text gameplay("The goal of the game is too reach and touch the orange FoxBox, which will grant your boxes access to the next\n world. Reaching the FoxBox will be no easy task, as it is protected by a huge amount of red Boxes.\n\nTo accomplish this goal, you must help the green Boxes get past their enemies. The Boxes are equipped with a\nbasic AI to move and fight. But they have no idea where to go, so you need to guide them.\n\nDifferent Boxes possess different attacks and attributes. Normal Boxes can stomp the ground and enemies.\nCharge Boxes can charge a long way in any direction, dealing huge damage to enemies.\nFloat Boxes ignore gravity and can drag away other boxes by activating their sticky function. They can also act as\nsground boxes, so other boxes can use them for advanced movement. Boom Boxes explode in a random radius,\ndealing damage and knocking boxes away. Magic Boxes turn ground boxes into dynamic ones, heal allies, turn\nenemies to neutrals, and neutrals to allies. Ground Boxes in the world that lose all direct connections\n(up/down/left/right) will become dynamic. Most Boxes also have tag charges, which will be used to turn dynamic\nneutral boxes to your team. The neutral box needs to be touched. The charge is then consumed.\n\nYou can directly influence ground and dynamic boxes by right clicking and holding the mouse button. Ground Boxes\ncan be turned to allies, and dynamic boxes can be pushed away. But these actions cost resources, which are\ngained by destroying ground boxes and enemies. Destroying special Boxes grants more resources. You will also\ngain some resources every few seconds, depending on the amount of boxes you command.", font_default, 16); gameplay.setPosition(460, 132); gameplay.setColor(sf::Color::White); window.draw(gameplay); }
int main() { load_configuration_file(); // ŁADOWANIE BIBLIOTEK al_init(); al_init_image_addon(); al_init_primitives_addon(); al_install_keyboard(); al_init_font_addon(); al_init_ttf_addon(); al_install_audio(); al_init_acodec_addon(); al_reserve_samples(100); // WYŚWTIETLANIE EKRANU display.view = NULL; // al_get_display_mode(al_get_num_display_modes() -3, &disp_data); // al_set_new_display_flags(ALLEGRO_FULLSCREEN); display.view = al_create_display(display.width, display.height); // TIMER main_timer = NULL; main_timer = al_create_timer(1.0 / display.FPS); GAME_MODE = MENU; Exit_game = false; al_start_timer(main_timer); while (!Exit_game) { switch (GAME_MODE) { case MENU: menu(); break; case GAMEPLAY: gameplay(); break; case AFTER_GAMEPLAY: menu(); break; default: break; } } al_destroy_display(display.view); al_destroy_timer(main_timer); return 111; }
//-------------------------------------------------------------- // Purpose : Update function // This is the update function // double dt - This is the amount of time in seconds since the previous call was made // // Game logic should be done here. // Such as collision checks, determining the position of your game characters, status updates, etc // If there are any calls to write to the console here, then you are doing it wrong. // // If your game has multiple states, you should determine the current state, and call the relevant function here. // // Input : dt = deltatime // Output : void //-------------------------------------------------------------- void update(double dt) { // get the delta time g_dElapsedTime += dt; g_dDeltaTime = dt; switch (g_eGameState) { case S_SPLASHSCREEN : splashScreenWait(); // game logic for the splash screen break; case S_GAME: gameplay(); // gameplay logic when we are in the game break; } }
int main( int argc, char **argv ) { if (initialiseSDL() == -1) { exit(EXIT_FAILURE); } srand(time(NULL)); Origin origin; Triangle triangle[HEIGHT][HEIGHT]; gameplay(triangle, origin); return 0; }
void update(double dt) { // get the delta time elapsedTime += dt; deltaTime = dt; switch (g_eGameState){ case CLASSSELECT: classSelect(); break; case GAME: gameplay(); break; case PAUSE: pausemenu(); break; case GAMEOVER: gameend(); break; case SPLASH: splashwait(); } }
void main(int argc, char **argv) { Bool printout = false; Bool binary = false; Bool convert = false; int opt; extern int optind; argv0 = argv[0]; while((opt = getopt(argc, argv, "cbp")) != EOF) { switch(opt) { case 'c': convert = true; break; case 'b': binary = true; break; case 'p': printout = true; break; default: usage(); } } if(binary && convert) error("what the hey?"); if (optind < argc) dictname = argv[optind]; print("dict..."); if(binary) initbinary(dictname); else initdict(dictname); if(convert) outbinary(dictname); if(printout) { printdict(root,0); exits(0); } print("board..."); initboard(); print("ready\n"); gameplay(); }
void main() { disable_interrupts(); DISPLAY_OFF; SPRITES_8x8; game_start(); SHOW_BKG; SHOW_SPRITES; DISPLAY_ON; enable_interrupts(); while(1) { wait_vbl_done(); joypad_state = joypad(); gameplay(joypad_state); } }
void DisplayFunc() { //Clear screen glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Main Viewport glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0 , ((float) model->width) / ((float) model->height), 1.0f , 2000.0); glViewport(0 , 0 , model->width, model->height); switch(model->state){ case TITLE: pregame(); break; case MAINMENU: mainMenu(); break; case METAPAUSE: metapause(); break; case MINIPAUSE: minipause(); break; case GAMEPLAY: gameplay(); break; case MINIGAME: minigame(); break; } model->tickCount++; glutSwapBuffers(); }
int main(int argc, char* argv[]) { Result result = NONE; // init ncurses initscr(); noecho(); curs_set(false); // init screen and windows getmaxyx(stdscr, term_size.y, term_size.x); info = newwin(INFO_HEIGHT, term_size.x, 0, 0); field = newwin(term_size.y - INFO_HEIGHT, term_size.x, INFO_HEIGHT, 0); check_term_size(); // init player positions player.x = 1; player.y = term_size.y/2; computer.x = term_size.x-2; computer.y = term_size.y/2; ball.x = term_size.x/2; ball.y = term_size.y/2; // TODO: create user input and ai-computer threads pthread_t userinput; pthread_t computerinput; unsigned char thread_status = 0xAA; pthread_create(&userinput, NULL, THREAD_userinput, (void*) &thread_status); pthread_create(&computerinput, NULL, THREAD_computerai, (void*) &thread_status); // play the game result = gameplay(); // print messages int pos_y = field_size.y/2; if (result == WIN) { int pos_x = (field_size.x-strlen(WIN_MSG))/2; mvwprintw(field,pos_y,pos_x,WIN_MSG); wrefresh(info); wrefresh(field); sleep(2); } else if (result == LOOSE) { int pos_x = (field_size.x-strlen(LOOSE_MSG))/2; mvwprintw(field,pos_y,pos_x,LOOSE_MSG); wrefresh(info); wrefresh(field); sleep(2); } thread_status = 0xFF; delwin(field); delwin(info); endwin(); pthread_cancel(computerinput); pthread_join(computerinput, NULL); perror("COMP joined"); pthread_cancel(userinput); pthread_join(userinput, NULL); perror("USER JOINED"); return 0; }
int main() { FILE *fp; int whr; //weather int diff=2; //variable for difficulty initialized in medium int slct1; //main menu selection int x,y=0,i=1; //loops int totals=50; //total score char name[30]; char c; //gameplay selection loop clearScreen(); printf("\n\t ---Welcome to LEMONADE STAND--- "); printf("\n\tA C version of the original game from the Apple II."); printf("\n\tProgrammed by R"); printf("\n"); printf("\n\tPlease, enter your name: "); scanf(" %[^\n]s", name); while( strlen(name) == 30) { printf("\tSorry, the name is too long. Try again..."); printf("\n\tEnter your name: "); scanf(" %30[^\n]", name); } fp=fopen("scores.txt","a"); int slct; //main menu selection do { printf("\n\t1- Start a new game"); printf("\n\t2- HELP and how to play"); printf("\n\t3- Options"); do{ printf("\n\tEnter: "); scanf(" %i",&slct); //menu entry selection switch(slct) { case 1: //GAME START x=0; break; case 2: //HELP SCREEN helpScreen(x); x=1; clearScreen(); break; case 3: //OPTIONS SCREEN diff=optionsScreen(diff); x=1; clearScreen(); break; default: printf("\tOption not recognised"); x=2; break; } }while(x==2); } while(x==1); clearScreen(); printf("\n\n\t Press ENTER to start the game.\n\tEnjoy and have fun!"); getchar(); getchar(); do{ clearScreen(); printf("\n\tDay %i", i); printf("\n\tMoney: %ic", totals); getchar(); whr = weather(diff); //weather screen totals += gameplay(diff, whr); clearScreen(); printf("\tYour total money is %i", totals); do { printf("\n\tDo you want to continue? (Y/N) "); scanf(" %c", &c); switch(c) { case 'y': case 'Y': y=1; break; case 'n': case 'N': y=0; break; default: printf("\tOption not recognised. Try again..."); y=2; break; } } while (y==2); i+=1; }while(y==1); clearScreen(); printf("\n\tYour total earnings were %i", totals); printf("\n\tIt will be saved to scores.txt"); fprintf(fp, "\n%s --- %i", name, totals); fclose(fp); printf("\n\tThank you for playing!"); printf("\n\n\n\tPress Enter to exit...\n\n"); getchar(); getchar(); return; }
void deal() { d=p=0; srand((unsigned)(time(0))); while (d<2) { dealer[d]=draw(); switch(dealer[d]) { case '2': dealer_sum+=2; break; case '3': dealer_sum+=3; break; case '4': dealer_sum+=4; break; case '5': dealer_sum+=5; break; case '6': dealer_sum+=6; break; case '7': dealer_sum+=7; break; case '8': dealer_sum+=8; break; case '9': dealer_sum+=9; break; case 'T': dealer_sum+=10; break; case 'J': dealer_sum+=2; break; case 'Q': dealer_sum+=3; break; case 'K': dealer_sum+=4; break; case 'A': dealer_sum+=11; break; } d++; player[p]=draw(); switch(player[p]) { case '2': player_sum+=2; break; case '3': player_sum+=3; break; case '4': player_sum+=4; break; case '5': player_sum+=5; break; case '6': player_sum+=6; break; case '7': player_sum+=7; break; case '8': player_sum+=8; break; case '9': player_sum+=9; break; case 'T': player_sum+=10; break; case 'J': player_sum+=2; break; case 'Q': player_sum+=3; break; case 'K': player_sum+=4; break; case 'A': player_sum+=11; break; } p++; } show_table(d,p); gameplay(); }/*=======================================================koniec deal() */