首页 > 其他 > 详细

团队作业

时间:2018-06-28 19:00:51      阅读:176      评论:0      收藏:0      [点我收藏+]

思路描述

此次任务我负责两个部分,一是技能类,并对一些人物数值和英雄数值进行权衡,二是精灵类,对每个精灵的贴图进行汇总并绘制。
设计实现过程及代码说明
==========
精灵类头文件
sprite.h
~~~

pragma once

include

include

include

include

include

include

include

class sprite
{
public:
sprite(int num, int be)//精灵图片的数量 开始的位置
{
pic_num = num;
begin = be;
}
sprite() {
}
~sprite() {
}
int pic_num;//图片数量
int begin;
void show(int x, int y, int index, HDC hdc, CImage pic[])//index 0 开始
{
pic[(index%pic_num) + begin].Draw(hdc, x, y);
}
void show(int x, int y, int index, HDC hdc, CImage pic[], int w, int h)//重载
{
pic[(index%pic_num) + begin].Draw(hdc, x, y, w, h);
}
void show(int x, int y, int index, HDC hdc, CImage pic[], int w, int h, int Px, int Py, int Pw, int Ph)// 重载
{
pic[(index%pic_num) + begin].Draw(hdc, x, y, w, h, Px, Py, Pw, Ph);
}
};
~~~
一开始设计的精灵类只是用来存储各个精灵的图片,经过改善后,把所有的精灵图片按照编号存储在专门的数组里面,用指针来访问它,pic_num表示该精灵有多少的图片,begin表示其起始位置,这样就能访问该精灵的所有图集。
重载了三个show函数用于对图像的绘制,有些图形会发生改变,如血条蓝条的长短,需要进行重载绘制,第一个为普通的绘制,第二个为只有某些固定方向变化的图形绘制,如各个物体的血条等,第三个为多个方向都变化的图形绘制,如大字火(某个技能)会随着移动慢慢变大。
精灵类cpp文件
sprite.cpp
~~~

include "sprite.h"

include

include

include

include

include

include

所有的描述都在头文件中,这部分没有什么实际的内容。
技能类头文件
skill.h

pragma once

include

include

include

include

include

include

include

include

include

include

include"skill.h"

define red 0

define blue 1

define so_big 99999

class hero;
class Army;
class hurt;
class tower;
using namespace std;
class skill
{
public:
skill() {}
skill(int who_, sprite SPR_atk_[]);
~skill() {}
int CD, cost;//技能CD和消耗
int who;//技能编号
sprite Spr_ani;//技能图标和技能效果
void skill_use(hero
, list<hurt>&, long long&);// 使用者 伤害列表 编号
bool can_use_skill(int cd_, int mp_);//可以使用当前技能

};
~~~
该部分include许多相关作用的文件,并进行了一些必要的声明。
技能类cpp文件
skill.cpp
~~~

include "sprite.h"

include"skill.h"

include

include

include

include

include

include

include

include

include

include

include

include

include

include"hero.h"

include"hurt.h"

include"Army.h"

include "tower.h"

using namespace std;

pragma once

define red 0

define blue 1

skill::skill(int who_, sprite SPR_atk_[])
{
who = who_;
Spr_ani = SPR_atk_;

if (who_ == 1)
{
    CD = 10;
    cost = 10;
}
if (who_ == 2)
{
    CD = 10;
    cost = 10;
}
if (who_ == 3)
{
    CD = 10;
    cost = 10;
}
if (who_ == 4)
{
    CD = 10;
    cost = 10;
}
if (who_ == 5)
{
    CD = 10;
    cost = 10;
}
if (who_ == 6)
{
    CD = 10;
    cost = 10;
}
if (who_ == 7)
{
    CD = 10;
    cost = 10;
}
if (who_ == 8)
{
    CD = 10;
    cost = 10;
}
if (who_ == 9)
{
    CD = 10;
    cost = 10;
}
if (who_ == 10)
{
    CD = 10;
    cost = 10;
}
if (who_ == 11)
{
    CD = 10;
    cost = 10;
}
if (who_ == 12)
{
    CD = 10;
    cost = 10;
}

}

/
Spr_skills_atk[0] = Spr_bullet_blue;//特效精灵
Spr_skills_atk[1] = Spr_bullet_red;
Spr_skills_atk[2] = Spr_bullet_green;
Spr_skills_atk[3] = Spr_fire;
Spr_skills_atk[4] = Spr_Million_tons;
Spr_skills_atk[5] = Spr_powder;
Spr_skills_atk[6] = Spr_Iron_wall;
Spr_skills_atk[7] = Spr_BIG;
Spr_skills_atk[8] = Spr_Sun_Flame;
Spr_skills_atk[9] = Spr_knife;
/

