void paint( const World& world ) { //TODAS LAS FUNCIONES ESTAN EXPLICADAS EN mis_funciones.cpp, AUNQUE LOS NOMBRES YA DICEN MUCHO Pintar_Boxes(world); Pintar_Estrellas(world, world.coord); Pintar_Tiempo(world); Pintar_FPS(world); Pintar_Vidas(world); Pintar_Mi_Nave(world, world.mi_nave); Pintar_Escudos(world); Pintar_Enemigos1(world); Pintar_Enemigos2(world); Pintar_Enemigos3(world); Pintar_Mis_Balas(world); Pintar_Primeros_Enemigos_Balas(world); Pintar_Segundos_Enemigos_Balas(world); Pintar_Terceros_Enemigos_Balas(world); You_Win(world); Game_Over(world); }
void display(void) { if(Game_HitGround()) { // Check keyboard for reset Airplane_Keyboard(&thrust, &yawRate, &pitchRate, &rollRate, &firstPersonView, &resetFlag); Game_Over(); if(resetFlag == 1) { Game_Reset(&forward, &up, &right, &position, &velocity, &thrust, &yawRate, &pitchRate, &rollRate, &firstPersonView, &resetFlag, &camera_position, &camera_look, camMatrix); } } else { // Get user input Airplane_Keyboard(&thrust, &yawRate, &pitchRate, &rollRate, &firstPersonView, &resetFlag); // Update airplane dynamics Dynamics_CalcRot(yawRate, pitchRate, rollRate, &forward, &up, &right); Dynamics_CalcPos(thrust, &forward, &velocity, &position); // Update camera Camera_Update(firstPersonView, &forward, &up, &position, velocity, &camera_position, &camera_look, camMatrix); printError("pre display"); // clear the screen glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Draw ground and skybox World_Draw(&camera_position, &camera_look, camMatrix, &position, &up, firstPersonView); // Check for collision Game_CollisionDetection(&position, &forward, &up, &right); // The game loop Game_Loop(position); // Draw target Game_DrawTarget(camMatrix, &camera_position); // Draw airplane Airplane_Draw(&forward, &up, &right, &position, &camera_position, camMatrix); // Reset game? if(resetFlag == 1) { Game_Reset(&forward, &up, &right, &position, &velocity, &thrust, &yawRate, &pitchRate, &rollRate, &firstPersonView, &resetFlag, &camera_position, &camera_look, camMatrix); } } printError("display"); glutSwapBuffers(); }
void SceneScriptUG05::sub_402218() { int v0 = sub_4021B0(); if (v0 != -1) { Actor_Face_Actor(kActorMcCoy, v0, true); Actor_Face_Actor(v0, kActorMcCoy, true); Actor_Says(kActorMcCoy, 5535, 13); if (v0 == 3) { Actor_Says(kActorDektora, 1110, 15); } else { Actor_Says(kActorLucy, 670, 17); } } Ambient_Sounds_Remove_All_Non_Looping_Sounds(1); Ambient_Sounds_Remove_All_Looping_Sounds(1); if (v0 == kActorLucy) { if (Game_Flag_Query(46)) { if (Global_Variable_Query(48) > 3) { Outtake_Play(13, 0, -1); } else { Outtake_Play(14, 0, -1); } } else { Outtake_Play(12, 0, -1); } } else if (v0 == kActorDektora) { if (Game_Flag_Query(47)) { if (Global_Variable_Query(48) > 3) { Outtake_Play(16, 0, -1); } else { Outtake_Play(17, 0, -1); } } else { Outtake_Play(15, 0, -1); } } else { Outtake_Play(19, 0, -1); } Outtake_Play(18, 0, -1); Game_Over(); }
bool AIScriptClovis::GoalChanged(int currentGoalNumber, int newGoalNumber) { switch (newGoalNumber) { case kGoalClovisDefault: AI_Movement_Track_Flush(kActorClovis); AI_Movement_Track_Append(kActorClovis, 33, 0); AI_Movement_Track_Repeat(kActorClovis); return true; case kGoalClovisBB11WalkToMcCoy: AI_Movement_Track_Flush(kActorClovis); AI_Movement_Track_Append(kActorClovis, 319, 0); AI_Movement_Track_Append(kActorClovis, 320, 0); AI_Movement_Track_Repeat(kActorClovis); return true; case kGoalClovisBB11StopSadik: Actor_Start_Speech_Sample(kActorClovis, 0); AI_Movement_Track_Flush(kActorClovis); AI_Movement_Track_Append(kActorClovis, 321, 0); AI_Movement_Track_Repeat(kActorClovis); return true; case kGoalClovisBB11TalkWithSadik: Actor_Set_Goal_Number(kActorSadik, kGoalSadikBB11TalkWithClovis); Actor_Says(kActorClovis, 10, 15); Actor_Says(kActorSadik, 0, kAnimationModeTalk); Actor_Face_Actor(kActorClovis, kActorSadik, true); Actor_Says(kActorClovis, 20, 13); Actor_Says(kActorClovis, 30, 12); Actor_Face_Actor(kActorSadik, kActorClovis, true); Actor_Says(kActorSadik, 10, kAnimationModeTalk); Actor_Says(kActorClovis, 40, 17); Actor_Says(kActorSadik, 20, kAnimationModeTalk); Actor_Face_Actor(kActorClovis, kActorMcCoy, true); Actor_Face_Actor(kActorSadik, kActorMcCoy, true); Actor_Says(kActorClovis, 50, 14); Actor_Change_Animation_Mode(kActorClovis, kAnimationModeSit); return true; case kGoalClovisBB11TalkToMcCoy: Actor_Says(kActorClovis, 60, 30); Actor_Says(kActorSadik, 30, kAnimationModeTalk); Actor_Says(kActorClovis, 70, 30); Actor_Says(kActorClovis, 80, 30); Actor_Change_Animation_Mode(kActorClovis, 29); Actor_Says(kActorSadik, 40, kAnimationModeTalk); Actor_Says(kActorSadik, 50, kAnimationModeTalk); Actor_Says(kActorClovis, 90, 13); Actor_Face_Current_Camera(5, true); Actor_Says(kActorClovis, 100, 17); Delay(1000); if (!Game_Flag_Query(kFlagSadikIsReplicant)) { Actor_Clue_Acquire(kActorMcCoy, kClueStaggeredbyPunches, true, kActorSadik); } Game_Flag_Set(kFlagNotUsed383); Game_Flag_Reset(kFlagBB11SadikFight); Global_Variable_Set(kVariableChapter, 3); Actor_Set_Goal_Number(kActorClovis, 200); Actor_Set_Goal_Number(kActorSadik, 200); Actor_Clue_Acquire(kActorMcCoy, kClueAct2Ended, true, -1); Player_Gains_Control(); Chapter_Enter(3, kSetCT08_CT51_UG12, kSceneCT08); Game_Flag_Set(kFlagMcCoyTiedDown); Game_Flag_Set(kFlagChapter3Intro); return true; case 300: Actor_Put_In_Set(kActorClovis, kSetUG18); Actor_Set_At_XYZ(kActorClovis, -52.26f, 0.0f, 611.02f, 900); Actor_Change_Animation_Mode(kActorClovis, kAnimationModeIdle); return true; case 301: case 302: case 303: case 310: return true; case 350: Actor_Put_In_Set(kActorClovis, kSetFreeSlotA); Actor_Set_At_Waypoint(kActorClovis, 33, 0); return true; case 400: AI_Movement_Track_Flush(kActorClovis); Actor_Put_In_Set(kActorClovis, kSetFreeSlotA); Actor_Set_At_Waypoint(kActorClovis, 33, 0); return true; case 401: AI_Movement_Track_Flush(kActorClovis); AI_Movement_Track_Append(kActorClovis, 341, 0); AI_Movement_Track_Append(kActorClovis, 342, 0); AI_Movement_Track_Repeat(kActorClovis); return true; case 402: Player_Loses_Control(); Actor_Force_Stop_Walking(kActorMcCoy); Actor_Face_Actor(kActorMcCoy, kActorClovis, 1); Loop_Actor_Walk_To_Actor(kActorClovis, kActorMcCoy, 48, 0, 1); Actor_Face_Actor(kActorClovis, kActorMcCoy, 1); Actor_Change_Animation_Mode(kActorClovis, 6); if (Player_Query_Combat_Mode()) { Actor_Change_Animation_Mode(kActorMcCoy, 49); } else { Actor_Change_Animation_Mode(kActorMcCoy, 48); } Delay(3000); Actor_Retired_Here(kActorMcCoy, 12, 48, 1, kActorClovis); return true; case 500: Actor_Set_Goal_Number(kActorClovis, 510); return true; case 510: if (Game_Flag_Query(653)) { Actor_Set_Goal_Number(kActorClovis, 513); } else { Actor_Set_Goal_Number(kActorClovis, 511); Game_Flag_Set(685); } return true; case 511: Actor_Put_In_Set(kActorClovis, kSetKP05_KP06); Actor_Set_At_XYZ(kActorClovis, -1072.0f, 8.26f, -708.0f, 530); return true; case 512: Actor_Says(kActorClovis, 110, kAnimationModeTalk); Actor_Says(kActorMcCoy, 2255, kAnimationModeTalk); Actor_Says(kActorClovis, 120, kAnimationModeTalk); Actor_Says(kActorClovis, 130, kAnimationModeTalk); Actor_Says(kActorClovis, 140, kAnimationModeTalk); Actor_Says(kActorMcCoy, 2260, kAnimationModeTalk); Actor_Says(kActorClovis, 150, kAnimationModeTalk); Actor_Set_Goal_Number(kActorClovis, 513); return true; case 513: Actor_Put_In_Set(kActorClovis, kSetKP07); Actor_Set_Targetable(kActorClovis, true); if (Game_Flag_Query(653)) { Global_Variable_Set(kVariableReplicants, 0); Global_Variable_Increment(kVariableReplicants, 1); Actor_Set_At_XYZ(kActorClovis, 45.0f, -41.52f, -85.0f, 750); } else { Actor_Set_At_XYZ(kActorClovis, 84.85f, -50.56f, -68.87f, 800); Actor_Face_Heading(kActorClovis, 1022, false); } someAnim(); return true; case 514: Actor_Says(kActorMcCoy, 2345, 16); Actor_Says(kActorClovis, 170, -1); Actor_Says(kActorClovis, 180, kAnimationModeTalk); Actor_Says(kActorMcCoy, 2350, 17); if (!Game_Flag_Query(714)) { Actor_Says(kActorMcCoy, 2355, 11); } Actor_Says(kActorClovis, 190, -1); Actor_Says(kActorClovis, 200, kAnimationModeTalk); Actor_Says(kActorMcCoy, 2360, 18); Actor_Says(kActorClovis, 210, kAnimationModeTalk); Actor_Says(kActorClovis, 220, -1); Actor_Set_Goal_Number(kActorClovis, 515); return true; case 515: ADQ_Add(kActorClovis, 240, -1); ADQ_Add(kActorClovis, 250, -1); ADQ_Add(kActorClovis, 260, -1); ADQ_Add(kActorClovis, 270, -1); ADQ_Add_Pause(1000); ADQ_Add(kActorClovis, 280, -1); ADQ_Add(kActorClovis, 290, -1); ADQ_Add(kActorClovis, 300, -1); return true; case 516: Actor_Says(kActorMcCoy, 8501, kAnimationModeTalk); Actor_Says(kActorClovis, 1260, kAnimationModeTalk); Actor_Says(kActorMcCoy, 8502, kAnimationModeTalk); Actor_Says(kActorClovis, 1270, kAnimationModeTalk); Actor_Says(kActorMcCoy, 8504, kAnimationModeTalk); Actor_Says(kActorClovis, 1290, kAnimationModeTalk); Actor_Says(kActorMcCoy, 8505, kAnimationModeTalk); Actor_Says(kActorClovis, 1300, kAnimationModeTalk); Actor_Says(kActorClovis, 1310, kAnimationModeTalk); Ambient_Sounds_Remove_All_Non_Looping_Sounds(true); Ambient_Sounds_Remove_All_Looping_Sounds(1); Outtake_Play(kOuttakeEnd4A, 0, -1); if (Global_Variable_Query(kVariableAffectionTowards) == kAffectionTowardsLucy && Game_Flag_Query(kFlagLucyIsReplicant) ) { Outtake_Play(kOuttakeEnd4B, 0, -1); } else if (Global_Variable_Query(kVariableAffectionTowards) == kAffectionTowardsDektora && Game_Flag_Query(kFlagDektoraIsReplicant) ) { Outtake_Play(kOuttakeEnd4C, 0, -1); } Outtake_Play(kOuttakeEnd4D, 0, -1); Game_Over(); return true; case 517: if (Global_Variable_Query(kVariableChapter) == 5 && Actor_Query_In_Set(kActorLucy, kSetKP07)) { Actor_Set_Goal_Number(kActorLucy, 599); Global_Variable_Decrement(kVariableReplicants, 1); } if (Global_Variable_Query(kVariableChapter) == 5 && Actor_Query_In_Set(kActorLuther, kSetKP07)) { Actor_Set_Goal_Number(kActorLuther, 599); Global_Variable_Decrement(kVariableReplicants, 1); } if (Global_Variable_Query(kVariableChapter) == 5 && Actor_Query_In_Set(kActorDektora, kSetKP07)) { Non_Player_Actor_Combat_Mode_On(kActorDektora, kActorCombatStateIdle, false, kActorMcCoy, 19, kAnimationModeCombatIdle, kAnimationModeCombatWalk, kAnimationModeCombatRun, 0, 0, 100, 10, 300, false); } if (Global_Variable_Query(kVariableChapter) == 5 && Actor_Query_In_Set(kActorZuben, kSetKP07)) { Non_Player_Actor_Combat_Mode_On(kActorZuben, kActorCombatStateIdle, false, kActorMcCoy, 19, kAnimationModeCombatIdle, kAnimationModeCombatWalk, kAnimationModeCombatRun, 0, 0, 100, 10, 300, false); } if (Global_Variable_Query(kVariableChapter) == 5 && Actor_Query_In_Set(kActorSadik, kSetKP07)) { Non_Player_Actor_Combat_Mode_On(kActorSadik, kActorCombatStateIdle, true, kActorMcCoy, 19, kAnimationModeCombatIdle, kAnimationModeCombatWalk, kAnimationModeCombatRun, 0, 0, 100, 10, 300, false); } if (Global_Variable_Query(kVariableChapter) == 5 && Actor_Query_In_Set(kActorIzo, kSetKP07)) { Non_Player_Actor_Combat_Mode_On(kActorIzo, kActorCombatStateIdle, false, kActorMcCoy, 19, kAnimationModeCombatIdle, kAnimationModeCombatWalk, kAnimationModeCombatRun, 0, 0, 100, 10, 300, false); } if (Global_Variable_Query(kVariableChapter) == 5 && Actor_Query_In_Set(kActorGordo, kSetKP07)) { Non_Player_Actor_Combat_Mode_On(kActorGordo, kActorCombatStateIdle, true, kActorMcCoy, 19, kAnimationModeCombatIdle, kAnimationModeCombatWalk, kAnimationModeCombatRun, 0, 0, 100, 10, 300, false); } if (Global_Variable_Query(kVariableChapter) == 5 && Actor_Query_In_Set(kActorClovis, kSetKP07)) { Non_Player_Actor_Combat_Mode_On(kActorClovis, kActorCombatStateIdle, false, kActorMcCoy, 19, kAnimationModeCombatIdle, kAnimationModeCombatWalk, kAnimationModeCombatRun, 0, 0, 100, 10, 300, false); } return true; case 518: Actor_Set_At_XYZ(kActorClovis, 84.85f, -50.56f, -68.87f, 800); Actor_Face_Heading(kActorClovis, 1022, false); Actor_Set_Targetable(kActorClovis, true); Game_Flag_Set(685); someAnim(); return true; default: break; } return false; }
void ScriptKP06::PlayerWalkedIn() { if (!Game_Flag_Query(653) && Game_Flag_Query(579)) { Game_Flag_Reset(579); if (Actor_Query_Goal_Number(1) == 499) { Actor_Face_Actor(1, 0, true); Actor_Says(1, 2530, 13); Actor_Face_Actor(0, 1, true); Actor_Says(0, 6200, 11); Actor_Says(1, 2540, 15); Actor_Says(1, 2550, 12); Actor_Says(0, 6205, 14); if (Actor_Query_Friendliness_To_Other(1, 0) < 50) { Actor_Says(1, 2560, 12); Actor_Says(0, 6210, 14); Actor_Says(1, 2570, 13); Actor_Says(0, 6215, 14); Actor_Says(1, 2580, 15); Actor_Says(1, 2590, 12); } Async_Actor_Walk_To_Waypoint(0, 551, 0, 0); Delay(1000); Actor_Says(0, 6220, -1); Delay(3000); Ambient_Sounds_Remove_All_Non_Looping_Sounds(1); Ambient_Sounds_Remove_All_Looping_Sounds(1); Outtake_Play(25, 0, -1); Game_Over(); //return true; return; } else { Actor_Set_Goal_Number(53, 499); Actor_Face_Actor(53, 0, true); Actor_Says(53, 220, 13); Actor_Face_Actor(0, 53, true); Actor_Says(0, 6245, 11); Actor_Says(53, 230, 14); if (Game_Flag_Query(714)) { Actor_Says(0, 6250, 15); Actor_Says(53, 240, 13); Delay(1000); Actor_Says(0, 6255, 17); Actor_Says(53, 250, 14); Delay(1000); } Actor_Says(53, 260, 12); Actor_Says(0, 6260, 15); Actor_Says(53, 270, 13); Actor_Says(53, 280, 15); Actor_Says(0, 6265, 14); Actor_Says(53, 290, 14); Actor_Says(53, 300, 15); Actor_Says(0, 6270, 11); Async_Actor_Walk_To_Waypoint(0, 550, 0, 0); Async_Actor_Walk_To_Waypoint(53, 551, 0, 0); Actor_Says(53, 310, -1); Delay(3000); Outtake_Play(26, 0, -1); Game_Over(); //return true; return; } } else { if (Actor_Query_Goal_Number(8) == 414) { Loop_Actor_Walk_To_XYZ(0, -809.0f, 8.26f, -619.0f, 0, 0, false, 0); Actor_Face_Actor(0, 8, true); Actor_Set_Goal_Number(8, 415); } if (Actor_Query_Goal_Number(1) == 431) { Actor_Set_Goal_Number(1, 432); } //return false; return; } }
int main(int argc, char *argv[]) { char dossier[] = CHEMIN_CARTE; char JeuxDeCarte[MAX][MAX]; int JeuxActuel[NB_CARTE] = RAZ_CARTE; //Déclaration des variables vidéo SDL_Surface *ecran = NULL; SDL_Surface *carte[NB_CARTE] = RAZ_CARTE; SDL_Rect position_carte[NB_CARTE]; SDL_Rect position_credit; SDL_Rect position_credit_reel; SDL_Event event; SDL_Surface *Affiche_Credit = NULL; SDL_Surface *Affiche_Credit_Reel = NULL; //Declaration des variables concernant le jeu int i = 1; int MainGagnante[NB_CARTE] = RAZ_CARTE; int continuer = 1; int Selection_Carte[NB_CARTE] = RAZ_SELECTION; int MainJouer[NB_CARTE] = RAZ_MAIN; int MainGarder[NB_CARTE] = RAZ_CARTE; char *JeuxActuel1[NB_CARTE] = RAZ_CARTE; int Credit = CREDIT; //Declaration du flag permettant de gerer les etapes du jeu FLAG FLAG; Initialisation_Accueil(&ecran, &FLAG, position_carte); Initialisation_Jeux(dossier, &JeuxDeCarte, &i); while (continuer) { SDL_WaitEvent(&event); switch(event.type) { case SDL_QUIT: continuer = 0; break; case SDL_KEYDOWN: switch (event.key.keysym.sym) { case SDLK_KP_ENTER: if (FLAG.FLAG_JEUX == 1){ Retirer_Credit(&Credit); Generation_Visuel_Credit(&ecran, &Affiche_Credit, &position_credit, &Affiche_Credit_Reel, &position_credit_reel, &Credit); } Gestion_Jeux(&ecran, &carte[6], &JeuxDeCarte, &position_carte, &MainJouer, &FLAG, &Selection_Carte, &JeuxActuel[NB_CARTE], JeuxActuel1, MainGagnante, &MainGarder, &Credit); break; case SDLK_KP1: if (FLAG.FLAG_SELECTION == 1){ if (Selection_Carte[0] == 0){ RetirerCarte(&ecran, &carte[6], &position_carte, &MainJouer, &FLAG, &Selection_Carte, &MainGarder, 0); Generation_Visuel_Credit(&ecran, &Affiche_Credit, &position_credit, &Affiche_Credit_Reel, &position_credit_reel, &Credit); SDL_Flip(ecran); break; }else if(Selection_Carte[0] == 1){ GarderCarte(&MainJouer, &FLAG, &Selection_Carte, &position_carte, &ecran, &MainGarder, 0); break; } } break; case SDLK_KP2: if (FLAG.FLAG_SELECTION == 1){ if (Selection_Carte[1] == 0){ RetirerCarte(&ecran, &carte[6], &position_carte, &MainJouer, &FLAG, &Selection_Carte, &MainGarder, 1); Generation_Visuel_Credit(&ecran, &Affiche_Credit, &position_credit, &Affiche_Credit_Reel, &position_credit_reel, &Credit); SDL_Flip(ecran); break; }else if(Selection_Carte[1] == 1){ GarderCarte(&MainJouer, &FLAG, &Selection_Carte, &position_carte, &ecran, &MainGarder, 1); break; } } break; case SDLK_KP3: if (FLAG.FLAG_SELECTION == 1){ if (Selection_Carte[2] == 0){ RetirerCarte(&ecran, &carte[6], &position_carte, &MainJouer, &FLAG, &Selection_Carte, &MainGarder, 2); Generation_Visuel_Credit(&ecran, &Affiche_Credit, &position_credit, &Affiche_Credit_Reel, &position_credit_reel, &Credit); SDL_Flip(ecran); break; }else if(Selection_Carte[2] == 1){ GarderCarte(&MainJouer, &FLAG, &Selection_Carte, &position_carte, &ecran, &MainGarder, 2); break; } } break; case SDLK_KP4: if (FLAG.FLAG_SELECTION == 1){ if (Selection_Carte[3] == 0){ RetirerCarte(&ecran, &carte[6], &position_carte, &MainJouer, &FLAG, &Selection_Carte, &MainGarder, 3); Generation_Visuel_Credit(&ecran, &Affiche_Credit, &position_credit, &Affiche_Credit_Reel, &position_credit_reel, &Credit); SDL_Flip(ecran); break; }else if(Selection_Carte[3] == 1){ GarderCarte(&MainJouer, &FLAG, &Selection_Carte, &position_carte, &ecran, &MainGarder, 3); break; } } break; case SDLK_KP5: if (FLAG.FLAG_SELECTION == 1){ if (Selection_Carte[4] == 0){ RetirerCarte(&ecran, &carte[6], &position_carte, &MainJouer, &FLAG, &Selection_Carte, &MainGarder, 4); Generation_Visuel_Credit(&ecran, &Affiche_Credit, &position_credit, &Affiche_Credit_Reel, &position_credit_reel, &Credit); SDL_Flip(ecran); break; }else if(Selection_Carte[4] == 1){ GarderCarte(&MainJouer, &FLAG, &Selection_Carte, &position_carte, &ecran, &MainGarder, 4); break; } } break; case SDLK_SPACE: if (Credit == 0){ Game_Over(&ecran); }else{ if (FLAG.FLAG_INI == 1){ //Ecran RAZ SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 0, 255)); Generation_Visuel_Credit(&ecran, &Affiche_Credit, &position_credit, &Affiche_Credit_Reel, &position_credit_reel, &Credit); NouvellePartie(&ecran, &carte[6], &position_carte, &FLAG, &Affiche_Credit, position_credit, &Affiche_Credit_Reel, position_credit_reel);// Initialisation de l'application video }} break; default: break; }break; break; } } SDL_FreeSurface(Affiche_Credit_Reel); SDL_FreeSurface(Affiche_Credit); SDL_FreeSurface(carte[0]); SDL_FreeSurface(carte[1]); SDL_FreeSurface(carte[2]); SDL_FreeSurface(carte[3]); SDL_FreeSurface(carte[4]); SDL_Quit(); return EXIT_SUCCESS; }
void Move_Snake() //让蛇动起来 { int ix, iy; for(ix = 0; ix < LEN; ++ix) //先标记蛇头 for(iy = 0; iy < WID; ++iy) if(Snake[ix][iy] == 1) { switch(Sna_Hea_Dir) //根据新的蛇头方向标志蛇头 { case 'W': if(iy == 0) Game_Over(); else Sna_Hea_Y = iy - 1; Sna_Hea_X = ix; break; case 'S': if(iy == (WID -1)) Game_Over(); else Sna_Hea_Y = iy + 1; Sna_Hea_X = ix; break; case 'A': if(ix == 0) Game_Over(); else Sna_Hea_X = ix - 1; Sna_Hea_Y = iy; break; case 'D': if(ix == (LEN - 1)) Game_Over(); else Sna_Hea_X = ix + 1; Sna_Hea_Y = iy; break; default: break; } } if(Snake[Sna_Hea_X][Sna_Hea_Y]!=1&&Snake[Sna_Hea_X][Sna_Hea_Y]!=0&&Snake[Sna_Hea_X][Sna_Hea_Y]!=-1) Game_Over(); if(Snake[Sna_Hea_X][Sna_Hea_Y] < 0) //吃到苹果 { ++Snake_Len; Eat_Apple = 1; } for(ix = 0; ix < LEN; ++ix) //处理蛇尾 for(iy = 0; iy < WID; ++iy) { if(Snake[ix][iy] > 0) { if(Snake[ix][iy] != Snake_Len) Snake[ix][iy] += 1; else Snake[ix][iy] = 0; } } Snake[Sna_Hea_X][Sna_Hea_Y] = 1; //处理蛇头 }