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

📄 minimap.cpp

📁 小型的3D游戏引擎
💻 CPP
字号:
#include "minimap.h"


//////////////////////////////////////////////////////////////////////////////////

void GcMinimap::Load(GcTexture * land, uint mapWidth, int scale)
{
	// Save the pointer the the terrain's land texture
	minimap = land;

	// Calculate the scale multiplier
	scaler = (float)MINIMAP_WIDTH / (scale * mapWidth);
}

//////////////////////////////////////////////////////////////////////////////////

void GcMinimap::Draw(float sx, float sy)
{
	float x = sy * scaler;
	float y = sx * scaler;

	glPushMatrix();

		// Move to the correct palce
		glTranslatef(GcSettings::ScreenWidth() - 128, GcSettings::ScreenHeight() - 128, 0.0f);

		glColor3f(1.0f, 1.0f, 1.0f);

		// Set the correct texture
		minimap->Bind();

		// Draw the minimap
		glBegin(GL_QUADS);
			glTexCoord2f(0.0f, 1.0f); glVertex3f(0.0f, 0.0f, 0.0f);
			glTexCoord2f(0.0f, 0.0f); glVertex3f(MINIMAP_WIDTH, 0.0f, 0.0f);
			glTexCoord2f(1.0f, 0.0f); glVertex3f(MINIMAP_WIDTH, MINIMAP_WIDTH, 0.0f);
			glTexCoord2f(1.0f, 1.0f); glVertex3f(0.0f, MINIMAP_WIDTH, 0.0f);
		glEnd();

		glColor3f(1.0f, 0.0f, 0.0f);

		glPointSize(5.0f);

		// No texture bound
		glBindTexture(GL_TEXTURE_2D, NULL);

		// Draw the location point
		glBegin(GL_POINTS);
			glVertex3f(x, y, 0.0f);
		glEnd();

	glPopMatrix();
}

//////////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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