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

📄 person.cpp

📁 3D俄罗斯方块源码.rar
💻 CPP
字号:
/********************************************************************
文件名: PERSON.cpp
Copyright (c)2004  红孩儿工作室
创建人  : 卞安
创建时间: 2004-5-18 12:33:30
版本: 1.0
类名: CPERSON
说明:
	主角类
********************************************************************/
#include "PERSON.h"
#include <windows.h>
#include "BASIC.h"
#define CONTROLSPEED 85
void CALLBACK TimerProc2(HWND hWnd,UINT nMsg,UINT nTimerid,DWORD dwTime);
bool g_Bcan1;
bool g_Bcan2;
//---------------------------------------------------------------
bool CPERSON::SetPerson(int _type,HWND _hWnd,C2DSOUND *_sound,C2DSOUND *_sound2)
{
	m_hWnd=_hWnd;
	m_type=_type;
	m_sound=_sound;
	m_sound2=_sound2;
	return true;
}
bool CPERSON::Start(int _row,int _level,bool _isshownext,LPDIRECT3DDEVICE8 g_pD3DDevice)
{
	m_pD3DDevice=g_pD3DDevice;
	if(FAILED(m_map.init(m_type,_level,_row,_isshownext,g_pD3DDevice,m_hWnd,m_sound,m_sound2)))return false;
	srand(timeGetTime());
	m_nexttile.Start(rand()%8);
	m_map.SetNext(&m_nexttile);
	SetTimer(m_hWnd,51,CONTROLSPEED,TimerProc2);
	SetTimer(m_hWnd,52,CONTROLSPEED,TimerProc2);
	return true;
}
void CPERSON::Render()
{
    
	if(m_map.m_finish==false)
	{
		if(!m_map.m_Isdown)
		{
			m_map.m_Isdown=true;
			m_thistile.Start(m_nexttile.Getstyle());
			srand(timeGetTime());
			m_nexttile.Start(rand()%8+1);
			m_map.GoTop(&m_thistile);
			m_map.m_cancon=true;
		}
			if(m_type==1)
			{		
				if(m_map.m_cancon==true&&g_Bcan1==true)
				{
				switch(m_keyboard->ProcessKBInput())
				{	       
				case 10:
				case 11:
				case 12:
				case 13:
				case 14:
					m_map.RotateTile(&m_thistile);
					break;
				case 20:
				case 21:
				case 22:
				case 23:
				case 24:
					m_map.GoDown(&m_thistile);
					break;
				case 30:
				case 31:
				case 32:
				case 33:
				case 34:
					m_map.GoLeft(&m_thistile);
					break;
				case 40:
				case 41:
				case 42:
				case 43:
				case 44:
					m_map.GoRight(&m_thistile);
					break;
				case 50:
				case 51:
				case 52:
				case 53:
				case 54:
					m_map.StartGoButtom();
					break;
				}
				g_Bcan1=false;
				}
			}
			else
			{
				if(m_map.m_cancon==true&&g_Bcan2==true)
				{
				switch(m_keyboard->ProcessKBInput())
				{
				case 1:
				case 11:
				case 21:
				case 31:
				case 41:
					m_map.RotateTile(&m_thistile);
					break;
				case 2:
				case 12:
				case 22:
				case 32:
				case 42:
					m_map.GoDown(&m_thistile);
					break;
				case 3:
				case 13:
				case 23:
				case 33:
				case 43:
					m_map.GoLeft(&m_thistile);
					break;
				case 4:
				case 14:
				case 24:
				case 34:
				case 44:
					m_map.GoRight(&m_thistile);
					break;
				case 5:
				case 15:
				case 25:
				case 35:
				case 45:
				case 55:
                    m_map.StartGoButtom();
					break;
				}
				g_Bcan2=false;
			}
			}
	}	
	m_map.Render();	
}
CPERSON::~CPERSON()
{
	KillTimer(m_hWnd,51);
	KillTimer(m_hWnd,52);
}
void CPERSON::SetKeyBoard(CKEYBOARD *g_keyboard)
{
m_keyboard=g_keyboard;
}
void CPERSON::GoDown()
{
	m_map.GoDown(&m_thistile);
}
void CPERSON::TickGoLeft()
{
	m_map.GoLeft(&m_thistile);
}
void CPERSON::TickGoRight()
{
	m_map.GoRight(&m_thistile);
}
void CPERSON::TickChange()
{
	m_map.RotateTile(&m_thistile);
}
void CPERSON::ReLife()
{
	if(m_map.m_finish)
	{
	m_map.m_level=m_map.g_level;
	m_map.AddSpeed();
    m_map.m_score=0;
	m_map.CleanMap();
	m_map.m_finish=false;
	m_map.m_Isdown=true;
	}
}
void CALLBACK TimerProc2(HWND hWnd,UINT nMsg,UINT nTimerid,DWORD dwTime)
{
	switch(nTimerid)
	{
	case 51:
       g_Bcan1=true;
		break;
	case 52:
       g_Bcan2=true;
		break;
	}
}

⌨️ 快捷键说明

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