Main.c
来源:互联网 发布:海南大学网络教学平台 编辑:程序博客网 时间:2024/05/22 14:53
#include <stdio.h>#include <stdlib.h>#include <ncurses.h>#include "Datatypes.h"#include "Output.h"#include "Move.h"#include "Version.h"#include <time.h>int main(void){tHandlehandle;tInt16ch;intquit=0;intleave;handle.best=0;handle.win=NULL;srand(time(NULL));while (!quit){initOutput(&handle);initField(&handle);drawField(&handle);newTile(&handle);newTile(&handle);ch=0;leave=0;while (!leave){int m;drawField(&handle);ch=getch(); // input a charm=0;switch(ch){case KEY_UP: // 0403case 'K':case 'k':case 'W':case 'w':m=makeMove(&handle,MOVE_UP);break;case KEY_DOWN: // 0402case 'J':case 'j':case 'S':case 's':m=makeMove(&handle,MOVE_DOWN);break;case KEY_LEFT: // 0404case 'H':case 'h':case 'A':case 'a':m=makeMove(&handle,MOVE_LEFT);break;case KEY_RIGHT: // 0405case 'L':case 'l':case 'D':case 'd':m=makeMove(&handle,MOVE_RIGHT);break;}if (m){newTile(&handle);if (m==WINNING_TILE){leave=1;drawField(&handle);quit=winner(&handle);}}m=checkMoveable(&handle);if (!m){leave=1;drawField(&handle);quit=loser(&handle);}if (ch=='Q') leave=quit=1;}}endOutput(&handle);printf("[n2048 v%i.%i] Copyright (c) 2014, Thomas Dettbarn (dettus@dettus.net)\n",MAJOR_REVISION,MINOR_REVISION);printf("All rights reserved.\n");printf("\n");printf("Redistribution and use in source and binary forms, with or without\n");printf("modification, are permitted provided that the following conditions are met:\n");printf("\n");printf("1. Redistributions of source code must retain the above copyright notice, this\n");printf(" list of conditions and the following disclaimer. \n");printf("2. Redistributions in binary form must reproduce the above copyright notice,\n");printf(" this list of conditions and the following disclaimer in the documentation\n");printf(" and/or other materials provided with the distribution.\n");printf("\n");printf("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n");printf("ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n");printf("WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n");printf("DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n");printf("ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n");printf("(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n");printf("LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n");printf("ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n");printf("(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n");printf("SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n");printf("\n");}
0 0
- main.c
- main.c
- main.c
- main.c
- main.c
- main.c
- main.c
- main.c
- main.c
- Main.c
- main.c
- 0.11-main.c
- [C学习]Main函数
- linux-main.c
- C++main的参数表
- xv6的main.c
- scull-main.c
- s3c24xx main.c
- C++的虚函数
- OPENCV的学习:平滑处理
- 55种开源数据可视化工具简介
- [积累]android 获取屏幕高度和宽度 不准确的问题
- laravel5修改原始登陆与注册代码
- Main.c
- 提高第30课时,自测
- Message Passing Leads to Better Scalability in Parallel Systems
- 面试题41_1 和为S的数
- 第3部分:添加一些配置数据——我的面包太轻!
- 博客折腾记
- 使用achartengine显示折线图
- IT行业岗位及发展方向
- A Message to the Future