-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwingplane.cpp
38 lines (34 loc) · 980 Bytes
/
wingplane.cpp
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 "wingplane.h"
#include "gamecontroller.h"
#include <QPainter>
WingPlane::WingPlane(GameController &controller):
controller(controller),
cnt(0)
{
setData(GD_type, GO_WingPlane);
pixMap.load("://images/MyPlane.png");
}
QRectF WingPlane::boundingRect() const
{
int w = pixMap.width(), h = pixMap.height();
return QRectF(-w/2, -h/2, w, h);
}
void WingPlane::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option); Q_UNUSED(widget);
if(!pixMap.isNull()) {
painter->save();
painter->scale(0.8, 0.8);
int w = pixMap.width(), h = pixMap.height();
painter->drawPixmap(QPoint(-w/2, -h/2), pixMap);
painter->restore();
}
}
void WingPlane::advance(int phace)
{
if(!phace) return;
if(++cnt == 15) {
controller.shootWingBullet(controller.getPlantPos() + pos() + QPointF(0, -20));
cnt = 0;
}
}