首页 > 系统 > Linux > 正文

linux控制台下实现2048小游戏

2019-11-02 15:52:26
字体:
来源:转载
供稿:网友

废话少说,直接奉上代码:

main.c

复制代码 代码如下:

#include"2048.h"

int main()

{

    start_game();

    return 0;

}

2048.h

复制代码 代码如下:

#ifndef _2048_H_

#define _2048_H_

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<termios.h>

//#include<unstd.h>

//#include<time/sys.h>

#define LINE 21

#define ROW   22

#define ARR_L 4

#define ARR_R 4

#define NUM_COLOR 32

#define BACK 49

#define BOLD 31

static int line_location=0;

static int row_location=0;

static int arr[4][4]={0};

static char tmp[5]="/0";

static int end_flag=0;

static int score=0;

static int print_appear_flag=0;

static char start_back0[LINE][ROW]={

    "@@@@@@@@@@@@@@@@@@@@@",

    "@    @    @    @    @",

    "@    @    @    @    @",

    "@    @    @    @    @",

    "@@@@@@@@@@@@@@@@@@@@@",

    "@    @    @    @    @",

    "@    @    @    @    @",

    "@    @    @    @    @",

    "@@@@@@@@@@@@@@@@@@@@@",

    "@    @    @    @    @",

    "@    @    @    @    @",

    "@    @    @    @    @",

    "@@@@@@@@@@@@@@@@@@@@@",

    "@    @    @    @    @",

    "@    @    @    @    @",

    "@    @    @    @    @",

    "@@@@@@@@@@@@@@@@@@@@@",

    "@                   @",

    "@ score:            @",

    "@                   @",

    "@@@@@@@@@@@@@@@@@@@@@"

};

int print_start();

char * itoc_2048(int data);

int print_num();

int  mov_left();

int swap_if0l();
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表