void DrawGame(Gdiplus::Graphics &graphics, Game &currentGame)
{
	// Draw background.
	graphics.FillRectangle(MY_WHITE_BRUSH, 0, 0, MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT);
	
	// Draw end.
	const MazeState &currentMazeState = currentGame.CurrentState();
	
	graphics.FillRectangle(
		WEAK_BLACK_BRUSH,
		static_cast<INT>(currentMazeState.end[0] * MAZE_GRID_CELL_SIZE + 2),
		static_cast<INT>(currentMazeState.end[1] * MAZE_GRID_CELL_SIZE + 2),
		static_cast<INT>(MAZE_GRID_CELL_SIZE - 5),
		static_cast<INT>(MAZE_GRID_CELL_SIZE - 5));
	
	// Draw player.
	graphics.FillEllipse(
		MY_RED_BRUSH,
		static_cast<INT>(currentMazeState.currentPosition[0] * MAZE_GRID_CELL_SIZE + 2),
		static_cast<INT>(currentMazeState.currentPosition[1] * MAZE_GRID_CELL_SIZE + 2),
		static_cast<INT>(MAZE_GRID_CELL_SIZE - 4),
		static_cast<INT>(MAZE_GRID_CELL_SIZE - 4));
	
	// Draw maze jumps.
	int numJumps = currentMazeState.jumps.size();
	for (int i = 0; i < numJumps; ++i) {
		graphics.FillEllipse(
			MY_BLUE_BRUSH,
			static_cast<INT>(currentMazeState.jumps[i].array[0] * MAZE_GRID_CELL_SIZE + 3),
			static_cast<INT>(currentMazeState.jumps[i].array[1] * MAZE_GRID_CELL_SIZE + 3),
			static_cast<INT>(MAZE_GRID_CELL_SIZE - 5),
			static_cast<INT>(MAZE_GRID_CELL_SIZE - 5));
	}
	
	// Draw maze.
	graphics.DrawRectangle(
		MY_BLACK_PEN,
		0, 0,
		MAZE_GRID_CELL_SIZE * MAZE_GRID_WIDTH, MAZE_GRID_CELL_SIZE * MAZE_GRID_HEIGHT);
	
	for (int j = 0; j < MAZE_GRID_HEIGHT; ++j) {
		for (int i = 0; i < MAZE_GRID_WIDTH; ++i) {
			if (currentMazeState.cellFlags[j][i] & CELL_WALL_UP) {
				graphics.DrawLine(
					MY_BLACK_PEN,
					static_cast<INT>(MAZE_GRID_CELL_SIZE * i), static_cast<INT>(MAZE_GRID_CELL_SIZE * j),
					static_cast<INT>(MAZE_GRID_CELL_SIZE * (i+1)), static_cast<INT>(MAZE_GRID_CELL_SIZE * j));
			}
			if (currentMazeState.cellFlags[j][i] & CELL_WALL_LEFT) {
				graphics.DrawLine(
					MY_BLACK_PEN,
					static_cast<INT>(MAZE_GRID_CELL_SIZE * i), static_cast<INT>(MAZE_GRID_CELL_SIZE * j),
					static_cast<INT>(MAZE_GRID_CELL_SIZE * i), static_cast<INT>(MAZE_GRID_CELL_SIZE * (j+1)));
			}
		}
	}
}
Beispiel #2
0
		void fill_ellipse(ft x, ft y, ft w, ft h)
		{
			Gdiplus::SolidBrush* brush = new Gdiplus::SolidBrush(*color);
			graphics->FillEllipse(brush, Gdiplus::Rect((st)x, (st)y, (st)w, (st)h));
			delete brush;
		}
//
//	Draw overlay 
//
PLUGIN_EXPORT void PluginUpdateOverlay()
{
	if (!pRenderHelper)
		return;

	//SAFE_DELETE(pFPSNormalBrush);
	//pFPSNormalBrush = new Gdiplus::SolidBrush(Gdiplus::Color(255, 255, 255, 255));
	if (bFirstAttach) {
		bFirstAttach = false;
		PC_StartRecording();
		PC_DebugPrint(L"Triggered");
	}
	else {
		PC_DebugPrint(L"Not Triggered");
	}
	// lock overlay image
	auto pLock = pRenderHelper->BeginFrame();
	if (!pLock)
		return;

	int w = pLock->dwWidth;
	int h = pLock->dwHeight;

	Gdiplus::Graphics *pGraphics = pRenderHelper->GetGraphics();

	//-----------------------------------------
	// draw FPS counter

	// set options
	//pGraphics->SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAlias);

	// clear back
	pGraphics->Clear(Gdiplus::Color(0, 0, 0, 0));




	// draw fps
	{
		Gdiplus::RectF bound;
		//bound.
		int circleSize = 0;
		if (w < h) {
			circleSize = w;
		}
		else {
			circleSize = h;
		}
		if (PC_IsRecording()) {
			pGraphics->FillEllipse(pFPSRecordBrush, 0, 0, circleSize, circleSize);
		}
		else if (bShowWhenNotRecording) {
			pGraphics->FillEllipse(pFPSNormalBrush, 0, 0, circleSize, circleSize);
		}
	}


	//	graphics.Flush(FlushIntentionSync);

	// fill overlay image
	pRenderHelper->EndFrame();
}
void Graphics::FillEllipse(Brush* brush, const Rect& rc) {
    Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private);
    Gdiplus::Brush* gdiBrush = reinterpret_cast<Gdiplus::Brush*>(brush->_private);
    g->FillEllipse(gdiBrush, ToGDIRect<Rect, Gdiplus::Rect>(rc));
}