贪吃蛇大作战
来源:互联网 发布:网络电玩游戏平台 编辑:程序博客网 时间:2024/06/10 15:02
写了大概有一个星期的贪吃蛇,最后崩盘了,没有写成功
也许是个错误的构思,用的二维int数组做的,写到最后一步的时候,已经实现的功能是在蛇屏幕上移动,还有判断game over ,还有随机产生果实
在写贪吃蛇的过程中,学到了不少,
- kbhit()判断是否有键入,没有返回0,else return 非0; #include
#include<stdio.h>#include<conio.h>#include<stdlib.h>int main(void){char ch;while(ch!=27){printf("HelloWorld\n");if(kbhit())ch=getch();}printf("End!\n");system("pause");return 0;}
getch()和getchar()是有区别的
getchar();需要enter键,
getch();并不需要随机
#include <time.h>time_t t;srand((unsigned)time(&t));int randomNum=rand()%k+1;
- 贪吃蛇地图
#include <stdio.h>#include <conio.h>#include <windows.h>int main(){ int width = 30, height = width; //宽度和高度 int x, y; //x、y分别表示当前行和列 HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); //设置窗口大小 system("mode con: cols=64 lines=32"); //打印背景,按行输出 for(x=0; x<width; x++){ for(y=0; y<height; y++){ if(y==0 || y==width-1 || x==0 || x==height-1){ //输出边框 SetConsoleTextAttribute(hConsole, 4 ); printf("□"); }else{ //贪吃蛇活动区域 SetConsoleTextAttribute(hConsole, 2 ); printf("■"); } } printf("\n"); } //暂停 getch(); return 0;}//http://c.biancheng.net/cpp/html/2942.html
下次再开车
1 0
- 贪吃蛇大作战
- 贪吃蛇大作战
- 球球大作战贪吃蛇大作战类似游戏算法优化
- 贪吃蛇大作战中的“马太效应”
- 贪吃蛇大作战类游戏的实现
- 贪吃蛇大作战单人版完整版代码以及详解
- 贪吃蛇大作战双人版完整代码
- 贪吃蛇大作战你个混蛋-别小看了异步消息
- 安卓 关于《贪吃蛇大作战》蛇头方向的判断与实现
- html5贪吃蛇大作战源码和俄罗斯方块源码 javascript图片演示
- unity 贪吃蛇作战—1
- unity 贪吃蛇作战—2
- 【Windows编程】球球大作战(二) 贪吃蛇的实现
- 说说夏日大作战
- make大作战
- 求职大作战1
- 爱情风水大作战
- 选课大作战
- 【USACO4.4.3】重叠的图像(DAG图的拓扑排序)
- makefile初级基础
- Hibernate的手动配置+手动增删改数据
- linux expect详解(ssh自动登录)
- Cpp环境【SDUT1128】【Code[VS]1809】【CQYZOJ1823】河床
- 贪吃蛇大作战
- Android自定义View——实现字母导航栏
- POJ1273 网络流-->最大流-->模板级别-->最大流常用算法总结
- HTTP 302问题
- linux 中php以及nginx的重启命令
- SQL那些事儿(三)----和小伙伴们做武大游
- frameset框架
- 形象易懂讲解算法II——压缩感知
- 学海无涯