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

📄 imager.cpp

📁 智力小游戏
💻 CPP
字号:


#include "hge.h"
#include "imager.h"


CImager::CImager(CGame* _game)
{
	Game = _game;
}

CImager::~CImager()
{
}

void CImager::LoadGraphics(HTEXTURE* tex)
{
	cells_tex = tex;
	fnt = new hgeFont("font1.fnt");
	
	for (int i=0;i<ROWS*COLUMNS-1;i++) {
		cell_sprs[i] = new hgeSprite(*cells_tex,i*40,0,40,40);
		cell_sprs[i]->SetHotSpot(20,20);
	}

	x =		DESK_X;
	y =		DESK_Y;
	curx =	-1;
	cury =	-1;
	scale = 2;
	angle = 0;
}


void CImager::DrawScene(int mousex, int mousey)
{
	int i,j,_x,_y,n;

	bool mouse_in = false;
	
	for (i=0;i<ROWS;i++)
	for (j=0;j<COLUMNS;j++)
	{
		n = Game->GetCell(i,j);
		
		_x = x+j*80;
		_y = y+i*80;
		

		hgeRect* rect = new hgeRect();
		if ((n >= 0) && (n < ROWS*COLUMNS-1))
		{
			cell_sprs[n]->GetBoundingBoxEx(_x,_y,scale,angle,rect);
			mouse_in = rect->TestPoint(mousex,mousey);
		} else
			mouse_in = false;
		
		
		if (mouse_in) {
			curx = j;
			cury = i;
			_x -= 3;
			_y -= 3;
		}

		if ((n >= 0) && (n < ROWS*COLUMNS-1))
		{
			if ((j == curx) && (i == cury))
			{
				cell_sprs[n]->SetColor(0xFFE83724);
				cell_sprs[n]->RenderEx(_x,_y,scale,angle-0.2);
			}
			else
			{
				cell_sprs[n]->SetColor(0xFFF1CA15);
				cell_sprs[n]->RenderEx(_x,_y,scale,angle);
			}
		}

		
	}
	DWORD tmp = Game->GetMoves();
	fnt->printf(30,20,"Moves counter: %d",tmp);
	fnt->printf(30,520,"Hold SHIFT - Move the Desk | A & Z - Scale Cells");
	fnt->printf(30,550,"Left Button - Move | Right Button - Mix | Space - Reset | Esc - Exit");

}


void CImager::Click(int mousex, int mousey)
{
	Game->MoveIt(cury,curx);		
}


⌨️ 快捷键说明

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