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

📄 player.cpp

📁 编译并且测试成功的虚拟机
💻 CPP
字号:
#include "stdafx.h"

#include "Player.h"
#include "Logger.h"

const int INTVAL_HP = 0;
const int INTVAL_SCORE = 1;
const int INTVAL_LOGMSG = 2;

// Declare the external variable:
Player* Player::theInstance = NULL;

Player::Player() {
  hp = 0;
  score = 0;
}


Player* Player::instance() {
	if (theInstance == NULL)
	  theInstance = new Player();
	  
	return theInstance;
}


void Player::setInt(const string& name, int nr, int value) {
  switch (nr) {
    case INTVAL_HP:
     hp = value;
     printf("hp: %i\n", hp);
     Log("hp: %i", hp);
     break;
    case INTVAL_SCORE:
     score = value;
     printf("score: %i\n", score);
     Log("score: %i", score);
     break;
    case INTVAL_LOGMSG:
     printf("%s\n", name.c_str());
     Log("%s", name.c_str());
     break;
    default:
     Log("ERROR - unknown player intval: %i", nr);
     break;
  }
}

⌨️ 快捷键说明

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