飞机游戏
简单飞机移动
#if 1
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main() {
int x = 10;
int y = 5;
int input;
while (1) {
system("cls");
for (int i = 0; i < y; i++) {
printf("\n");
}
for (int i = 0; i < x; i++) {
printf(" ");
}
printf("*");
if (kbhit()) {
input = getch();
switch (input) {
case 'a':
x--;
break;
case 's':
y++;
break;
case 'w':
y--;
break;
case 'd':
x++;
break;
default:
break;
}
}
}
system("pause");
return 0;
}
#endif
#if 1
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main() {
int x = 10;
int y = 5;
int input;
while (1) {
system("cls");
for (int i = 0; i < y; i++) {
printf("\n");
}
for (int i = 0; i < x; i++) {
printf(" ");
}
printf(" * \n");
for (int i = 0; i < x; i++) {
printf(" ");
}
printf("*****\n");
for (int i = 0; i < x; i++) {
printf(" ");
}
printf(" * *");
if (kbhit()) {
input = getch();
switch (input) {
case 'a':
x--;
break;
case 's':
y++;
break;
case 'w':
y--;
break;
case 'd':
x++;
break;
default:
break;
}
}
}
system("pause");
return 0;
}
#endif
飞机发射激光
#if 1
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main() {
int x = 10;
int y = 5;
int input;
bool isFire = false;
while (1) {
system("cls");
for (int i = 0; i < y; i++) {
if (isFire) {
for (int i = 0; i < x; i++) {
printf(" ");
}
printf(" | ");
}
printf("\n");
}
for (int i = 0; i < x; i++) {
printf(" ");
}
printf(" * \n");
for (int i = 0; i < x; i++) {
printf(" ");
}
printf("*****\n");
for (int i = 0; i < x; i++) {
printf(" ");
}
printf(" * *");
if (kbhit()) {
input = getch();
switch (input) {
case 'a':
x--;
isFire = false;
break;
case 's':
y++;
isFire = false;
break;
case 'w':
y--;
isFire = false;
break;
case 'd':
x++;
isFire = false;
break;
case ' ':
isFire = true;
break;
default:
break;
}
}
}
system("pause");
return 0;
}
#endif