From 1cf5a427a829b22abea7027b18a130a01da3ed6a Mon Sep 17 00:00:00 2001 From: Samu Laaksonen Date: Fri, 28 Sep 2012 22:36:58 +0300 Subject: Rename commit Renamed some files according the project name Added base directory structure for resources Changed more fitting parallax scrolled background to menus - added 3 new layers as resources Changed more cheerful buttons to menus Added base classes to build HUD later on Added one new test level that is size of 800*480 with tilesize of 32*32 --- src/BarDisplay.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/BarDisplay.cpp (limited to 'src/BarDisplay.cpp') diff --git a/src/BarDisplay.cpp b/src/BarDisplay.cpp new file mode 100644 index 0000000..edab1c9 --- /dev/null +++ b/src/BarDisplay.cpp @@ -0,0 +1,58 @@ +#include "BarDisplay.h" + +BarDisplay::BarDisplay(QGraphicsItem* parent) : + QGraphicsItem(parent) +{ + m_partCount = 4; + m_maxValue = 50; + m_value = 50; + + /* TODO: + initialize this item with some kind of rectangle graphics + that supports partitioning, e.g. + [ / / ] or such + */ +} + +BarDisplay::~BarDisplay() +{ +} + +void BarDisplay::collected(int amount) +{ + m_value += amount; + + if (m_value > m_maxValue) + m_value = m_maxValue; + + updateDisplay(); +} + +void BarDisplay::consumed(int amount) +{ + m_value -= amount; + + if (m_value < 0) + m_value = 0; + + updateDisplay(); +} + +void BarDisplay::setDisplayColor(QColor col) +{ + m_displayColor = col; +} + +void BarDisplay::updateDisplay() +{ + // TODO: update graphics so user knows he is hit +} + +QRectF BarDisplay::boundingRect() const +{ + return QRectF(); +} + +void BarDisplay::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ +} -- cgit v1.2.3