Small Procedures for Foundation Elimination of Enemy Aircraft
This is the beginning. Compare dishes. Of course, I'm also a vegetable now... emmmm, used purely as a record.
Functions: 1. Eliminate enemy aircraft
2. Slow down
Implemented functions: a bunch, not listed
Disadvantages: 1. Interface scintillation
2 Unhidden cursor
Tips: 1. You can use delay and for loops to slow down the pause rate.
//Simple Elimination of Aircraft Games #include<stdio.h> #Include <stdlib.h>//Screen Clearing #Include <conio.h>//No return is required #Include <windows.h>// Slowly move, set pause int main() { int i, j; int x=5, y=0; char input; int isfiled = 0; int iskilled = 0; int score = 0; //Calculated fraction srand(time(0)); int nx = rand() % 40 + 4; //Setting Random Number to Get Moving Target int ny = rand() % 40 + 4; while (1) { system("CLS"); //Clean screen if (!iskilled) //If hit, the target disappears. { for (i = 0; i < ny; i++) printf("\n"); for (j = 0; j < nx; j++) //Output Targets Using Random Numbers printf(" "); printf("+\n"); } else { Sleep(20); for (j = 0; j < nx; j++) //Output Targets Using Random Numbers printf(" "); printf("+\n"); } if (isfiled) { for (i = 0; i < y; i++) //Output Bullet, Output Bullet if Input Space Key, Output Bullet if Input Space Key, Output Bullet if Input Space Key { for (j = 0; j < x; j++) printf(" "); printf(" |\n"); if (x + 2 == nx) //Judge whether or not you hit the target { iskilled = 1; score++; nx = rand() % 40 + 4; ny = rand() % 40 + 4; } isfiled = 0; } } else { for (i = 0; i < y; i++) printf("\n"); } for (j = 0; j < x; j++) //Output of a small aircraft printf(" "); printf(" *\n"); for (j = 0; j < x; j++) printf(" "); printf("*****\n"); for (j = 0; j < x; j++) printf(" "); printf(" * *\n"); //Scanf_s("% c", & input, 1);//input wasd to control the up and down movement of the small aircraft input = _getch(); if (input == 'a') x--; if (input == 'd') x++; if (input == 'w') y--; if (input == 's') y++; if (input == ' ') //Bullet Launching Through Space Keys isfiled = 1; printf("score:%d", score); } system("pause"); return 0; }