You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#include "enemy.h"
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QGraphicsScene>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "game.h"
|
|
|
|
#include "health.h"
|
|
|
|
|
|
|
|
extern Game* game;
|
|
|
|
|
|
|
|
Enemy::Enemy()
|
|
|
|
{
|
|
|
|
int random_number = rand() % 700;
|
|
|
|
setPos(random_number,0);
|
|
|
|
setRect(0,0,100,100);
|
|
|
|
QTimer* timer = new QTimer();
|
|
|
|
connect(timer, SIGNAL(timeout()), this, SLOT(move()));
|
|
|
|
timer->start(50);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Enemy::move()
|
|
|
|
{
|
|
|
|
this->setPos(x(), y()+5);
|
|
|
|
if(pos().y() > 600) {
|
|
|
|
game->health->decrease();
|
|
|
|
scene()->removeItem(this);
|
|
|
|
delete this;
|
|
|
|
qDebug() << "bullet deleted";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|