⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gameform.cpp

📁 俄罗斯方块
💻 CPP
字号:
#include "GameForm.h"

GameForm::GameForm(Rect r, Rect g,COLORREF bColor, COLORREF fColor,int size):Form(r,bColor,fColor)
{
	regionGrid = g;
	unitSize = size;
}
void GameForm::draw()const
{
	initgraph(480,520);
	IMAGE pic;
	getimage(&pic,"pic\\background.jpg");
	putimage(0,0,&pic);
}

void GameForm::eraseGrid(void)const
{
}
void GameForm::drawGrid(const Grid &grid)const
{
	int x=0,y=0;
	IMAGE pic;
	getimage(&pic,"pic\\7.jpg");
	for (int i=0; i<LINES; i++)
	{
		for (int j=0; j<COLUMNS; j++)
		{
			if (grid.isOccupied(i,j))
			{				
				x = regionGrid.x+j*unitSize;
				y = regionGrid.y+i*unitSize;
				putimage(x,y,&pic);	
			}
		}
	}
}

void GameForm::drawBox(const Box &box) const
{
	int x;
	int y;
	char filename[20];
	Coord location;
	BoxCode box_code;
	IMAGE img;
	box_code = box.getCode();
	location = box.getLocation();
	sprintf(filename,"pic\\%d.jpg",box.getBoxNo());
	getimage(&img,filename);
	for (int i=0; i<COLUMNS; i++)
	{
		if (box_code.test(COLUMNS-1-i) == 1)
		{
			x = regionGrid.x+(location.x+i%4)*unitSize;
			y = regionGrid.y+(location.y+i/4)*unitSize;
			putimage(x,y,&img);
		}
	}

}
void GameForm::eraseBox(const Box &box) const
{
	Coord location = box.getLocation();
    BoxCode code = box.getCode();
	int x=0,y=0;
		for (int i=0;i<16;i++)
		{
			if(code.test(15-i))
			{  
			 x=regionGrid.x+(location.x+i%4)*unitSize;
			 y=regionGrid.y+(location.y+i/4)*unitSize;
			 setfillstyle(backColor);
			 bar(x,y,x+unitSize,y+unitSize);
			}
		}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -