YTU 2635: P4 游戏中的Human角色
2635: P4 游戏中的Human角色
时间限制: 1 Sec 内存限制: 128 MB
提交: 524 解决: 328
题目描述
{
loc.setXY(rx,ry);
}
void Role::addBlood(int b)
{
blood+=b;
}
输入
输出
样例输入
Avanda 500 1000 4 3
-300
200
2 5
样例输出
Avanda has 500 attack and 1000 blood in (4,3)
Avanda has 200 attack and 1200 blood in (2,5)
迷失在幽谷中的鸟儿,独自飞翔在这偌大的天地间,却不知自己该飞往何方……
#include <iostream>
using namespace std;
class Location
{
private:
int x, y;
public:
Location(int a, int b):x(a),y(b) {}
int getX()
{
return x;
}
int getY()
{
return y;
}
void setXY(int a,int b)
{
x=a;
y=b;
}; //设置位置坐标
};
class Role
{
public:
Role(int rblood, int rx, int ry):blood(rblood),loc(rx,ry) {}
void moveTo(int rx, int ry); //移动到(rx, ty)处,要改变loc的值
void addBlood(int b); //增加血量,参数为负时,代表减少
protected:
int blood;
Location loc;
};
void Role::moveTo(int rx, int ry)
{
loc.setXY(rx,ry);
}
void Role::addBlood(int b)
{
blood+=b;
}
class Human:public Role,public Location
{
public:
Human(string na,int att,int rblood,int rx,int ry):Location(rx,ry),Role(rblood,rx,ry),name(na),attack(att) {}
void show()
{
cout<<name<<" has "<<attack<<" attack and "<<blood<<" blood in ("<<getX()<<","<<getY()<<")"<<endl;
}
void addAttack(int a)
{
attack+=a;
}
void addBlood(int b)
{
Role::addBlood(b);
}
void moveTo(int rx,int ry)
{
Location::setXY(rx,ry);
}
private:
string name; // 姓名
int attack; // 攻击力
};
int main()
{
string name;
int att, blood, x, y;
cin>>name>>att>>blood>>x>>y;
Human hum(name,att,blood,x,y); //人name的攻击力att,血量blood,在(x,y)处
hum.show();
int incAtt, incBlood, newx, newy ;
cin>>incAtt;
cin>>incBlood;
cin>>newx>>newy;
hum.addAttack(incAtt); //攻击力增加incAtt
hum.addBlood(incBlood); //血量增加incBlood
hum.moveTo(newx,newy); //人移到了(news,newy)处
hum.show();
return 0;
}
#include <iostream>
using namespace std;
class Location
{
private:
int x, y;
public:
Location(int a, int b):x(a),y(b) {}
int getX()
{
return x;
}
int getY()
{
return y;
}
void setXY(int a,int b)
{
x=a;
y=b;
}; //设置位置坐标
};
class Role
{
public:
Role(int rblood, int rx, int ry):blood(rblood),loc(rx,ry) {}
void moveTo(int rx, int ry); //移动到(rx, ty)处,要改变loc的值
void addBlood(int b); //增加血量,参数为负时,代表减少
protected:
int blood;
Location loc;
};
void Role::moveTo(int rx, int ry)
{
loc.setXY(rx,ry);
}
void Role::addBlood(int b)
{
blood+=b;
}
class Human:public Role,public Location
{
public:
Human(string na,int att,int rblood,int rx,int ry):Location(rx,ry),Role(rblood,rx,ry),name(na),attack(att) {}
void show()
{
cout<<name<<" has "<<attack<<" attack and "<<blood<<" blood in ("<<getX()<<","<<getY()<<")"<<endl;
}
void addAttack(int a)
{
attack+=a;
}
void addBlood(int b)
{
Role::addBlood(b);
}
void moveTo(int rx,int ry)
{
Location::setXY(rx,ry);
}
private:
string name; // 姓名
int attack; // 攻击力
};
int main()
{
string name;
int att, blood, x, y;
cin>>name>>att>>blood>>x>>y;
Human hum(name,att,blood,x,y); //人name的攻击力att,血量blood,在(x,y)处
hum.show();
int incAtt, incBlood, newx, newy ;
cin>>incAtt;
cin>>incBlood;
cin>>newx>>newy;
hum.addAttack(incAtt); //攻击力增加incAtt
hum.addBlood(incBlood); //血量增加incBlood
hum.moveTo(newx,newy); //人移到了(news,newy)处
hum.show();
return 0;
}
YTU 2635: P4 游戏中的Human角色的更多相关文章
- 问题 C: P4 游戏中的Human角色
题目描述 在一个平面打斗游戏中,任何的角色(Role)都有血量(blood)和位置loc(此处loc是Location类的实例)属性.有了Role类,可以派生出不同的角色,如人.神仙.怪兽等.如下程序 ...
- 游戏中的人工智能——初探AI
一.游戏中的人工智能 让游戏具有挑战性: 让游戏好玩的关键因素是为之找到合适的难度等级: 人工智能在游戏中的作用是通过提供富有挑战性的竞争对象来让游戏更好玩,而在游戏中行动逼真的非玩家角色(NPC), ...
- Unity3D 游戏开发构架篇 ——角色类的设计与持久化
在游戏开发中,游戏角色占了很大的篇幅,可以说游戏中所有的内容都是由主角所带动.这里就介绍一下角色类的设计和持久化. 一.角色类应用场景和设计思想 游戏中的角色类型不一而足,有不同的技能,有不同的属性等 ...
- 《Genesis-3D开源游戏引擎完整实例教程-2D射击游戏篇05:角色中弹》
5.角色中弹 概述: 为了使游戏具有挑战性,大部分游戏设定中,游戏角色都有生命限制.即在游戏中,由于玩家的操控操控不当,导致游戏角色死亡游戏终止.打飞机游戏也不例外,当敌人击中角色的时候,角色宣判死亡 ...
- 论游戏中Buff的实现 [转]
论游戏中Buff的实现 分类: C/C++ 游戏开发2012-09-13 14:30 574人阅读 评论(6) 收藏 举报 c++游戏开发 源地址:http://blog.codingnow.com/ ...
- Unity3d中角色模型和角色名字保持相对位置
3D游戏中,经常遇到这样的情况.角色模型上需要显示角色名字或者血条等信息. 如果用一个摄像机会有可能出现名字或血条显示不正常等问题,所以我采用两个摄像机.一个渲染名字或血条等UI,另一个渲染角色模型. ...
- Unity优化方向——优化Unity游戏中的图形渲染(译)
CPU bound:CPU性能边界,是指CPU计算时一直处于占用率很高的情况. GPU bound:GPU性能边界,同样的是指GPU计算时一直处于占用率很高的情况. 原文:https://unity3 ...
- Unity 2D游戏开发教程之游戏中精灵的跳跃状态
Unity 2D游戏开发教程之游戏中精灵的跳跃状态 精灵的跳跃状态 为了让游戏中的精灵有更大的活动范围,上一节为游戏场景添加了多个地面,于是精灵可以从高的地面移动到低的地面处,如图2-14所示.但是却 ...
- 浅谈游戏中BUFF的设计要点
其实这类帖子并没有多少的设计理论,对于策划的提升和帮助也并不大,原因其实在于其适用性太窄,当我要设计XX象棋的时候,它就滚一边去了. 废话不多说切入正题: 游戏中的BUFF/DEBUFF我们见过很多, ...
随机推荐
- HDU - 4544 湫湫系列故事——消灭兔子(优先队列+贪心)
题目: 最近,减肥失败的湫湫为发泄心中郁闷,在玩一个消灭免子的游戏. 游戏规则很简单,用箭杀死免子即可. 箭是一种消耗品,已知有M种不同类型的箭可以选择,并且每种箭都会对兔子造成伤害,对应的伤害值分别 ...
- 中南大学2019年ACM寒假集训前期训练题集(入门题)
A: 漫无止境的八月 Description 又双叒叕开始漫无止境的八月了,阿虚突然问起长门在这些循环中团长哪几次扎起了马尾,他有多少次抓住了蝉等等问题,长门一共回复n个自然数,每个数均不超过1500 ...
- CSU1008: Horcrux
Description A Horcrux is an object in which a Dark wizard or witch has hidden a fragment of his or h ...
- Python 文件修改-函数介绍
上节课复习:1.字符编码 1.1 如何解决乱码问题: 字符存取使用的编码标准不一致 1.2 文件头 在文件的首行写入文件头,用于控制Python解释器读取py文件内容时使用的编码 #coding:文件 ...
- MT4系统自带指标代码
MT4系统自带指标代码 ~ Accelerator Oscillator 震荡加速指标: double iAC() ~ Accumulation/Distribut ...
- 杭电 1789 Doing Homework again (贪心 求最少扣分)
Description zichen has just come back school from the 30th ACM/ ICPC. Now he has a lot of homework t ...
- Web框架django进阶篇
分页 一.Django内置分页 from django.shortcuts import render from django.core.paginator import Paginator, Emp ...
- BNUOJ 1268 PIGS
PIGS Time Limit: 1000ms Memory Limit: 10000KB This problem will be judged on PKU. Original ID: 11496 ...
- C语言不容易识别的坑
1.重复两次定义 #include<stdio.h> #include<stdlib.h> #include<string.h> int a,b; void fun ...
- Network(poj 3694)
题意:一个无向图可以有重边,下面q个操作,每次在两个点间连接一条有向边,每次连接后整个无向图还剩下多少桥(注意是要考虑之前连了的边,每次回答是在上一次的基础之上) /* tarjan+LCA 先用ta ...