当前位置: 首页 > news >正文

wordpress站点赏析万网注册域名做简单网站

wordpress站点赏析,万网注册域名做简单网站,网站建站 seo,建设主题网站步骤最近看到大神在Linux下写的贪吃蛇代码#xff0c;用到了curses图形库#xff0c;可能很多人都没有用过#xff0c;分享出来给大家。在ubuntu下安装curses图形库命令sudo apt-get install libncurses5-dev双buff是一个非常优秀的机制#xff0c;之前写贪吃蛇的时候#xff… 最近看到大神在Linux下写的贪吃蛇代码用到了curses图形库可能很多人都没有用过分享出来给大家。在ubuntu下安装curses图形库命令sudo apt-get install libncurses5-dev 双buff是一个非常优秀的机制之前写贪吃蛇的时候如果不使用双buff屏幕跳动会很剧烈使用了双buff后体验就非常好。我们使用curses图形库也是一样如果没有调用refresh()函数之前显示的屏幕是不会进行更新的。比如下面这段代码#include unistd.h #include stdlib.h #include curses.h int main() {initscr();/* We move the cursor to the point (5,15) on the logical screen,print Hello World and refresh the actual screen.Lastly, we use the call sleep(2) to suspend the program for two seconds,so we can see the output before the program ends. */move(5, 15);addstr(Hello World);refresh();sleep(2);endwin();exit(EXIT_SUCCESS); } 使用下面的命令编译并运行gcc -o t screen1.c -lncurses  ./t 首先初始化一个屏幕然后移动到屏幕的 5,15位置在输出字符串 Hello World。之后休眠 2秒后程序退出。使用curses写贪吃蛇代码//sudo apt-get install libncurses5-dev //gcc -o t tanchishe.c -lncurses  ./t #include curses.h // Linux 下的图形库 #include unistd.h // usleep() #include stdlib.h // rand() #include time.h   // time() #define W 40 #define H 24 int m[W * H], q[W * H], p  H / 2 * W  (W / 2), a, h  0, t  0, d  1, i; int main(void) {initscr(); noecho(); keypad(stdscr, 1); nodelay(stdscr, 1); curs_set(0);srand(time(NULL));for (i  0; i  W * H; i)m[i]  !(i / W % (H - 1)  i % W % (W - 1));m[q[t  (t  1) % (W * H)]  p]  1;do { a  rand() % (W * H); } while (m[a]);while ((i  getch()) ! 27) {if      (i  KEY_UP     d !  W) d  -W;else if (i  KEY_DOWN   d ! -W) d   W;else if (i  KEY_LEFT   d !  1) d  -1;else if (i  KEY_RIGHT  d ! -1) d   1;if (m[p  d]) break;m[q[t  (t  1) % (W * H)]  p]  1;if (p  a) do { a  rand() % (W * H); } while (m[a]);else m[q[h  (h  1) % (W * H)]]  0;for (i  0; i  W * H; i)mvaddstr(i / W, (i % W) * 2, m[i] ? [] :   );mvaddstr(a / W, (a % W) * 2, ());refresh();usleep(100000);}while (getch()  ERR);endwin(); }程序运行简单解释下for (i  0; i  W * H; i)mvaddstr(i / W, (i % W) * 2, m[i] ? [] :   ); 构建边框和蛇身的代码边框是用 [] 构建的用这个字符从视觉上看会比较舒服。mvaddstr(a / W, (a % W) * 2, ()); 随机生成的食物之前已经用时间srand(time(NULL));作为种子设置了随机数。if (m[p  d]) break; 碰撞检测if (p  a) do { a  rand() % (W * H); } while (m[a]);else m[q[h  (h  1) % (W * H)]]  0; 如果碰撞到了食物就增加蛇长度m[]里面同时保存蛇的数据和边框的数据并且蛇移动的时候需要把后面的数值设置为0。p  H / 2 * W  (W / 2) 蛇的初始位置自己修改的代码可以实现穿墙效果//sudo apt-get install libncurses5-dev //gcc -o t tanchishe.c -lncurses  ./t #include curses.h // Linux 下的图形库 #include unistd.h // usleep() #include stdlib.h // rand() #include time.h   // time() #define W 40 #define H 24 int m[W * H], q[W * H], p  H / 2 * W  (W / 2), a, h  0, t  0, d  1, i,j3; int main(void) {initscr(); noecho(); keypad(stdscr, 1); nodelay(stdscr, 1); curs_set(0);srand(time(NULL));for (i  0; i  W * H; i) m[i]  !(i / W % (H - 1)  i % W % (W - 1));m[q[t  (t  1) % (W * H)]  p]  1;do { a  rand() % (W * H); } while (m[a]);while ((i  getch()) ! 27) {if      (i  KEY_UP     d !  W) {d  -W;j0;}else if (i  KEY_DOWN   d ! -W) {d   W;j1;}else if (i  KEY_LEFT   d !  1) {d  -1;j2;}else if (i  KEY_RIGHT  d ! -1) {d   1;j3;}if (m[p  d]) {switch(j){case 0:p  p(H-2)*W; break;case 1:p  p-(H-2)*W; break;case 2:p  pW-2; break;case 3:p  p-W2; break;default: p  H / 2 * W  (W / 2); break;}};m[q[t  (t  1) % (W * H)]  p]  1;if (p  a) do { a  rand() % (W * H); } while (m[a]);else m[q[h  (h  1) % (W * H)]]  0;for (i  0; i  W * H; i){mvaddstr(i / W, (i % W) * 2, m[i] ? [] :   );}mvaddstr(a / W, (a % W) * 2, ());refresh();usleep(100000);}while (getch()  ERR);endwin(); }运行如下代码原文https://www.zhihu.com/question/360814879/answer/1013986215公众号后台回复「curse」获取curse图形库资料推荐阅读专辑|Linux文章汇总专辑|程序人生专辑|C语言我的知识小密圈关注公众号后台回复「1024」获取学习资料网盘链接。欢迎点赞关注转发在看您的每一次鼓励我都将铭记于心~
http://wiki.neutronadmin.com/news/210639/

