/*********************************************************************** ; Name: startMatch ; Description: This function is the main game loop. All player movement ; and scorekeeping has to be performed inside this loop. ;***********************************************************************/ void startMatch(void) { char quit = 0; writeBackground(selected_field); display_character(&player0); display_character(&player1); while (!quit) { if (hCnt > HSYNCHIGH || hCnt < HSYNCLOW) { // update horizontal and vertical velocity for player 0 updateVelAcc(&player0,joy0hor,joy0ver); updateVelAcc(&player1,joy1hor,joy1ver); // check for jumping. checkPlayerJump(&player0); checkPlayerJump(&player1); // TEMPORARY EXIT CONDITION //if (player0.attacking == 2) // pushbutton 2 pressed //{ // quit = 1; //} // attack for player player0.attack(&player0); player1.attack(&player1); // move player (it can be any function) player0.move(&player0); player1.move(&player1); // display the character at his location //display_character(&player0); displayLives(); displayDamage(); quit = quit || checkDeath(&player0); quit = quit || checkDeath(&player1); } } // reset player lives and other values player0.lives = 5; player1.lives = 5; player0.damage = 0; player1.damage = 0; }
int main(int argc, const char * argv[]) { char str[] = ""; int r = 0; int c = 0; printf("Enter a string: "); scanf("%99[^\n]",str); printf("Enter row position: "); scanf("%d", &r); printf("Enter col position: "); scanf("%d", &c); display_character(str,r,c); return(0); }
/*********************************************************************** ���� � ������ �� ; TIM interrupt service routine (If needed!) ; ; Make sure you add it to the interrupts vector table (VECTOR 15 TIM_ISR) ; under: Project Settings/Linker Files/Project.PRM ;***********************************************************************/ interrupt 8 void TIM_ISR(void) { // set TFLG1 bit TFLG1 = TFLG1 | 0x01; // increment the counter for TC0 (it should wrap around and create reliable interrupt rate) TC0 += 15000; // No need to add anything in the .PRM file, the interrupt number is included above // handle splash screen logic if (splash_screen_enable < TIMEFORONESECOND) { splash_screen_enable++; } // If game is in progress.... if (selection == 3 && select == 1) { // ################################# // set player0 velocity update flag // ################################# if (player0.horacc != 0) { player0.horacccnt++; if (player0.horacccnt >= abs(player0.horacc) ) { // need to update velocity up/down //bset(player0.moveflag, VELRI); player0.movehor_v = 1; // restart count player0.horacccnt = 0; } } if (player0.veracc != 0) { player0.veracccnt++; if (player0.veracccnt >= abs(player0.veracc) ) { // need to update velocity left/right //bset(player0.moveflag, VELUP); player0.movever_v = 1; player0.veracccnt = 0; } } // set player0 movement flag if (player0.horvel != 0) { player0.horvelcnt++; if (player0.horvelcnt >= abs(player0.horvel) ) { //bset(player0.moveflag, MOVERI); player0.movehor_r = 1; player0.horvelcnt = 0; } } if (player0.vervel != 0) { player0.vervelcnt++; if (player0.vervelcnt >= abs(player0.vervel) ) { //bset(player0.moveflag, MOVEUP); player0.movever_r = 1; player0.vervelcnt = 0; } } // ############################ // player 1 acceleration values // ############################ if (player1.horacc != 0) { player1.horacccnt++; if (player1.horacccnt >= abs(player1.horacc) ) { // need to update velocity up/down //bset(player1.moveflag, VELRI); player1.movehor_v = 1; // restart count player1.horacccnt = 0; } } if (player1.veracc != 0) { player1.veracccnt++; if (player1.veracccnt >= abs(player1.veracc) ) { // need to update velocity left/right //bset(player1.moveflag, VELUP); player1.movever_v = 1; player1.veracccnt = 0; } } // set player1 movement flags if (player1.horvel != 0) { player1.horvelcnt++; if (player1.horvelcnt >= abs(player1.horvel) ) { //bset(player1.moveflag, MOVEUP); player1.movehor_r = 1; player1.horvelcnt = 0; } } if (player1.vervel != 0) { player1.vervelcnt++; if (player1.vervelcnt >= abs(player1.vervel) ) { //bset(player1.moveflag, MOVERI); player1.movever_r = 1; player1.vervelcnt = 0; } } // handle player0 attacking mode if (player0.attacking) { player0.attackcount++; if (player0.attackcount > player0.attacklength) { // reset the attack direction. player0.attackdirection = 0; // reset the attack count player0.attackcount = 0; // set attack length back to default player0.attacklength = DEFAULTATTACKLENGTH; // transition out of attacking mode player0.attacking = 0; } } // handle player 1 attacking mode if (player1.attacking) { player1.attackcount++; if (player1.attackcount > player1.attacklength) { // reset the attack direction. player1.attackdirection = 0; // reset the attack count player1.attackcount = 0; // set attack length back to default player1.attacklength = DEFAULTATTACKLENGTH; // transition out of attacking mode player1.attacking = 0; player1.frame = image_kirby; display_character(&player1); } } } // END OF TIM ISR }
/*** Write a character ***/ void putc(char c) { display_character(c); }