-
Notifications
You must be signed in to change notification settings - Fork 1
/
Marinenemy.cpp
36 lines (33 loc) · 995 Bytes
/
Marinenemy.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
//
// Created by nikang on 1/31/17.
//
#include "Marinenemy.h"
#include "Wall.h"
#include <typeinfo>
#include <QDebug>
#include "explosion.h"
Marinenemy::Marinenemy(QString leftAddress, QString rightAddress, int height, int score, double vX)
: EnemyObject(leftAddress, rightAddress, height,score, vX)
{
}
void Marinenemy::advance(int phase)
{
QList<QGraphicsItem *> colliding_items = collidingItems();
for(int i = 0 , n = colliding_items.size() ; i < n ; i++ )
if(typeid(*colliding_items[i]) == typeid(Wall))
{
this->xPhys.setV(-1 * this->xPhys.getV());
if(this->xPhys.getV() > 0)
{
this->setPixmap(right);
this->setPos(mapToParent(5, 0));
}
else
{
this->setPixmap(left);
this->setPos(mapToParent(-5, 0));
}
return;
}
this->setPos(mapToParent(xPhys.movement(), ScreenPhys.movement()));
}