testresource.cpp

来自「这个是我第一次完成的一个简单的3D ALIEN SHOOTING GAME的RE」· C++ 代码 · 共 67 行

CPP
67 行
字号
// TestResource.cpp
//

// Author:			Lea Hayes
// Date Created:	10/03/2006
// Date Modified:	10/03/2006

#include "Common.h"
#include "TestResource.h"

using namespace Resources;


// TestResource - Construction and destruction.

TestResource::TestResource()
: x(NULL)
, y(NULL)
, z(NULL)
{
	// Random value will lie between -300.0f and 300.0f.
	float nMin = -300.0f, nMax = 300.0f;
	float nWidth = fabs(nMin) + fabs(nMax);

	// Generate three random values.
	float rand0and1 = (float)rand() / (float)RAND_MAX;
	x = rand0and1 * nWidth + nMin;

	rand0and1 = (float)rand() / (float)RAND_MAX;
	y = rand0and1 * nWidth + nMin;

	rand0and1 = (float)rand() / (float)RAND_MAX;
	z = rand0and1 * nWidth + nMin;
}

TestResource::~TestResource()
{
}


// TestResource - Functions which must be overriden.

void TestResource::OnProcess(float nTime)
{
}

void TestResource::OnRender(float nTime)
{
	// Render resource contents.
	printf("X = %+.2f,\tY = %+.2f,\tZ = %+.2f\n", x, y, z);
}

DWORD TestResource::GetUniqueID() const
{
	return CUSTOM_TESTRESOURCE;
}


// TestResource - Functions which can be overriden.

void TestResource::OnDestroy()
{
	// Test event call.
	printf("Destroying TestResource { X: %+.2f,\tY: %+.2f,\tZ: %+.2f }...\n",
		x, y, z);
}

⌨️ 快捷键说明

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