当前位置:网站首页>2022年6月11日记:王老师的春天,混入
2022年6月11日记:王老师的春天,混入
2022-06-12 23:41:00 【屯门山鸡叫我小鸡】
推荐一个 零声学院 免费公开课程,个人觉得老师讲得不错,分享给大家:[Linux,Nginx,ZeroMQ,MySQL,Redis,fastdfs,MongoDB,ZK,流媒体,CDN,P2P,K8S,Docker,TCP/IP,协程,DPDK等技术内容,立即学习]
后台服务器:https://course.0voice.com/v1/course/intro?courseId=5&agentId=0
ANSER
template <typename...T>
class role : public T... //把传入的模板参数当做该类模板的父类
{
public:
role() : T()..., m_attack(0.0), m_defence(0.0), m_life(100.0) {
}//初始时攻击力防御力都为0,血量100;
role(double att, double def, double life) : T()..., m_attack(att), m_defence(def), m_life(life) {
}
public:
double m_attack; //攻击力
double m_defence; //防御力
double m_life; //血量(生命值)
};
template <typename...T>
class family
{
public:
vector< role<T...> > m_members;
//....其他信息
};
using role_npc = role<npcattr>;
using role_player = role<playerattr>;
using role_mixnpc = role<npcattr,playerattr>; //通过混入技术方便的组合,自由的装配各种功能
using family_npc = family<npcattr>;
这种编程方法解决了以下的问题,可以说是谁用谁知道。
//role角色类,代表玩家,包括攻击力,防御力,血量(生命值):
class role
{
public:
//构造函数:
role() :m_attack(0.0), m_defence(0.0), m_life(100.0) {
}//初始时攻击力防御力都为0,血量100;
role(double att,double def,double life):m_attack(att), m_defence(def), m_life(life) {
}
public:
double m_attack; //攻击力
double m_defence; //防御力
double m_life; //血量(生命值)
//......
};
class family
{
public:
vector<role> m_members;
//....其他信息
};
//怪物、NPC(非玩家角色)。 NPC分类:0:代表装饰游戏场景的这种NPC,1:代表商人,卖服装。2:代表把游戏任务派送给玩家。 自言自语的说话。
template<typename T>
class family
{
public:
//vector<role> m_members;
vector<T> m_members;
//....其他信息
};
//npc属性类
struct npcattr
{
int m_sort; //npc种类:0:代表装饰游戏场景的这种NPC,1:代表商人,卖服装。2:代表把游戏任务派送给玩家。
std::string m_lang; //记录自言自语的一句话
};
NPC类
class role_npc :public role
{
public:
//构造函数
role_npc(): role(), m_strucattr{
0,"" }{
}
role_npc(double att, double def, double life, int sort, std::string lang) :role(att, def, life), m_strucattr{
sort,lang } {
}
public:
npcattr m_strucattr;
};
边栏推荐
- Record 5 - the serial port of stm32f411ceu6 realizes the sending and receiving of fixed length data and variable length data
- 2202 resume making
- 移动安全必备之CS呢【NETHUNTER】
- For product managers, which of the two certificates, PMP and NPDP, is more authoritative?
- Case sharing of online real queuing system reconfiguration -- practical part
- leaflet如何加载10万条数据
- Common message oriented middleware selection
- Actual combat | inductance element positioning -- detailed explanation of Halcon and opencv implementation (with source code)
- 2022 operation of simulated examination platform for hoisting machinery command certificate
- Colab tutorial (super detailed version) and colab pro/colab pro+ usage evaluation
猜你喜欢

Leetcode 2164. 对奇偶下标分别排序(可以,一次过)

Running of NCF dapr application instance

Test platform series (97) perfect the case part

Talent Weekly - 5

leaflet如何优雅的展示重叠点位的气泡窗口

Operation of simulation test platform for G3 boiler water treatment test questions in 2022

Deep feature synthesis and genetic feature generation, comparison of two automatic feature generation strategies

Colab tutorial (super detailed version) and colab pro/colab pro+ usage evaluation

For product managers, which of the two certificates, PMP and NPDP, is more authoritative?

Introduction to message oriented middleware (message queue)
随机推荐
设计消息队列存储消息数据的 MySQL 表格
Don't write about the full screen explosion, try the decorator mode, this is the elegant way!!
2022年危險化學品經營單比特安全管理人員考試試題及在線模擬考試
TCP与UDP
Summary of MySQL foundation view
Heilongjiang Branch and Liaoning Branch of PostgreSQL Chinese community have been established!
2202-簡曆制作
Pytorch common parameter initialization methods: [uniform distribution, normal (Gaussian) distribution, Xavier, Kaiming, orthogonal matrix, sparse matrix, constant, identity matrix, zero filling]
Find out the data that can match the keyword key in field 1 or field 2 in the database table. If you want to display the matching data in field 1 first
Pytorch中的梯度累加【在实验时,由于GPU显存限制,遇到batch_size不能再增大的情况。为解决该问题,使用梯度累加方法】
Comprehensive analysis of C array
Lua loop statement
利率降低导致债券价格上涨
array
leaflet如何加载10万条数据
36 krypton's debut | "osogena" won nearly ten million angel rounds of financing. The original DLR scientists of German Aerospace Research and development system modeling and simulation CAE software PA
Industry reshuffle, a large number of programmers are going to lose their jobs? How can we break the current workplace dilemma
CS for mobile security [nethunter]
Hongmeng starts 2
scala中的隐式转换和隐式参数讲解与实践