使用C语言+EasyX完成消灭星星游戏(3)
本篇介绍方块消除后,方块下落移动。
#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); //判断方块附近颜色是否一样
void rectanglefall(void); //方块下落移动
int main() {
initgraph(700, 700);//初始化窗口
game();
playgame();
system("pause");
return 0;
}
void game() {
loadimage(&bgImage, "../Project2/bg2.2.jpg", 700, 700);//取背景图
putimage(0, 0, &bgImage);//放置背景图
setfillcolor(RGB(0, 0, 0));
fillrectangle(150, 0, 550, 700);//黑色背景
settextstyle(15, 0, _T(""));
settextcolor(RGB(255, 255, 255));
outtextxy(10, 10, "hello,");
srand