资源简介
C语言基础项目,C语言多关卡设计,C语言可视化编程,C语言可视化推箱子
代码片段和文件信息
/*
1.基本绘图窗口
2.基本贴图
3.二维数组制作小游戏地图
4.按键处理:用户交互方式
5.多关卡设计:三维数组的使用
*/
#define _CRT_SECURE_NO_WARNINGS
#include
#include
#include
//1.二位数组把地图绘制出来
int map[3][7][8] =
{
1 1 1 1 1 1 1 1
1 3 4 0 0 4 3 1
1 0 1 0 1 1 0 1
1 0 0 5 4 3 0 1
1 0 1 0 1 1 0 1
1 3 4 0 0 4 3 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 3 4 0 0 4 3 1
1 0 1 0 1 1 0 1
1 3 4 5 4 3 0 1
1 0 1 0 1 1 0 1
1 3 4 0 0 4 3 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 3 4 0 0 4 3 1
1 0 1 0 4 3 0 1
1 3 4 5 4 3 0 1
1 0 1 0 1 1 0 1
1 3 4 0 0 4 3 1
1 1 1 1 1 1 1 1
};
IMAGE img[6];
int cos = 0; //控制关卡
//0.bmp 1.bmp 3.bmp
int imgURLIndex[6] = { 0 1 3 4 5 7 };
void loadResource()
{
//批处理
for (int i = 0; i < 6; i++)
{
char fileName[20] = ““;
//printf:打印到屏幕
//0.bmp 1.bmp
sprintf(fileName “%d.bmp“ imgURLIndex[i]);
loadimage(img + i fileName);
}
}
void drawMap()
{
int x y;
for (int i = 0; i < 7; i++)
{
for (int j = 0; j < 8; j++)
{
x = 64 * j;
y = 64 * i;
switch (map[cos][i][j])
{
case 0:
putimage(x y img + 0);
break;
case 1:
putimage(x y img + 1);
break;
case 3:
putimage(x y img + 2);
break;
case 4:
putimage(x y img + 3);
break;
case 5:
case 8:
putimage(x y img + 4);
break;
case 7:
putimage(x y img + 5);
break;
}
}
}
}
void keyDown()
{
//定位人在哪里?
int i j; //数组中值是5和8 时候是人
for (i = 0; i < 7; i++)
{
for (j = 0; j < 8; j++)
{
if (map[cos][i][j] == 5 || map[cos][i][j] == 8)
{
break; //break跳出一层循环
}
}
if (map[cos][i][j] == 5 || map[cos][i][j] == 8)
{
break;
}
}
char userKey = _getch();
//小键盘:72 80 75 77
switch (userKey)
{
case ‘w‘:
case ‘W‘:
case 72:
//什么时候能动?上面是空地0或者目的地3
if (map[cos][i - 1][j] == 0 || map[cos][i - 1][j] == 3)
{
//能走是怎么走的
map[cos][i][j] -= 5;
map[cos][i - 1][j] += 5;
}
//是箱子 :4 箱子+目的:7
else if (map[cos][i - 1][j] == 4 || map[cos][i - 1][j] == 7)
{
if (map[cos][i - 2][j] == 0 || map[cos][i - 2][j] == 3)
{
//能走是怎么走的
map[cos][i][j] -= 5;
map[cos][i - 1][j] += 1;
map[cos][i - 2][j] += 4;
}
}
break;
case ‘s‘:
case ‘S‘:
case 80:
if (map[cos][i + 1][j] == 0 || map[cos][i + 1][j] == 3)
{
//能走是怎么走的
map[cos][i][j] -= 5;
map[cos][i + 1][j] += 5;
}
//是箱子 :4 箱子+目的:7
else if (map[cos][i + 1][j] == 4 || map[cos][i + 1][j] == 7)
{
if (map[cos][i + 2][j] == 0 || map[cos][i + 2][j] == 3)
{
//能走是怎么走的
map[cos][i][j] -= 5;
map[cos][i + 1][j] += 1;
map[cos][i + 2][j] += 4;
}
}
break;
case ‘A‘:
case ‘a‘:
case 75:
if (map[cos][i][j - 1] == 0 || map[cos][i][j - 1] == 3)
{
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 109056 2019-04-03 21:36 myBoxGame\Debug\myBoxGame.exe
文件 683544 2019-04-03 21:36 myBoxGame\Debug\myBoxGame.ilk
文件 789504 2019-04-03 21:36 myBoxGame\Debug\myBoxGame.pdb
文件 31744 2019-04-03 20:41 myBoxGame\Debug\二维数组.exe
文件 227020 2019-04-03 20:41 myBoxGame\Debug\二维数组.ilk
文件 445440 2019-04-03 20:41 myBoxGame\Debug\二维数组.pdb
文件 103424 2019-04-03 20:30 myBoxGame\Debug\绘图窗口.exe
文件 678772 2019-04-03 20:30 myBoxGame\Debug\绘图窗口.ilk
文件 781312 2019-04-03 20:30 myBoxGame\Debug\绘图窗口.pdb
文件 12344 2018-10-15 16:17 myBoxGame\myBoxGame\0.bmp
文件 12344 2018-10-15 16:17 myBoxGame\myBoxGame\1.bmp
文件 12344 2018-10-15 16:17 myBoxGame\myBoxGame\3.bmp
文件 12344 2018-10-15 16:17 myBoxGame\myBoxGame\4.bmp
文件 12344 2018-10-15 16:17 myBoxGame\myBoxGame\5.bmp
文件 12344 2018-10-15 16:17 myBoxGame\myBoxGame\7.bmp
文件 1780 2019-04-03 21:36 myBoxGame\myBoxGame\Debug\myBoxGame.log
文件 41815 2019-04-03 21:36 myBoxGame\myBoxGame\Debug\myBoxGame.obj
文件 714 2019-04-03 21:36 myBoxGame\myBoxGame\Debug\myBoxGame.tlog\cl.command.1.tlog
文件 18300 2019-04-03 21:36 myBoxGame\myBoxGame\Debug\myBoxGame.tlog\CL.read.1.tlog
文件 800 2019-04-03 21:36 myBoxGame\myBoxGame\Debug\myBoxGame.tlog\CL.write.1.tlog
文件 1432 2019-04-03 21:36 myBoxGame\myBoxGame\Debug\myBoxGame.tlog\li
文件 2724 2019-04-03 21:36 myBoxGame\myBoxGame\Debug\myBoxGame.tlog\li
文件 768 2019-04-03 21:36 myBoxGame\myBoxGame\Debug\myBoxGame.tlog\li
文件 253 2019-04-03 21:36 myBoxGame\myBoxGame\Debug\myBoxGame.tlog\myBoxGame.lastbuildstate
文件 519168 2019-04-03 21:36 myBoxGame\myBoxGame\Debug\vc120.idb
文件 167936 2019-04-03 21:36 myBoxGame\myBoxGame\Debug\vc120.pdb
文件 4482 2019-04-03 21:36 myBoxGame\myBoxGame\myBoxGame.cpp
文件 3385 2019-04-03 20:17 myBoxGame\myBoxGame\myBoxGame.vcxproj
文件 950 2019-04-03 20:17 myBoxGame\myBoxGame\myBoxGame.vcxproj.filters
文件 32899072 2019-04-03 21:42 myBoxGame\myBoxGame.sdf
............此处省略46个文件信息
- 上一篇:水库优化调度c++builder程序
- 下一篇:完整socket c++
相关资源
- 105个C语言编程代码
- 心电信号检测C语言编写的程序
- ATM(用C语言编写)的
- C语言编写的中国象棋源代码
- C++ 推箱子 源代码
- TC3TurboC 是一款优秀的C语言编程软件,
- 推箱子小游戏 c++ wxwidgets code:blocks
- C语言写的推箱子游戏
- C语言编写的象棋源码范例
- 用C++语言编写一个班级信息管理系统
- Qt版推箱子源码-鼠标键盘功能都有
- C语言编写的电子地图管理系统
- C语言编的数据库管理系统DBMS
- 用C++语言编写数学常用算法修订版光
- 华为C++语言编程规范
- Win-TCwindows下的C语言编程工具
- 单片机C语言编程与
- 32位单片机C语言编程:基于PIC32中文
- VC6绿色完整版
- cfree5.0破解版
- 实用C语言编程第三版.[美]Steve Oualli
- PL/0语言编译器源代码及测试代码
- STC15增强型8051单片机C语言编程与应用
- C语言编写的仿QQ局域网通讯程序
- C语言推箱子游戏有注释文档
- Windows环境下socket编程C语言编写
- 32位单片机C语言编程:基于PIC32.pdf
- c语言编写的自助旅游系统学校课设
- 单片机C语言编程与(PDF高清版)
- 嵌入式系统高级C语言编程.凌明(带详
评论
共有 条评论