#include "Player.h" #include #include #include #include #include Tower::Tower() { // Set graphic image setElementId("Player"); /* // To play sounds soundEffect = new QSoundEffect(qApp); soundEffect->setSource(QUrl("qrc:/Resources/Sound.wav")); soundEffect->setVolume(0.98f); */ } Tower::~Tower() { } void Tower::setInitialPos() { // Place the player in the middle bottom of the scene qreal x = (scene()->width() - boundingRect().width()) * 0.5; qreal y = (scene()->height() - boundingRect().height()) * 0.5; setPos(x, y); } void Tower::keyPressEvent(QKeyEvent* event) { /* // Move this object if arrow keys are pressed if ( event->key() == Qt::Key_Left && x() ) moveLeft(); else if ( event->key() == Qt::Key_Right ) moveRight(); else if ( event->key() == Qt::Key_Up ) setPos( x(), y() - 10.0 ); else if ( event->key() == Qt::Key_Down ) setPos( x(), y() + 10.0 ); // Do something if the spacebar is pressed else if ( event->key() == Qt::Key_Space ) doSomething(); */ } void Tower::mousePressEvent(QGraphicsSceneMouseEvent* event) { // user clicked event->pos().x() and event->pos().y() }