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

📄 normal.h

📁 这个例子告诉你2d Arpg游戏中的动态阴影如何生成
💻 H
字号:
#ifndef normal_h
#define normal_h
#include <cassert>

#ifndef NULL
#ifdef  __cplusplus
#define NULL    0
#else
#define NULL    ((void *)0)
#endif
#endif

#define READ_MEMORY( pDataSrc, type ) (*(type *)pDataSrc)

#ifdef _DEBUG
#define debug_assert( c )	assert( c )
#else
#define debug_assert( c )	0
#endif

template <class T>
void SafeRelease( T &p )
{
	if ( p != NULL )
	{
		p->Release();
		p = NULL;
	}
}

template <class T>
void SafeFree( T &p )
{
	if ( p != NULL )
		p->Free();
}

template <class T>
void SafeDelete( T &p )
{
	if ( p != NULL )
	{
		delete p;
		p = NULL;
	}
}

template <class T>
void SafeDeleteArray( T &p )
{
	if ( p != NULL )
	{
		delete [] p;
		p = NULL;
	}
}

template <class T>
void Swap( T &t1, T &t2 )
{
	T temp;
	temp = t1;
	t1 = t2;
	t2 = temp;
}

template < class T >
void QuickSort( T a[], int iSize )
{
	if ( iSize <= 1 ) return;

	int iEnd = iSize - 1;

	T bound = a[iSize / 2];

	Swap( a[0], a[iSize / 2] );

	int i = 1; 

	while ( i <= iEnd )
	{
		if ( a[i] < bound )
		{
			Swap( a[i], a[iEnd] );
			--iEnd;
		}
		else
		{
			++i;
		}
	}
	Swap( a[0], a[i-1] );

	QuickSort( &a[0], i - 1 );

	QuickSort( &a[iEnd + 1], iSize - 1 - iEnd );
	
}

#endif

⌨️ 快捷键说明

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