gameobjects.cpp

来自「游戏编程精华02-含有几十个游戏编程例子」· C++ 代码 · 共 50 行

CPP
50
字号
/* Copyright (C) Bruce Dawson, 2001. 
 * All rights reserved worldwide.
 *
 * This software is provided "as is" without express or implied
 * warranties. You may freely copy and compile this source into
 * applications you distribute provided that the copyright text
 * below is included in the resulting source code, for example:
 * "Portions Copyright (C) Bruce Dawson, 2001"
 */
#include "priv_precompiled.h"

#include "gameobjects.h"
#include "imagelibrary/csbitmap.h"
#include "gamelibrary/microthreads.h"
using namespace MicroThread;

GameObject::GameObject()
	: m_pSprite(0), m_thread(0), m_x(0), m_y(0), m_deadFrames(0)
{
}

void GameObject::RenderSelf(CSBitmap* pBitmap)
{
	assert(pBitmap);
	assert(pBitmap->HasBitmap());
	if (m_pSprite)
		CompositeBitmap(pBitmap, m_pSprite, int(m_x), int(m_y));
}

static void MICROTHREADCALL RunMicroThread(void* pVoid)
{
	GameObject* pObject = (GameObject*)pVoid;
	pObject->MicroThreadProcess();
}

void GameObject::PostConstructorInit()
{
	m_thread = CreateMicroThread(RunMicroThread, this);
}

void GameObject::RunThread()
{
	SwitchToMicroThread(m_thread);
}

void GameObject::MicroThreadProcess()
{
	// Do nothing - just return.
}

⌨️ 快捷键说明

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