-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplant.cpp
More file actions
38 lines (29 loc) · 881 Bytes
/
plant.cpp
File metadata and controls
38 lines (29 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "plant.h"
#include"position.h"
#include <QPoint>
#include <QPixmap>
#include <QPainter>
const QSize Plant::ms_fixedSize(60,52);
Plant::Plant(QPoint pos, Window1 *game, const QPixmap &sprite)
:
m_attackRange(100)
, m_damage(10)
, m_fireRate(1000)
, m_rotationSprite(0.0)
, m_game(game)
, m_pos(pos)
, m_sprite(sprite)
{
}
void Plant:: draw(QPainter *painter) const{
painter->save();
//painter->setPen(Qt::black);
// 绘制攻击范围
//painter->drawEllipse(m_pos, m_attackRange, m_attackRange);
// 绘制偏转坐标,由中心+偏移=左上
static const QPoint offsetPoint(-ms_fixedSize.width()/3.5, -ms_fixedSize.height());
// 绘制炮塔并选择炮塔
painter->translate(m_pos);
painter->drawPixmap(offsetPoint, m_sprite);
painter->restore();
}