当前位置: 首页 > 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://www.huolong8.cn/news/210639/

相关文章:

  • 网页此站点不安全wordpress 安装主题慢
  • 公司网站域名无法解析汕头建站程序
  • 沈阳学网站制作学校怎么用Visio studio做网站
  • 网站建设报价是多少wordpress 直达链接
  • 淘宝做基础销量网站建设网站需要投入
  • 软件开发流程培训深圳网站seo教程
  • 国外做3d模型的网站上海网站建设市场分析
  • 做网站需要会的软件中英文网站模板源码
  • 网站布局怎么写wordpress主题修改
  • 最好的网站设计公相城区建设局网站
  • 网站设计与开发培训贵阳百度快照优化排名
  • 便利的龙岗网站设计商城网站除了域名备案还要
  • wordpress4.6字体seo网站优化方案案例
  • 如何给客户更好的做网站分析怎么恢复wordpress设定值
  • 网站设计的目的那些网站专门做棋牌推广的
  • 用ps做糖果店网站模板上海seo搜索优化
  • 上海网站建设定制开发群晖wordpress 外网很慢
  • 专业制作开发公司网站怎么在网站做gif
  • 做网站的数据库的步骤有知道做网站的吗
  • 佛山企业网站自助建站开发游戏需要多少钱
  • 电脑做视频的网站吗湖南做电商网站需要什么条件
  • 如何设置wordpress不自动更新开封做网站优化
  • 对网站建设有什么样好的建设意见网站推广营销方案
  • 海口招商建设有限公司网站济南正规的网站制作
  • 富平做网站安国市城乡建设局网站
  • 做美食网站的需求深圳哪里网站制作
  • 建外贸网站哪个好设计网站多少费用多少
  • 用钢铁侠做网站沈阳搜索排名公司
  • wordpress设置301重定向杭州企业seo网站优化
  • 深圳建设工程协会网站wordpress手机中文版下载