使用C语言+EasyX完成消灭星星游戏(2)
上一篇简单介绍一下项目和创建游戏界面
本篇介绍如何达到消除方块的功能。具体思路,代码都有详细注释。
下一篇消除同色方块后其他方块的下落。
#include<stdio.h>
#include<graphics.h>
#include<time.h>
#include <conio.h>
#include <mmsystem.h>
#pragma comment(lib,"Winmm.lib")
#pragma warning(disable:4996)
#define N 40
IMAGE bgImage;//游戏页面背景图片
IMAGE RegbgImage;//注册页面背景图片
IMAGE nowImage; //当前
MOUSEMSG m; //鼠标
COLORREF colorArr[6] = {
RGB(200, 0, 0), RGB(0, 200, 0),
RGB(0, 200, 200), RGB(200, 0, 200),RGB(200,200,0) };//颜色池
typedef struct position
{
int x;
int y;
}posType; //位置信息
posType mou; //鼠标位置结构体
posType sameArr[100]; //同色方块坐标
int index = 0; //同色方块个数
void game(void); //初始化游戏界面
void playgame(void); //游戏玩法
void getsameclolr(posType, COLORREF);//获取同颜色的方块
int isValid(posType, COLORREF); //判断方块附近颜色是否一样
int main() {
initgraph(700, 700);//初始化窗口
game();
playgame()

这篇博客介绍了如何使用C语言结合EasyX库实现消灭星星游戏中消除方块的功能,包括思路和详细代码注释,为游戏开发系列的第二部分。
最低0.47元/天 解锁文章
630

被折叠的 条评论
为什么被折叠?



