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

📄 playerlevelstate.cpp

📁 VIGASOCO (VIdeo GAmes SOurce COde) Windows port (v0.01)
💻 CPP
字号:
// PlayerLevelState.cpp
//
/////////////////////////////////////////////////////////////////////////////

#include <algorithm>
#include "PlayerLevelState.h"

/////////////////////////////////////////////////////////////////////////////
// initialization and cleanup
/////////////////////////////////////////////////////////////////////////////

PlayerLevelState::PlayerLevelState()
{
	resetState();
}

PlayerLevelState::~PlayerLevelState()
{
}

void PlayerLevelState::resetState()
{
	diffEntry = 0;
	firstFruit = secondFruit = false;
	eatenPills = 0;

    pinkGhostHomeCounter = blueGhostHomeCounter = orangeGhostHomeCounter = 0;

	easierFlag = false;
	currentLevel = 0;

	lives = 0;
	displayedLives = 0;

	for (int i = 0; i < 240; i++){
		normalPills[i] = false;
	}

	superPills[0] = superPills[1] = superPills[2] = superPills[3] = 0;
}

/////////////////////////////////////////////////////////////////////////////
// player and level state management
/////////////////////////////////////////////////////////////////////////////

void PlayerLevelState::initPills()
{
	// init pills
	for (int i = 0; i < 240; i++){
		normalPills[i] = true;
	}

	// init super pills
	superPills[0] = superPills[1] = superPills[2] = superPills[3] = 0x14;
}

void PlayerLevelState::clone(PlayerLevelState *p)
{
	// copy player state
	diffEntry = p->diffEntry;
	firstFruit = p->firstFruit;
	secondFruit = p->secondFruit;
	eatenPills = p->eatenPills;
	pinkGhostHomeCounter = p->pinkGhostHomeCounter;
	blueGhostHomeCounter = p->blueGhostHomeCounter;
	orangeGhostHomeCounter = p->orangeGhostHomeCounter;
	easierFlag = p->easierFlag;
	currentLevel = p->currentLevel;
	lives = p->lives;
	displayedLives = p->displayedLives;

	// copy player pills
	for (int i = 0; i < 240; i++){
		normalPills[i] = p->normalPills[i];
	}

	// copy player super pills
	for (int i = 0; i < 4; i++){
		superPills[i] = p->superPills[i];
	}
}

void PlayerLevelState::swapState(PlayerLevelState *p)
{
	// swap player state
	std::swap<int>(diffEntry, p->diffEntry);
	std::swap<bool>(firstFruit, p->firstFruit);
	std::swap<bool>(secondFruit, p->secondFruit);
	std::swap<int>(eatenPills, p->eatenPills);
	std::swap<int>(pinkGhostHomeCounter, p->pinkGhostHomeCounter);
	std::swap<int>(blueGhostHomeCounter, p->blueGhostHomeCounter);
	std::swap<int>(orangeGhostHomeCounter, p->orangeGhostHomeCounter);
	std::swap<bool>(easierFlag, p->easierFlag);
	std::swap<int>(currentLevel, p->currentLevel);
	std::swap<int>(lives, p->lives);
	std::swap<int>(displayedLives, p->displayedLives);

	// swap player pills
	for (int i = 0; i < 240; i++){
		std::swap<bool>(normalPills[i], p->normalPills[i]);
	}

	// swap player super pills
	for (int i = 0; i < 4; i++){
		std::swap<int>(superPills[i], p->superPills[i]);
	}
}

⌨️ 快捷键说明

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