当前位置:网站首页>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;
};
边栏推荐
- KConfig
- Model over fitting - solution (II): dropout
- Gradient accumulation in pytorch [during the experiment, due to the limitation of GPU video memory, the batch\u size can no longer be increased. To solve this problem, the gradient accumulation method
- Abstract methods and abstract classes
- 2202-简历制作
- How about opening a securities account in flush? Is it safe or not
- 2022年危險化學品經營單比特安全管理人員考試試題及在線模擬考試
- Modify the text color of the menu on the right of toobar
- Tableau
- [SciPy optimization tutorial] v. quick solution of univariate function optimization
猜你喜欢
Teach you how to grab ZigBee packets through cc2531 and parse encrypted ZigBee packets
数组
Summary of MySQL foundation view
[kubernetes guide ④] pod quick start
〖Kubernetes指南④〗Pod快速入门
Deep feature synthesis and genetic feature generation, comparison of two automatic feature generation strategies
Comprehensive analysis of C array
测试平台系列(97) 完善执行case部分
[opencv learning] perspective transformation matrix
M_ 8: Design a MySQL table for message queue to store message data
随机推荐
人脸检测:MTCNN
MYSQL 行转列、列转行、多列转一行、一行转多列
RT thread quick start - experience RT thread
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
Restrictions on MySQL function creation
It is meaningful to define genus, and D can use it to explain semantics
PostgreSQL 中文社区黑龙江分会和辽宁分会成立啦!
2022起重机械指挥上岗证题目模拟考试平台操作
2022年危险化学品经营单位安全管理人员考试试题及在线模拟考试
How about opening a securities account in flush? Is it safe or not
Access static variables within class in swift
Deep feature synthesis and genetic feature generation, comparison of two automatic feature generation strategies
InfoQ geek media's 15th anniversary solicitation | brief introduction to the four challenges of building a micro service architecture
OpenCV源代码编译
Pytorch common parameter initialization methods: [uniform distribution, normal (Gaussian) distribution, Xavier, Kaiming, orthogonal matrix, sparse matrix, constant, identity matrix, zero filling]
Develop a web office suite from scratch (5): mouse hover over text
基于Three.js海上风电数字孪生三维效果
NCF 的Dapr应用实例的运行
Preparing for the Blue Bridge Cup Day11__ Basic operation of serial port communication
SAP UI5 如何通过 manifest.json 文件定义第三方库依赖关系