做游戏,学编程(C语言) 飞机游戏 2 (思考改进)
来源:互联网 发布:乔丹和詹姆斯数据对比 编辑:程序博客网 时间:2024/06/11 09:46
思路来自;https://zhuanlan.zhihu.com/p/24652156
#include<stdio.h>#include<stdlib.h>#include<conio.h>#include<windows.h> int main(){int a,b;int c=5; //定义敌机初始位置int d=0; //定义敌机初始位置int x=17; //控制飞机横向位置int y=17; //控制飞机纵向位置int score=0;char input; //符号变量int isfire = 0; //通过变量检测是否发射子弹int isKilled = 0; //记录是否击中int velocity_x = 1;int velocity_y = 1;int left = 0;int right = 15;int top = 0;int bottom = 10;//战机移动相关while(1){system("cls"); //清屏Sleep(10);//输出敌机c=c+velocity_x; d=d+velocity_y;if ((c==left)||(c==right))velocity_x = -velocity_x;if ((d==top)||(d==bottom))velocity_y = -velocity_y; if(score<=100){for(b=0;b<d;b++)printf("\n");for(a=0;a<c;a++)printf(" ");printf("o\n");}system("cls");//输出飞机上面的空行if(isfire==0){for(b=0;b<y;b++)printf("\n");}//输出激光束线else {for(b=0;b<y;b++){for (a=0;a<x;a++)printf(" ");printf(" |\n");}if (x+2==c)isKilled=1;// 击中靶子if (x+2==c) score++;isfire = 0;}//输出飞机for(a=0;a<x;a++)printf(" ");printf(" *\n");for(a=0;a<x;a++)printf(" ");printf("*****\n");for(a=0;a<x;a++)printf(" ");printf(" * *\n"); printf("\n");if(kbhit()) // 判断是否有输入{input=getch();if(input=='a')x--; //左移if(input=='d')x++; //右移if(input=='w')y--; //上移if(input=='s')y++; //下移if(input==' ')isfire=1;}system("cls");for(a=0;a<20;a++)printf("\n");printf("score=%d ",score);/**if(score>=100)break;**/}return 0;}
0 0
- 做游戏,学编程(C语言) 飞机游戏 2 (思考改进)
- 做游戏,学编程(C语言) 2 最简单的飞机游戏
- 做游戏,学编程(C语言) 3 利用函数对飞机游戏进行重构
- 做游戏,学编程(C语言) 4 flappy bird
- 做游戏,学编程(C语言) 5 数组之生命游戏
- 做游戏,学编程(C语言) 6 数组之空战游戏
- 边做游戏边学android—2(飞机大战①创建飞机)
- 做游戏,学编程(C语言) 1 实现弹跳小球
- 做游戏,学编程(C语言) 7 学习EasyX图形交互功能----flappy bird源代码
- 边做游戏边学android—3(飞机大战②飞机移动)
- 飞机游戏(2)
- 界面打飞机游戏,C语言
- C语言实现“飞机大战”游戏
- 飞机游戏2
- 飞机游戏2
- 飞机游戏(1)
- 边做游戏边学android—4(飞机大战③添加敌机和碰撞检测)
- 边做游戏边学android—5(飞机大战④子弹发射和碰撞检测)
- codeforces 785D Anton and School
- linux 内核模块学习
- Android官方Guide回顾补漏
- 判断按钮的弹起和点击事件 mfc
- pip 指定源
- 做游戏,学编程(C语言) 飞机游戏 2 (思考改进)
- java线程浅析[结合源码讲述Thread的生命周期]
- linux下repo文件的配置
- 将matlab中数据保存为txt或dat格式
- git 基本操作记录
- 1. 需求和动态伸缩的网络架构
- Java 异常的捕获与处理详解(二)
- 基于Android的天气APP
- 开始使用 Fresco