相关文章:

  • 多语言版本网站制作海南网站建设哪里好
  • 如何建立自己的网站免费商城网站项目案例
  • 高端网站开发价格网站优化怎么做外链
  • html5制作网站开发网站建设管理经验
  • 传统企业网站建设西安网站建设云李
  • 牛人网站建设网站建设公司山而
  • 娱乐网站制作企业网站做的好的有什么公司
  • 广州积分入学网站注册公司流程及步骤
  • 用php做电商网站有哪些成都网站备案
  • 网站建设经费管理php企业网站系统
  • 网站建设数据库怎么传送网站制作 杭州公司
  • 软件开发和网站建设那个好区块链app制作教程
  • 怎么上传网站仙居住房和城乡建设局网站
  • 广州网站建设哪好买个天猫店多少钱一个
  • 九江企业网站的建设WordPress站内跳转设置
  • 网站建设书本打电话沟通做网站
  • 官方网站建设 磐石网络多少费用wordpress免费简约主题下载
  • 聊网站推广河源东源新闻最新消息
  • 天津手机版建站系统哪个好比较好看的网站设计
  • 网站开发和设计区别网站开发专业 工作意愿
  • 近期做网站需要什么软件申请微信小程序流程
  • 2021建站做相册集什么网站
  • 哪里有做证seo综合查询平台官网
  • 网站个人信息页面布局南昌网站做
  • 济南做网站那家好网页设计图片素材小插件
  • 一般网站后台地址赣州营销网站建设
  • 有关做有机肥的企业网站wordpress织梦扩展
  • 企业网站开发网站做端口是什么情况
  • 网站建设类的计入什么科目优秀个人网页设计案例分析
  • 竹子建站怎么样rpc wordpress