📄 playership.cpp
字号:
#include "PlayerShip.h"
CPlayerShip::CPlayerShip(void)
{
m_nLevel = 1;
m_nShipType = Lugger;
m_nSpeed = 2;
m_nDirection = 0;
m_nBulletCount = 0;
m_nShipCount = 3;
m_timeOnReef = 0;
}
CPlayerShip::~CPlayerShip(void)
{
}
// Re born ///////////////////////////////////////////////////
void CPlayerShip::Reborn()
{
}
// Move fuctions /////////////////////////////////////////////
void CPlayerShip::MoveUp(CGameResource *&pResource)
{
if (NULL != pResource)
{
// Change the texture of player
if (1 == m_nLevel)
{
m_pTexture = pResource->m_textureWarship[0].m_pTexture;
m_nWidth = pResource->m_textureWarship[0].m_nWidth;
m_nHeight = pResource->m_textureWarship[0].m_nHeight;
}
else
{
m_pTexture = pResource->m_textureWarship[28].m_pTexture;
m_nWidth = pResource->m_textureWarship[28].m_nWidth;
m_nHeight = pResource->m_textureWarship[28].m_nHeight;
}
m_nY -= m_nSpeed;
}
}
void CPlayerShip::MoveRight(CGameResource *&pResource)
{
if (NULL != pResource)
{
if (1 == m_nLevel)
{
m_pTexture = pResource->m_textureWarship[1].m_pTexture;
m_nWidth = pResource->m_textureWarship[1].m_nWidth;
m_nHeight = pResource->m_textureWarship[1].m_nHeight;
}
else
{
m_pTexture = pResource->m_textureWarship[29].m_pTexture;
m_nWidth = pResource->m_textureWarship[29].m_nWidth;
m_nHeight = pResource->m_textureWarship[29].m_nHeight;
}
m_nX += m_nSpeed;
}
}
void CPlayerShip::MoveDown(CGameResource *&pResource)
{
if (NULL != pResource)
{
if (1 == m_nLevel)
{
m_pTexture = pResource->m_textureWarship[2].m_pTexture;
m_nWidth = pResource->m_textureWarship[2].m_nWidth;
m_nHeight = pResource->m_textureWarship[2].m_nHeight;
}
else
{
m_pTexture = pResource->m_textureWarship[30].m_pTexture;
m_nWidth = pResource->m_textureWarship[30].m_nWidth;
m_nHeight = pResource->m_textureWarship[30].m_nHeight;
}
m_nY += m_nSpeed;
}
}
void CPlayerShip::MoveLeft(CGameResource *&pResource)
{
if (NULL != pResource)
{
if (1 == m_nLevel)
{
m_pTexture = pResource->m_textureWarship[3].m_pTexture;
m_nWidth = pResource->m_textureWarship[3].m_nWidth;
m_nHeight = pResource->m_textureWarship[3].m_nHeight;
}
else
{
m_pTexture = pResource->m_textureWarship[31].m_pTexture;
m_nWidth = pResource->m_textureWarship[31].m_nWidth;
m_nHeight = pResource->m_textureWarship[31].m_nHeight;
}
m_nX -= m_nSpeed;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -