Removed debug messages.
[kgcqgv.git] / element.cpp
blobaa59c08b9c9562b7e7a55c99685c516b38dbbf0a
1 #include "element.h"
2 #include <KDebug>
4 Element::Element(SCENE* scene, const QPoint& point)
5 : m_position(point - size() / 2.0)
7 #ifdef USE_KGC
8 m_item = new KGameCanvasRectangle(Qt::red, QSize(size().x(), size().y()), scene);
9 m_item->moveTo(point - size() / 2);
10 m_item->show();
11 #else
12 m_item = scene->addRect(QRect(QPoint(0, 0), QSize(size().x(), size().y())), Qt::NoPen, Qt::red);
13 m_item->setPos(point - size() / 2);
14 #endif
16 m_velocity.setX(((double)rand() / RAND_MAX) * 0.1);
17 m_velocity.setY(((double)rand() / RAND_MAX) * 0.1);
20 Element::~Element() { delete m_item; }
22 QPointF Element::position() const { return m_position; }
24 QPointF Element::velocity() const { return m_velocity; }
26 void Element::setPosition(const QPointF& pos) {
27 m_position = pos;
28 #ifdef USE_KGC
29 m_item->moveTo(m_position.toPoint() - size() / 2);
30 #else
31 m_item->setPos(m_position - size() / 2);
32 #endif
35 void Element::setVelocity(const QPointF& vel) {
36 m_velocity = vel;
39 QPoint Element::size() const {
40 return QPoint(30, 30);