【VC开源代码栏目提醒】:网学会员在VC开源代码频道为大家收集整理了Els.cpp提供大家参考,希望对大家有所帮助!
// Els.cpp: implementation of the CEls class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "games.h"
#include "Els.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CEls::CEls()
{
m_Hotp = (-1, -1);
m_nType = -1;
m_nMoveType = -1;
m_nOldType = -1;
}
CEls::CEls(UINT nType, int x, int y)
{
m_Hotp = m_Oldp = CPoint(x, y);
m_nType = nType;
m_nMoveType = m_nOldType = 1;
}
CEls::~CEls()
{
}
void CEls::SetMoveType(int off)
{
m_nOldType = m_nMoveType;
m_nMoveType += off;
if(m_nMoveType == 5)
m_nMoveType = 1;
else if(m_nMoveType == 0)
m_nMoveType = 4;
}
void CEls::SetMoveType()
{
m_nOldType = m_nMoveType;
// m_Oldp = m_Hotp;
}
void CEls::SetHotPoint(int xOff, int yOff)
{
// m_Oldp = m_Hotp;
m_Hotp.x += xOff;
m_Hotp.y += yOff;
}
int CEls::GetPointNum()
{
int re;
switch(m_nType)
{
case 0: // *****
re = 5;
break;
case 1:
case 2:
case 3:
case 4:
re = 4;
break;
case 5:
case 6:
case 7:
re = 6;
break;
case -1: //NULL
re =0;
break;
}
return re;
}
CPoint CEls::GetPoint(int num, BOOL b)
{
CPoint reP(0,0);
int xOff = 0;
int yOff = 0;
UINT nType;
if(b)
nType = m_nMoveType;
else
nType = m_nOldType;
switch(m_nType)
{
case 0:
if(nType == 1 || nType == 3) // *****
xOff = 24 * (num - 2);
else
yOff = 24 * (num - 2);
break;
case 1:
if(nType == 1)
// *
// * *
// *
{
if(num < 3)
yOff = 24 * (num - 1);
else
xOff = 24;
}
else if(nType == 2)
// *
// * * *
{
if(num < 3)
xOff = 24 * (num - 1);
else
yOff = -24;
}
else if(nType == 3)
// *
// * *
// *
{
if(num < 3)
yOff = 24 * (num - 1);
else
xOff = -24;
}
else if(nType == 4)
// * * *
// *
{
if(num < 3)
xOff = 24 * (num - 1);
else
yOff= 24;
}
break;
case 2:
if(nType == 1 || nType == 3)
// * *
// * *
{
if(num < 2)
xOff = 24 * (num - 1);
else
{
xOff = 24 * (num - 2);
yOff = 24;
}
}
else if(nType == 2 || nType == 4)
// *
// * *
// *
{
if(num < 2)
yOff = 24 * (1 - num);
else
{
xOff = 24;
yOff = 24 * (2 - num);
}
}
break;
case 3:
if(nType == 1 || nType == 3)
// * *
// * *
{
if(num < 2)
xOff = 24 * (1 - num);
else
{
xOff = 24 * (2 - num);
yOff = 24;
}
}
else if(nType == 2 || nType == 4)
// *
// * *
// *
{
if(num < 2)
yOff = 24 * (num - 1);
else
{
xOff = 24;
yOff = 24 * (num - 2);
}
}
break;
case 4: // **
// **
if(num <= 1)
xOff = 24 * num;
else
{
xOff = 24 * (num - 2);
yOff = 24;
}
break;
case 5: //***
// ***
if(nType == 1 || nType == 3)
{
if(num <= 2)
xOff = 24 * (num - 2);
else
{
xOff = 24 * (num - 3);
yOff = 24;
}
}
else if(nType == 2 || nType == 4)
// *
// *
// * *
// *
// *
{
if(num <= 2)
yOff = 24 * (2 - num);
else
{
yOff = 24 * (3 - num);
xOff = 24;
}
}
break;
case 6: // ***
// ***
if(nType == 1 || nType == 3)
{
if(num <= 2)
xOff = 24 * (num - 2);
else
{
xOff = 24 * (num - 3);
yOff = -24;
}
}
else if(nType == 2 || nType == 4)
// *
// *
// * *
// *
// *
{
if(num <= 2)
yOff = 24 * (num - 2);
else
{
yOff = 24 * (num - 3);
xOff = 24;
}
}
break;
case 7: // ***
// *
// *
if(nType == 1) // *
{
if(num <= 2)
xOff = 24 * (num - 2);
else
{
yOff = 24 * (num - 2);
}
}
else if(nType == 2) // ****
// *
// *
{
if(num <= 3)
xOff = 24 * num;
else
yOff = 24 * (num - 3);
}
else if(nType == 3) // *
// *
// *
// ***
{
if(num <= 3)
yOff = 24 * -num;
else
xOff = 24 * (num - 3);
}
else if(nType == 4)
// *
// *
// ****
{
if(num <= 3)
xOff = 24 * -num;
else
yOff = 24 * -(num - 3);
}
break;
case 10: // *****
// * *
// * *
if(nType == 1)
{
if(num <= 4)
xOff = 24 * (num - 2);
else if(num == 5 || num == 6)
{
xOff = 24 * 2;
yOff = 24 * (num - 4);
}
else if(num == 7 || num == 8)
{
xOff = 24 * -2;
yOff = 24 * (num - 6);
}
}
else if(nType == 2)
// * * *
// *
// *
// *
// * * *
{