void skill::skill_use(hero user, list(Spr_ani + 2), user->atk, user, user->fx));
user->sleep = 1;
user->weak_time = 5;//技能硬直

}
else if (who == 4)//百万吨拳击
{
    int tx, ty;
    int ax, ay;
    ax = user->x + user->wide;
    ay = user->y + user->hight;
    if (user->fx == 0)
    {
        tx = ax + 24;
        ty = ay - 24 - 16;
    }
    if (user->fx == 90)
    {
        tx = ax - 16;
        ty = ay - 24 - 64;
    }
    if (user->fx == 180)
    {
        tx = ax - 24 - 32;
        ty = ay - 24 - 16;
    }
    if (user->fx == 270)
    {
        tx = ax - 16;
        ty = ay + 24;
    }
    Magic.push_back(hurt(tx, ty, user->color, object_ID++, 3, *(Spr_ani + 4), user->atk, user, user->fx));
    user->sleep = 1;
    user->weak_time = 5;//技能硬直
}
else if (who == 5)//催眠粉
{
    int tx, ty;
    tx = user->x + 24 - 32;
    ty = user->y + 24 - 32;
    Magic.push_back(hurt(tx, ty, user->color, object_ID++, 2, *(Spr_ani + 5), 0, user, user->fx));
    user->sleep = 1;
    user->weak_time = 5;//技能硬直
}
else if (who == 6)//大字爆
{
    int tx, ty;
    tx = user->x + 24;
    ty = user->y + 24;
    Magic.push_back(hurt(tx, ty, user->color, object_ID++, 5, *(Spr_ani + 7), user->atk, user, user->fx));
    user->sleep = 1;
    user->weak_time = 5;//技能硬直
}
else if (who == 7)//飞叶快刀
{
    int tx, ty;
    tx = user->x;
    ty = user->y;
    for (int i = 0; i<360; i += 45)
        Magic.push_back(hurt(tx, ty, user->color, object_ID++, 6, *(Spr_ani + 9), user->atk, user, i));
    user->sleep = 1;
    user->weak_time = 5;//技能硬直
}
else if (who == 8)//喷射火焰
{
    int tx, ty;
    tx = user->x + 24 - 16;
    ty = user->y + 24 - 16;
    Magic.push_back(hurt(tx, ty, user->color, object_ID++, 9, *(Spr_ani + 3), user->atk, user, user->fx));
    user->sleep = 1;
    user->weak_time = 5;//技能硬直
}
else if (who == 9)//阳光烈焰
{
    int tx, ty;
    tx = user->x + 24 - 80;
    ty = user->y + 24 - 80;
    Magic.push_back(hurt(tx, ty, user->color, object_ID++, 4, *(Spr_ani + 8), user->atk, user, user->fx));
    user->sleep = 1;
    user->weak_time = 20;//技能硬直
}
else if (who == 10)//铁壁
{
    user->wudi = 1;
    user->wudi_time = 50;
}
else if (who == 11)//泡泡攻击
{
    int tx, ty;
    tx = user->x + 24 - 16;
    ty = user->y + 24 - 16;
    Magic.push_back(hurt(tx, ty, user->color, object_ID++, 1, *(Spr_ani), user->atk, -1, user));
    user->sleep = 1;
    user->weak_time = 5;//技能硬直
}
else//水炮
{
    int tx, ty, fx_;
    tx = user->x + 24 - 16;
    ty = user->y + 24 - 16;
    fx_ = user->fx;

    Magic.push_back(hurt(tx, ty, user->color, object_ID++, 7, *(Spr_ani), user->atk, user, fx_));
    Magic.push_back(hurt(tx, ty, user->color, object_ID++, 7, *(Spr_ani), user->atk, user, (fx_ + 45) % 360));
    Magic.push_back(hurt(tx, ty, user->color, object_ID++, 7, *(Spr_ani), user->atk, user, (fx_ - 45 + 360) % 360));

    user->sleep = 1;
    user->weak_time = 5;//技能硬直
}

}
bool skill::can_use_skill(int cd_, int mp_) {
if (cd_ >= CD && mp_ >= cost)
return true;
return false;
}
~~~
第一部分对各个技能进行初始化,who表示技能编号用于识别,检索编号,赋予对应的cd和蓝耗。
第二部分为各个技能的相关描述hero *user用于对英雄自身有作用的技能时的指针,list

团队作业

原文:https://www.cnblogs.com/ljj237085795/p/9240165.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!