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

📄 plist.cpp

📁 应朋友邀请,写的一个纯C++的五子棋游戏,用到了windows的sdk
💻 CPP
字号:
// PList.cpp: implementation of the CPList class.
//
//////////////////////////////////////////////////////////////////////

#include "PList.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CPList::CPList()
{
	head = tail = NULL;
	size = 0;
}

CPList::~CPList()
{

}

void CPList::AddTail(Play &play)
{
	if (size == 0)
	{
		head = new Play;
		memcpy(head,&play,sizeof(Play));
		head->next = NULL;
		tail = head;
	}
	else
	{
		Play *p = new Play;
		memcpy(p,&play,sizeof(Play));
		tail->next = p;
		tail = p;
		tail->next = NULL;
	}
	size++;
}

int CPList::GetSize()
{
	return size;
}

Play* CPList::GetNext(Play *pl)
{
	if (pl == NULL)
	{
		return head;
	}
	else if (pl->next != NULL)
	{
		return pl->next;
	}
	return NULL;
}

Play* CPList::GetFirst()
{
	return head;
}

void CPList::RemoveAll()
{
	Play *p;

	for (int i=0; i<size; i++)
	{
		p = head->next;
		delete head;
		head = p;
	}
	size = 0;
}

Play* CPList::Find(POINT point)
{
	Play *p = NULL;
	for (int i=0; i<size; i++)
	{
		p = GetNext(p);
		POINT base;
		base.x = p->x;
		base.y = p->y;
		if (IsInRect(base,point))
		{
			return p;
		}
	}
	return NULL;
}

BOOL CPList::IsInRect(POINT base, POINT point)
{
	if ((point.x>=base.x) && (point.x<=(base.x+space)) && (point.y>=base.y) && (point.y<=base.y+space))
	{
		return TRUE;
	}
	return FALSE;
}

⌨️ 快捷键说明

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