#include "bullet.h" #include #include Bullet::Bullet(QGraphicsItem *parent) { // set graphics setPixmap(QPixmap(":/images/missile.png")); QTimer *move_timer = new QTimer(this); connect(move_timer, SIGNAL(timeout()), this, SLOT(move())); move_timer->start(50); } void Bullet::move() { int STEP_SIZE = 30; int theta = rotation(); // degrees double dy = STEP_SIZE * qSin(qDegreesToRadians(theta)); double dx = STEP_SIZE * qCos(qDegreesToRadians(theta)); setPos(x()+dx, y()+dy); }