GithubHelp home page GithubHelp logo

game_2048's Introduction

C语言2048小游戏

涉及内容

  • 屏幕绘制库ncurese的使用

  • ncurese库安装 $ sudo apt-get install libncurses5-dev

获取代码

$ git clone 
$ gcc game_2048.c -o 2048 -lcurses
$ ./2048

环境说明

  • Linux Ubuntu
  • Vim

效果图

设计思路

2048游戏中关键的是消掉方块和在屏幕上输出数据,后者可以通过ncurses库实现。 2048的2个关键点:

  • 1.满足条件消掉方块
  • 2.移动方块,触发消掉或者移动数据

大体思路维护和地图相同大小的数组矩阵,玩家操作,改变数组数据,并绘制出来。

函数说明

void draw();  // 用于绘制游戏界面
void play();  // 游戏运行的逻辑主体
void init();  // 初始化函数,用于完成一些必要的初始化操作
void draw_one(int y, int x);  // 绘制单个数字
void cnt_value(int *new_y, int *new_x);  // 
int game_over();  // 结束游戏
int cnt_one(int y, int x);  

game_2048's People

Contributors

estormlynn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.