资源简介
自己写的课程设计,Windows SDK编程实现的2048小游戏,可以完全重现2048游戏的常见所有功能。

代码片段和文件信息
#include“game2048.h“
extern int i;
extern TCHAR zd[256];
extern BOOL menu;
extern int map[max_n][max_n];
extern int oldmap[max_n][max_n];
extern int flag[max_n][max_n];
extern int n;
extern int map_new[max_n][max_n];
extern int score;
extern int oldscore;
extern int bgmflag kflag;
extern RECT rect;
extern DWORD dwBytes;
/*******************************************************************
常用函数区
********************************************************************/
int go()//判断是否还有空位
{
for (int i = 0; i for (int j = 0; j {
if (map[i][j] == 0) return 1;
}
return 0;
}
int pan()//判断游戏是否结束
{
if (go() == 1) return 1;
for (int i = 1; i for (int j = 1; j {
if (map[i][j] == map[i - 1][j] || map[i][j] == map[i + 1][j] || map[i][j] == map[i][j - 1] || map[i][j] == map[i][j + 1])
return 1;
}
for (int j = 1; j<= max_n - 1; j++)
{
if (map[0][j] == map[0][j - 1])
return 1;
}
for (int j = 1; j<= max_n - 1; j++)
{
if (map[max_n - 1][j] == map[max_n - 1][j - 1])
return 1;
}
for (int i = 1; i <= max_n - 1; i++)
{
if (map[i][0] == map[i - 1][0])
return 1;
}
for (int i = 1; i <= max_n - 1; i++)
{
if (map[i][max_n - 1] == map[i - 1][max_n - 1])
return 1;
}
return 0;
}
int panold()//判断map是否有变化
{
for (int i = 0; i for (int j = 0; j {
if (map[i][j] != oldmap[i][j]) return 1;
}
return 0;
}
void s()//生成随机数
{
srand(time(0));
if (go() == 1)
do {
int x = rand() % max_n;
int y = rand() % max_n;
if (map[x][y] == 0)
{
if (rand() % 20 == 4) map[x][y] = 4;
else map[x][y] = 2;
break;
}
} while (1);
}
void restart()
{
for (int i = 0; i {
for (int j = 0; j {
map[i][j] = 0;
}
}
s();
s();
score = 0;
}
void releaseflag()
{
for (int i = 0; i {
for (int j = 0; j {
flag[i][j] = 0;
}
}
}
int getid(int x)
{
if (x == 0)return IDB_B0;
else if (x == 2)return IDB_B2;
else if (x == 4)return IDB_B4;
else if (x == 8)return IDB_B8;
else if (x == 16)return IDB_B16;
else if (x == 32)return IDB_B32;
else if (x == 64)return IDB_B64;
else if (x == 128)return IDB_B128;
else if (x == 256)return IDB_B256;
else if (x == 512)return IDB_B512;
else if (x == 1024)return IDB_B1024;
else if (x == 2048)return IDB_B2048;
else if (x = 4096)return IDB_B4096;
}
void up_clicked()
{
for (int k = 0; k < max_n; k++) {
for (int i = 1; i< max_n; i++) {
for (int j = 0; j < max_n; j++) {
if (map[i - 1][j] == 0) {
if (map[i][j] != 0) {
map[i - 1][j] = map[i][j];
map[i][j] = 0;
}
}
else
{
if (map[i][j] == map[i - 1][j])
{
if (flag[i][j] == 0)
{
map[i - 1][j] *= 2;
score += map[i - 1][j];
map[i][j] = 0;
n = i;
while (n > 0)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 25088 2018-04-27 18:52 GAME2048\.vs\GAME2048\v14\.suo
文件 1920056 2018-04-27 14:02 GAME2048\Debug\bj1.bmp
文件 2953728 2018-04-27 18:45 GAME2048\Debug\GAME2048.exe
文件 383148 2018-04-27 18:45 GAME2048\Debug\GAME2048.ilk
文件 1044480 2018-04-27 18:45 GAME2048\Debug\GAME2048.pdb
文件 40054 2018-04-27 13:52 GAME2048\GAME2048\0.bmp
文件 40054 2018-04-27 13:52 GAME2048\GAME2048\1024.bmp
文件 40054 2018-04-27 13:51 GAME2048\GAME2048\128.bmp
文件 40054 2018-04-27 13:51 GAME2048\GAME2048\16.bmp
文件 40054 2018-04-27 13:51 GAME2048\GAME2048\2.bmp
文件 40054 2018-04-27 13:51 GAME2048\GAME2048\2048.bmp
文件 40054 2018-04-27 13:51 GAME2048\GAME2048\256.bmp
文件 40054 2018-04-27 13:51 GAME2048\GAME2048\32.bmp
文件 40054 2018-04-27 13:51 GAME2048\GAME2048\4.bmp
文件 40054 2018-04-27 13:51 GAME2048\GAME2048\4096.bmp
文件 40054 2018-04-27 13:51 GAME2048\GAME2048\521.bmp
文件 40054 2018-04-27 13:51 GAME2048\GAME2048\64.bmp
文件 40054 2018-04-27 13:51 GAME2048\GAME2048\8.bmp
文件 1920056 2018-04-27 13:51 GAME2048\GAME2048\bj1.bmp
文件 294 2018-04-27 18:45 GAME2048\GAME2048\Debug\GAME2048.log
文件 2410816 2018-04-27 18:45 GAME2048\GAME2048\Debug\GAME2048.res
文件 2194 2018-04-27 18:44 GAME2048\GAME2048\Debug\GAME2048.tlog\CL.command.1.tlog
文件 84652 2018-04-27 18:44 GAME2048\GAME2048\Debug\GAME2048.tlog\CL.read.1.tlog
文件 2018 2018-04-27 18:44 GAME2048\GAME2048\Debug\GAME2048.tlog\CL.write.1.tlog
文件 195 2018-04-27 18:45 GAME2048\GAME2048\Debug\GAME2048.tlog\GAME2048.lastbuildstate
文件 2566 2018-04-27 18:45 GAME2048\GAME2048\Debug\GAME2048.tlog\li
文件 6316 2018-04-27 18:45 GAME2048\GAME2048\Debug\GAME2048.tlog\li
文件 982 2018-04-27 18:45 GAME2048\GAME2048\Debug\GAME2048.tlog\li
文件 494 2018-04-27 18:45 GAME2048\GAME2048\Debug\GAME2048.tlog\rc.command.1.tlog
文件 5940 2018-04-27 18:45 GAME2048\GAME2048\Debug\GAME2048.tlog\rc.read.1.tlog
............此处省略33个文件信息
相关资源
- FTP课程设计(服务端+客户端)
-
AN_BLE-SDKDH-C1_Teli
nk BLE SDK DeveloperHan - Python全栈学习笔记面向对象大作业:
- 高频电子线路课程设计报告收音机
- 直流稳压电源的课程设计、安装及调
- EDA课程设计_密码锁
- 单片机课程设计 篮球计分器
- 数据结构课程设计 6 1 彩票系统
- 端口扫描课程设计详细的报告
- LzmaLib
- 步进电机课程设计(个人设计)
- 校园网络规划与设计课程设计
- 编译原理课程设计:词法语法编译器
-
simuli
nk 课程设计 qpsk - 武汉理工大学 单片机课程设计 16*16点
- 数据库VFP课程设计
- 分页系统模拟实验 操作系统 课程设
- 模拟段页式虚拟存储管理中地址转换
- 硬件课程设计—流水灯(quartus软件
- 超市收银系统eclipse access大学课程设计
- 航空订票系统_数据结构课程设计
- 图书借阅管理信息系统
- c 课程设计 职工信息管理系统
- 汇编语言,课程设计,红绿灯
- 机床液压系统课程设计卧式钻床动力
- 课程设计蔬菜大棚自动控制系统,包
- 密码学课程设计:DES加密解密算法的
- 操作系统课程设计完整版
- 磁盘调度算法的模拟实现及对比
- PL/0功能扩充break功能
评论
共有 条评论