int main() { /*----------------------------------- main function -----------------------------------*/ int start_games=1; int i=0; int x=8; // x좌표 키값받아서 움직임( 기본값 : 8 ) srand((unsigned)time(NULL)); setcursortype(NOCURSOR); StartScreen(); for(i=0;i<1001; i++) { check_crash(); if(stop==1||start_games==1) { // 블럭 충돌시 또는 게임 시작 시 block_type=rand()%7; x=8; new_block(x,block_height); // 기본위치에 블럭 생성 start_games=0; stop=0; } if(i==10){ i=0; Sleep(10); if(stop==0){ block_height+=1; } } new_block(x,block_height); Sleep(10); } getch(); return 0; }
int main() { PA_Init(); // Initializes PA_Lib // PA_InitVBL(); // Initializes a standard VBL PA_VBLFunctionInit(AS_SoundVBL); AS_Init(AS_MODE_MP3 | AS_MODE_SURROUND | AS_MODE_16CH); AS_SetDefaultSettings(AS_PCM_8BIT, 11025, AS_SURROUND); PA_LoadDefaultText(1, 0); StartScreen(); CreateTasks(); initMap(map); vTaskStartScheduler(); // Never returns while (1) ; return 0; }
int main(argc, argv) { Player *player; int i, j; /* Initialize the screen. */ initscr(); /* Resize the window to 16x64 and set it to scroll. */ wresize(stdscr, 16, 64); scrollok(stdscr, TRUE); /* Seed the random number generator. */ srand(time(NULL)); /* Display the game start screen. */ StartScreen(); /* Set up game options. */ GameSetupScreen(); /* Run game until it's over. */ while (!gameOver) { /* Start a new year. */ NewYearScreen(); /* Go through each player. */ for (i = 0; i < COUNTRY_COUNT; i++) { /* Get player. */ player = &(playerList[i]); /* Skip dead players. */ if (player->dead) continue; /* Play as human or CPU. */ if (player->human) PlayHuman(player); else PlayCPU(player); /* Stop if game over. */ if (gameOver) break; } /* Stop if game over. */ if (gameOver) break; /* Display summary. */ SummaryScreen(); } /* End nCurses. */ endwin(); return 0; }
int main(){ int gd=DETECT, gm; int Return=0; char Key, ScanCode; int Counter=0; //Divide total delay & take multiple input initgraph(&gd, &gm,"c:\\tc\\bgi"); //initialize graphics mode randomize(); //Randomize block's shapes & color cleardevice(); //clear screen InitPalette(); //for setting color pallete InitMatrix(); //Initialize Matrix GetImages(); //Saving the images StartScreen(); //for start screen cleardevice(); //clear screen AssignShape(GetRandomShape(), GetRandomColor()); //for the falling block NextShape=GetRandomShape(); NextColor=GetRandomColor(); DisplayScreen(); //Show main screen DisplayNextShape(); //show next brick MoveBlock(LEFT); //keep the block on center & check game over while(kbhit()) getch(); //empty the keyboard input while (!Quit && !GameOver) { //Moving the blocks down if(++Counter >= Speed) //For controling the speed { Counter=0; MoveBlock(DOWN); SoundDrop(); } if(kbhit()) //For the arrow keys { Key = getch(); if(Key == 0) { ScanCode = getch(); if(ScanCode == KEY_UP) RotateBlock(); else if(ScanCode == KEY_LEFT) MoveBlock(LEFT); else if(ScanCode == KEY_RIGHT) MoveBlock(RIGHT); else if(ScanCode == KEY_DOWN) { Score++; //increase score PrintScore(); MoveBlock(DOWN); } if(!Return) SoundDrop(); Return = 0; } else if(Key == KEY_ENTER || Key == KEY_SPACE) //Rotating bricks RotateBlock(); else if(Key == 'P' || Key == 'p') //For pause { MessageBox(" Paused"); while(kbhit()) getch(); //clear the keyboard input for(int x=0; x<COLS; x++) for(int y=0; y<ROWS; y++) PreviousScreenLayout[x][y] -= 1; //Clear the present screen layout to refresh the whole screen UpdateScreen(); //refresh screen } else if(Key == KEY_ESC) //For quit { char ret = MessageBox("Are you sure, you want to Quit?", 563, 2); if(ret == 'y' || ret == 'Y' || ret == KEY_ENTER) { Quit = 1; break; } cleardevice(); //Clear the message box while(kbhit()) getch(); //Clear the keyboard input for(int x=0; x<COLS; x++) for(int y=0; y<ROWS; y++) PreviousScreenLayout[x][y] -= 1; // Clear the present screen layout to refresh the whole screen UpdateScreen(); //refresh screen DisplayScreen(); //show the main screen again DisplayNextShape(); //show next brick box } else if(Key == 's' || Key == 'S') //For sound on/off { SoundOn = !SoundOn; } else if(Key=='a' || Key=='A') //For author { MessageBox("Author: Aguntuk Group",450); cleardevice(); //Clear the message box while(kbhit()) getch(); //Clear the keyboard input for(int x=0;x<COLS;x++) for(int y=0;y<ROWS;y++) PreviousScreenLayout[x][y] -=1; //Clear the present screen layout to refresh the whole screen UpdateScreen(); //refresh screen DisplayScreen(); //show the main screen again DisplayNextShape(); //show next brick box } } delay(6); //For moving down the blocks slowly } if(GameOver) //For game over option { DisplayBlock(6,0); //For display the top most brick ShowGameOver(); //For display game over message box } restorecrtmode(); //For closing graphicg mode return 0; }