aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamu Laaksonen <laaksonen.sj@gmail.com>2012-12-10 23:47:03 +0200
committerSamu Laaksonen <laaksonen.sj@gmail.com>2012-12-10 23:47:03 +0200
commitad19e537066742e1a5f9bbb8c3549a47480a33c1 (patch)
tree2f48c08f22bea31756f784495d3c50cd9736e889
parent9674c5ea91912d07f4726140ca2c88669c03f874 (diff)
downloadprism-ad19e537066742e1a5f9bbb8c3549a47480a33c1.tar.gz
prism-ad19e537066742e1a5f9bbb8c3549a47480a33c1.zip
Box2d integration
Very crude and buggy Needs to be much better
-rw-r--r--concepts/hero_concept.png (renamed from data/gfx/hero_concept.png)bin2250 -> 2250 bytes
-rw-r--r--data/gfx/buttons/back-arrow-pressed.pngbin0 -> 3545 bytes
-rw-r--r--data/gfx/buttons/back-arrow.pngbin0 -> 3545 bytes
-rw-r--r--data/gfx/characters/hero/idle/hero_idle.pngbin0 -> 1996 bytes
-rw-r--r--libtiled/libtiled.pro3
-rw-r--r--prism.pro22
-rw-r--r--src/ActionScene.cpp654
-rw-r--r--src/ActionScene.h226
-rw-r--r--src/BarDisplay.h65
-rw-r--r--src/CircularDisplay.cpp172
-rw-r--r--src/CircularDisplay.h70
-rw-r--r--src/CreditsScene.cpp136
-rw-r--r--src/HeadsUpDisplay.cpp154
-rw-r--r--src/HeadsUpDisplay.h76
-rw-r--r--src/Hero.cpp242
-rw-r--r--src/Hero.h79
-rw-r--r--src/LevelSelectionScene.cpp210
-rw-r--r--src/Sprite.cpp216
-rw-r--r--src/common.h17
-rw-r--r--src/src.pro220
20 files changed, 1509 insertions, 1053 deletions
diff --git a/data/gfx/hero_concept.png b/concepts/hero_concept.png
index 2021c34..2021c34 100644
--- a/data/gfx/hero_concept.png
+++ b/concepts/hero_concept.png
Binary files differ
diff --git a/data/gfx/buttons/back-arrow-pressed.png b/data/gfx/buttons/back-arrow-pressed.png
new file mode 100644
index 0000000..f32e0cf
--- /dev/null
+++ b/data/gfx/buttons/back-arrow-pressed.png
Binary files differ
diff --git a/data/gfx/buttons/back-arrow.png b/data/gfx/buttons/back-arrow.png
new file mode 100644
index 0000000..f32e0cf
--- /dev/null
+++ b/data/gfx/buttons/back-arrow.png
Binary files differ
diff --git a/data/gfx/characters/hero/idle/hero_idle.png b/data/gfx/characters/hero/idle/hero_idle.png
new file mode 100644
index 0000000..252e5de
--- /dev/null
+++ b/data/gfx/characters/hero/idle/hero_idle.png
Binary files differ
diff --git a/libtiled/libtiled.pro b/libtiled/libtiled.pro
index c7730a3..9371ffb 100644
--- a/libtiled/libtiled.pro
+++ b/libtiled/libtiled.pro
@@ -13,7 +13,8 @@ macx {
DLLDESTDIR = ..
#win32:INCLUDEPATH += $$(QTDIR)/src/3rdparty/zlib
-win32:INCLUDEPATH += G:/QtSDK/QtSources/4.8.1/src/3rdparty/zlib
+#win32:INCLUDEPATH += I:/Qt/Qt5.0.0-rc1/5.0.0-rc1/Src/qtbase/src/3rdparty/zlib
+win32:INCLUDEPATH += I:/Qt/4.8.4/src/3rdparty/zlib
else:LIBS += -lz
DEFINES += QT_NO_CAST_FROM_ASCII \
diff --git a/prism.pro b/prism.pro
index 9035e94..a357f37 100644
--- a/prism.pro
+++ b/prism.pro
@@ -1,11 +1,11 @@
-#-------------------------------------------------
-#
-# Project created by QtCreator 2011-02-20T21:55:55
-#
-#-------------------------------------------------
-
-TEMPLATE = subdirs
-CONFIG += ordered
-
-SUBDIRS = libtiled \
- src
+#-------------------------------------------------
+#
+# Project created by QtCreator 2011-02-20T21:55:55
+#
+#-------------------------------------------------
+
+TEMPLATE = subdirs
+CONFIG += ordered
+
+SUBDIRS = src \
+ libtiled \
diff --git a/src/ActionScene.cpp b/src/ActionScene.cpp
index c10bcf6..436d2a8 100644
--- a/src/ActionScene.cpp
+++ b/src/ActionScene.cpp
@@ -1,281 +1,373 @@
-#include <QPainter>
-#include <QPainterPath>
-#include <QColor>
-#include <QBrush>
-#include <QDebug>
-#include <QGraphicsPixmapItem>
-#include <QGraphicsSceneMouseEvent>
-#include <QKeyEvent>
-
-#include <QSettings>
-
-#include <QApplication>
-#include <QTime>
-#include <QFileInfo>
-#include <QMessageBox>
-
-#include "MainWindow.h"
-#include "GameView.h"
-#include "Hero.h"
-#include "ParallaxScrollerStatic.h"
-#include "Collectible.h"
-#include "HeadsUpDisplay.h"
-
-#include "layer.h"
-#include "objectgroup.h"
-#include "mapobject.h"
-#include "tile.h"
-#include "tilelayer.h"
-
-#include "Box2D/Dynamics/b2World.h"
-
-#include "ActionScene.h"
-
-using Tiled::Map;
-using Tiled::MapReader;
-using Tiled::OrthogonalRenderer;
-using Tiled::Layer;
-using Tiled::ObjectGroup;
-using Tiled::Tile;
-using Tiled::TileLayer;
-
-ActionScene::ActionScene(const QString &name, const QRectF &rect, GameView *parent)
- : GameScene(name, parent)
-{
- setSceneRect(rect);
- m_clearAlert = false;
- m_mapReader = new Tiled::MapReader;
-
- m_map = 0;
- m_mapRenderer = 0;
-
- m_hud = new HeadsUpDisplay(sceneRect().width(), sceneRect().height(), this, this);
-
- // start setting up the world here
- //b2Vec2 gravity(0.0f, -10.0f);
- //m_physicalWorld = new b2World(gravity);
- //m_physicalWorld->SetAllowSleeping(true);
-
- // initialize rand here
- qsrand(QTime::currentTime().msec());
- // TODO: implement some logic to randomize color bubbles given to player
-
- //m_hero = new Hero(this, QPointF(100, 300));
- //connect(m_hero, SIGNAL(removeMe()), this, SLOT(removeSprite()));
-}
-
-ActionScene::~ActionScene()
-{
- if (m_map)
- delete m_map;
- if (m_mapReader)
- delete m_mapReader;
- if (m_mapRenderer)
- delete m_mapRenderer;
-
- if(m_physicalWorld)
- ;//delete m_physicalWorld;
-}
-
-void ActionScene::updateLogic()
-{
- if(!m_clearAlert)
- {
- advance();
- update();
- }
-}
-
-void ActionScene::keyPressEvent(QKeyEvent *event)
-{
- QGraphicsScene::keyPressEvent(event);
-
- switch(event->key())
- {
- // arrow up
- case 16777235:
- break;
- // arrow down
- case 16777237:
- break;
- // arrow left
- case 16777234:
- break;
- // arrow right
- case 16777236 :
- break;
- // button a
- case 65:
- break;
- // button s
- case 83:
- break;
- // button d
- case 68 :
- break;
- case 16777216 :
- gameView()->changeScene(gameView()->getScene("LevelSelectionScene"));
- break;
- default:
- qDebug() << event->key();
- break;
- }
-}
-
-void ActionScene::drawBackground(QPainter *painter, const QRectF &rect)
-{
-
-}
-
-void ActionScene::drawForeground(QPainter *painter, const QRectF &rect)
-{
- painter->drawPixmap(rect.x(), rect.y(), sceneRect().width(), sceneRect().height(), *m_hud);
-}
-
-void ActionScene::loadMap(QString target)
-{
- QFileInfo f(target);
- m_levelName = f.fileName();
-
- QSettings set;
- m_levelScore = set.value(m_levelName).toInt();
-
- m_map = m_mapReader->readMap(target);
-
- if (m_map == NULL)
- {
- qDebug() << "error:" << m_mapReader->errorString();
- return;
- }
-
- m_mapRenderer = new Tiled::OrthogonalRenderer(m_map);
-
- qDebug() << "size" << m_map->width() << "x" << m_map->height();
- qDebug() << "layers" << m_map->layerCount();
-
- for(int layer = 0; layer < m_map->layerCount(); layer++)
- {
- QString type = m_map->layerAt(layer)->property("type");
-
- if (type == "solid")
- {
- Tiled::TileLayer* solidTiles = NULL;
- solidTiles = m_map->layerAt(layer)->asTileLayer();
-
- for(int w = 0; w < solidTiles->width(); w++)
- {
- for (int h = 0; h < solidTiles->height(); h++)
- {
- Tiled::Cell cell;
- cell = solidTiles->cellAt(w, h);
-
- if(!cell.isEmpty())
- {
- QGraphicsPixmapItem *solidTile = new QGraphicsPixmapItem(0, this);
- solidTile->setData(ITEM_OBJECTNAME, QString("SolidGround"));
- solidTile->setPos(w * m_map->tileWidth(),
- h * m_map->tileHeight());
- solidTile->setZValue(1);
- solidTile->setPixmap(cell.tile->image());
- m_mapPixmapItems.append(solidTile);
- }
- }
- }
- }
- else
- {
- QImage img(m_map->width() * m_map->tileWidth(),
- m_map->height() * m_map->tileHeight(),
- QImage::Format_ARGB32);
-
- QPainter painter(&img);
- m_mapRenderer->drawTileLayer(&painter, m_map->layerAt(layer)->asTileLayer());
-
- QPixmap mapPixmap = QPixmap::fromImage(img);
- m_mapPixmaps.append(mapPixmap);
-
- qDebug() << "hasAlpha" << mapPixmap.hasAlpha() << "\n"
- << "hasAlphaChannel" << mapPixmap.hasAlphaChannel();
-
- QGraphicsPixmapItem* mapPixmapItem = addPixmap(mapPixmap);
- mapPixmapItem->setPos(0, 0);
- mapPixmapItem->setShapeMode(QGraphicsPixmapItem::MaskShape);
-
- mapPixmapItem->setPixmap(mapPixmap);
-
- if (type == "covering")
- {
- mapPixmapItem->setData(ITEM_OBJECTNAME, QString("Covering"));
- mapPixmapItem->setZValue(2);
- }
- else if (type == "coveringBg")
- {
- mapPixmapItem->setData(ITEM_OBJECTNAME, QString("CoveringBg"));
- mapPixmapItem->setZValue(-1);
- }
-
- m_mapPixmapItems.append(mapPixmapItem);
- }
- }
-
- QVector<QString> colors;
- colors.append("red"); colors.append("blue"); colors.append("green");
-
- for (int i = 0; i < colors.size(); i++)
- {
- Tiled::ObjectGroup* color = NULL;
-
- if(m_map->indexOfLayer(colors.at(i)) >= 0)
- color = m_map->layerAt(m_map->indexOfLayer(colors.at(i)))->asObjectGroup();
-
- if(color)
- {
- Q_FOREACH(Tiled::MapObject *obj, color->objects())
- {
- Collectible* colorbubble = new Collectible(0, this);
- colorbubble->setData(ITEM_OBJECTNAME, QString(colors.at(i)));
- connect(colorbubble, SIGNAL(removeMe()), this, SLOT(removeSprite()));
- colorbubble->setPos((obj->x()) * m_map->tileWidth(),
- (obj->y() - 1) * m_map->tileHeight());
-
- colorbubble->setZValue(1);
-
- qDebug() << obj->position() << colorbubble->pos();
- }
- }
- }
-
- m_clearAlert = false;
-}
-
-void ActionScene::unloadMap()
-{
- foreach(QGraphicsPixmapItem* removableItem, m_mapPixmapItems)
- {
- removeItem(removableItem);
- }
-
- for(int i = m_mapPixmapItems.size() - 1; i > 0; i++)
- delete m_mapPixmapItems.at(i);
-
- m_mapPixmapItems.clear();
-
- m_mapPixmaps.clear();
-
- if (m_mapRenderer)
- delete m_mapRenderer;
- if (m_map)
- delete m_map;
-}
-
-void ActionScene::removeSprite()
-{
- qDebug() << "removing a sprite";
-
- Sprite* sp = (Sprite*) sender();
- if(sp)
- {
- removeItem(sp);
- sp->deleteLater();
- }
-}
+#include <QPainter>
+#include <QPainterPath>
+#include <QColor>
+#include <QBrush>
+#include <QDebug>
+#include <QGraphicsPixmapItem>
+#include <QGraphicsSceneMouseEvent>
+#include <QKeyEvent>
+
+#include <QSettings>
+
+#include <QApplication>
+#include <QTime>
+#include <QFileInfo>
+#include <QMessageBox>
+
+#include "MainWindow.h"
+#include "GameView.h"
+#include "Hero.h"
+#include "ParallaxScrollerStatic.h"
+#include "Collectible.h"
+#include "HeadsUpDisplay.h"
+
+#include "layer.h"
+#include "objectgroup.h"
+#include "mapobject.h"
+#include "tile.h"
+#include "tilelayer.h"
+
+#include "Box2d/Dynamics/b2World.h"
+#include "Box2d/Dynamics/b2Fixture.h"
+#include "Box2d/Collision/Shapes/b2PolygonShape.h"
+#include "Box2d/Collision/Shapes/b2EdgeShape.h"
+
+#include "common.h"
+
+#include "ActionScene.h"
+
+using Tiled::Map;
+using Tiled::MapReader;
+using Tiled::OrthogonalRenderer;
+using Tiled::Layer;
+using Tiled::ObjectGroup;
+using Tiled::Tile;
+using Tiled::TileLayer;
+
+ActionScene::ActionScene(const QString &name, const QRectF &rect, GameView *parent)
+ : GameScene(name, parent)
+{
+ setSceneRect(rect);
+ m_clearAlert = false;
+ m_mapReader = new Tiled::MapReader;
+
+ m_map = 0;
+ m_mapRenderer = 0;
+
+ m_hud = new HeadsUpDisplay(sceneRect().width(), sceneRect().height(), this, this);
+
+ // start setting up the world here
+ b2Vec2 gravity(0.0f, 10.0f);
+ m_world = new b2World(gravity);
+ m_world->SetAllowSleeping(true);
+
+ // initialize rand here
+ qsrand(QTime::currentTime().msec());
+ // TODO: implement some logic to randomize color bubbles given to player
+
+ QString appDir = qApp->applicationDirPath();
+
+ m_hero = new Hero(this, QPointF(150, 150));
+ m_hero->loadAnimations(QString(appDir + "/data/gfx/characters/hero/"));
+
+ //connect(m_hero, SIGNAL(removeMe()), this, SLOT(removeSprite()));
+}
+
+ActionScene::~ActionScene()
+{
+ if (m_map)
+ delete m_map;
+ if (m_mapReader)
+ delete m_mapReader;
+ if (m_mapRenderer)
+ delete m_mapRenderer;
+
+ if(m_world)
+ delete m_world;
+}
+
+void ActionScene::updateLogic()
+{
+ if(!m_clearAlert)
+ {
+ // Collision logic through sheer awesomeness of Box2D, FTW.
+ m_world->Step(1.0f / FPS, 5, 5);
+ m_world->ClearForces();
+
+ advance();
+ update();
+ m_hud->update();
+ }
+}
+
+void ActionScene::keyPressEvent(QKeyEvent *event)
+{
+ //QGraphicsScene::keyPressEvent(event);
+
+ b2Body *body = m_hero->getFixture()->GetBody();
+
+ switch(event->key())
+ {
+ // arrow up
+ case 16777235:
+ body->ApplyForce(b2Vec2(5.0f, -20.0f), body->GetWorldCenter());
+ break;
+ // arrow down
+ case 16777237:
+ break;
+ // arrow left
+ case 16777234:
+ body->ApplyForce(b2Vec2(-10.0f, 0), body->GetWorldCenter());
+ break;
+ // arrow right
+ case 16777236 :
+ body->ApplyForce(b2Vec2(10.0f, 0), body->GetWorldCenter());
+ break;
+ // button a
+ case 65:
+ m_hud->toggleRedColor();
+ m_hero->toggleRedColor();
+ break;
+ // button s
+ case 83:
+ m_hud->toggleGreenColor();
+ m_hero->toggleGreenColor();
+ break;
+ // button d
+ case 68 :
+ m_hud->toggleBlueColor();
+ m_hero->toggleBlueColor();
+ break;
+ case 16777216 :
+ gameView()->changeScene(gameView()->getScene("LevelSelectionScene"));
+ break;
+ default:
+ qDebug() << event->key();
+ break;
+ }
+}
+
+void ActionScene::drawBackground(QPainter *painter, const QRectF &rect)
+{
+ return;
+}
+
+void ActionScene::drawForeground(QPainter *painter, const QRectF &rect)
+{
+ //painter->drawPixmap(rect.x(), rect.y(), sceneRect().width(), sceneRect().height(), *m_hud);
+}
+
+void ActionScene::addBlock(const QRectF &rect, const QPointF &pos, QGraphicsPixmapItem* tile)
+{
+ b2BodyDef def;
+ def.position.Set(P2M(pos.x()), P2M(pos.y()));
+ def.userData = tile;
+ b2Body *body = m_world->CreateBody(&def);
+
+ b2PolygonShape box;
+ box.SetAsBox(P2M(rect.width()/2), P2M(rect.height()/2),
+ b2Vec2(P2M(rect.width()/2), P2M(rect.height()/2)), 0);
+
+ b2Fixture *fixture = body->CreateFixture(&box, 0);
+
+ b2Filter filter;
+ fixture->SetFilterData(filter);
+
+ // Setup a circular reference, we can get the body from the item
+ // and the item from the body. Dunno if needed though :-)
+ tile->setData(0, qVariantFromValue(static_cast<void *>(fixture)));
+}
+
+void ActionScene::addBlock(qreal w, qreal h, qreal x, qreal y, QGraphicsPixmapItem* tile)
+{
+ addBlock(QRectF(0, 0, w, h), QPointF(x, y), tile);
+}
+
+void ActionScene::addEdge(const b2Vec2 &v1, const b2Vec2 &v2)
+{
+ QGraphicsLineItem *li = new QGraphicsLineItem(M2P(v1.x), M2P(v1.y),
+ M2P(v2.x), M2P(v2.y));
+ li->setPen(QPen(Qt::transparent));
+ addItem(li);
+
+ b2BodyDef def;
+ b2Body *body = m_world->CreateBody(&def);
+
+ b2EdgeShape edge;
+ edge.Set(v1, v2);
+
+ b2FixtureDef fixdef;
+ fixdef.friction = 0.25f;
+ fixdef.density = 0;
+ fixdef.shape = &edge;
+ fixdef.userData = li;
+
+ b2Fixture *fixture = body->CreateFixture(&fixdef);
+
+ // Setup a circular reference, we can get the fixture from the item
+ // and the item from the fixture. Dunno if needed though :-)
+ li->setData(0, qVariantFromValue(static_cast<void *>(fixture)));
+}
+
+void ActionScene::loadMap(QString target)
+{
+ QFileInfo f(target);
+ m_levelName = f.fileName();
+
+ QSettings set;
+ m_levelScore = set.value(m_levelName).toInt();
+
+ m_map = m_mapReader->readMap(target);
+
+ if (m_map == NULL)
+ {
+ qDebug() << "error:" << m_mapReader->errorString();
+ return;
+ }
+
+ m_mapRenderer = new Tiled::OrthogonalRenderer(m_map);
+
+ qDebug() << "size" << m_map->width() << "x" << m_map->height();
+ qDebug() << "layers" << m_map->layerCount();
+
+ for(int layer = 0; layer < m_map->layerCount(); layer++)
+ {
+ QString type = m_map->layerAt(layer)->property("type");
+
+ if (type == "solid")
+ {
+ Tiled::TileLayer* solidTiles = NULL;
+ solidTiles = m_map->layerAt(layer)->asTileLayer();
+
+ for(int w = 0; w < solidTiles->width(); w++)
+ {
+ for (int h = 0; h < solidTiles->height(); h++)
+ {
+ Tiled::Cell cell;
+ cell = solidTiles->cellAt(w, h);
+
+ if(!cell.isEmpty())
+ {
+ QGraphicsPixmapItem *solidTile = new QGraphicsPixmapItem(0, this);
+ solidTile->setData(ITEM_OBJECTNAME, QString("SolidGround"));
+ solidTile->setPos(w * m_map->tileWidth(),
+ h * m_map->tileHeight());
+ solidTile->setZValue(1);
+ solidTile->setPixmap(cell.tile->image());
+ addBlock(m_map->tileWidth(), m_map->tileHeight(),
+ w * m_map->tileWidth(),
+ h * m_map->tileHeight(),
+ solidTile);
+ m_mapPixmapItems.append(solidTile);
+ }
+ }
+ }
+ }
+ else
+ {
+ QImage img(m_map->width() * m_map->tileWidth(),
+ m_map->height() * m_map->tileHeight(),
+ QImage::Format_ARGB32);
+
+ QPainter painter(&img);
+ m_mapRenderer->drawTileLayer(&painter, m_map->layerAt(layer)->asTileLayer());
+
+ QPixmap mapPixmap = QPixmap::fromImage(img);
+ m_mapPixmaps.append(mapPixmap);
+
+ qDebug() << "hasAlpha" << mapPixmap.hasAlpha() << "\n"
+ << "hasAlphaChannel" << mapPixmap.hasAlphaChannel();
+
+ QGraphicsPixmapItem* mapPixmapItem = addPixmap(mapPixmap);
+ mapPixmapItem->setPos(0, 0);
+ mapPixmapItem->setShapeMode(QGraphicsPixmapItem::MaskShape);
+
+ mapPixmapItem->setPixmap(mapPixmap);
+
+ if (type == "covering")
+ {
+ mapPixmapItem->setData(ITEM_OBJECTNAME, QString("Covering"));
+ mapPixmapItem->setZValue(2);
+ }
+ else if (type == "coveringBg")
+ {
+ mapPixmapItem->setData(ITEM_OBJECTNAME, QString("CoveringBg"));
+ mapPixmapItem->setZValue(-1);
+ }
+
+ m_mapPixmapItems.append(mapPixmapItem);
+ }
+ }
+
+ QVector<QString> colors;
+ colors.append("red"); colors.append("blue"); colors.append("green");
+
+ for (int i = 0; i < colors.size(); i++)
+ {
+ Tiled::ObjectGroup* color = NULL;
+
+ if(m_map->indexOfLayer(colors.at(i)) >= 0)
+ color = m_map->layerAt(m_map->indexOfLayer(colors.at(i)))->asObjectGroup();
+
+ if(color)
+ {
+ Q_FOREACH(Tiled::MapObject *obj, color->objects())
+ {
+ Collectible* colorbubble = new Collectible(0, this);
+ colorbubble->setData(ITEM_OBJECTNAME, QString(colors.at(i)));
+ connect(colorbubble, SIGNAL(removeMe()), this, SLOT(removeSprite()));
+ colorbubble->setPos((obj->x()) * m_map->tileWidth(),
+ (obj->y() - 1) * m_map->tileHeight());
+
+ colorbubble->setZValue(1);
+
+ qDebug() << obj->position() << colorbubble->pos();
+ }
+ }
+ }
+
+ const int w = sceneRect().width() / 8;
+ const int h = sceneRect().height();
+ // top, bottom, left, right walls
+ addEdge(b2Vec2(0, 0), b2Vec2(P2M(w), 0));
+ addEdge(b2Vec2(0, P2M(h-1)), b2Vec2(P2M(w), P2M(h-1)));
+ addEdge(b2Vec2(0, 0), b2Vec2(0, P2M(h)));
+ addEdge(b2Vec2(P2M(w-1), 0), b2Vec2(P2M(w-1), P2M(h)));
+
+ m_hero->bindToWorld(m_world);
+ m_hero->updatePosition(100, 100);
+
+ m_clearAlert = false;
+}
+
+void ActionScene::unloadMap()
+{
+ foreach(QGraphicsPixmapItem* removableItem, m_mapPixmapItems)
+ {
+ removeItem(removableItem);
+ }
+
+ for(int i = m_mapPixmapItems.size() - 1; i > 0; i++)
+ delete m_mapPixmapItems.at(i);
+
+ m_mapPixmapItems.clear();
+
+ m_mapPixmaps.clear();
+
+ if (m_mapRenderer)
+ delete m_mapRenderer;
+ if (m_map)
+ delete m_map;
+}
+
+void ActionScene::removeSprite()
+{
+ qDebug() << "removing a sprite";
+
+ Sprite* sp = (Sprite*) sender();
+ if(sp)
+ {
+ removeItem(sp);
+ sp->deleteLater();
+ }
+}
diff --git a/src/ActionScene.h b/src/ActionScene.h
index 6460523..fa503a4 100644
--- a/src/ActionScene.h
+++ b/src/ActionScene.h
@@ -1,103 +1,123 @@
-#ifndef ActionScene_H
-#define ActionScene_H
-
-#include <QObject>
-#include <QRectF>
-#include <QGraphicsRectItem>
-
-#include "GameScene.h"
-#include "Sprite.h"
-
-#include "map.h"
-#include "mapreader.h"
-#include "orthogonalrenderer.h"
-
-#include "Box2D.h"
-
-class QGraphicsPixmapItem;
-class Hero;
-class HeadsUpDisplay;
-
-class b2World;
-
-class ActionScene : public GameScene
-{
- Q_OBJECT
-
-public:
- explicit ActionScene(const QString &name, const QRectF &rect, GameView *parent = 0);
- virtual ~ActionScene();
-
- void updateLogic();
- void keyPressEvent(QKeyEvent *event);
-
- /**
- * TODO: Bind in-game background parallax-scroller to this
- */
- void drawBackground(QPainter *painter, const QRectF &rect);
-
- /**
- * Used to draw HUD, TODO: implementation
- */
- void drawForeground(QPainter *painter, const QRectF &rect);
-
- /**
- * Loads level from target location.
- */
- void loadMap(QString target);
-
- /**
- * Unloads map, releasing its resources from memory
- */
- void unloadMap();
-
-private:
-
- b2World* m_physicalWorld;
-
- Tiled::Map *m_map;
- Tiled::MapReader *m_mapReader;
- Tiled::OrthogonalRenderer *m_mapRenderer;
-
- //! Level name used for records.
- QString m_levelName;
-
- //! Levelscore used for records.
- int m_levelScore;
-
- //! Map layers are drawn to these pixmaps
- QVector<QPixmap> m_mapPixmaps;
-
- //! Items for map layers
- QVector<QGraphicsPixmapItem*> m_mapPixmapItems;
-
- //! What portion of the map to draw
- QSize m_mapWindow;
-
- //! Background pixmap
- QPixmap m_bgPixmap;
- QGraphicsPixmapItem *m_bgPixmapItem;
-
- //! What portion of the bg pixmap to draw
- QRectF m_bgWindow;
-
- //! Pointer for forwarding commands to main character
- Hero* m_hero;
-
- //! Stops graphics rendering while scene is cleared.
- bool m_clearAlert;
-
- //! This item contais all hud elements, rendered in drawForeground
- HeadsUpDisplay* m_hud;
-
-signals:
- void gameOver();
-
-public slots:
- /**
- * Removes a sprite from the scene
- */
- void removeSprite();
-};
-
-#endif // ActionScene_H
+#ifndef ActionScene_H
+#define ActionScene_H
+
+#include <QObject>
+#include <QRectF>
+#include <QGraphicsRectItem>
+
+#include "GameScene.h"
+#include "Sprite.h"
+
+#include "map.h"
+#include "mapreader.h"
+#include "orthogonalrenderer.h"
+
+#include "Box2D/Common/b2Math.h"
+
+class QGraphicsPixmapItem;
+class Hero;
+class HeadsUpDisplay;
+
+class b2World;
+
+class ActionScene : public GameScene
+{
+ Q_OBJECT
+
+public:
+ explicit ActionScene(const QString &name, const QRectF &rect, GameView *parent = 0);
+ virtual ~ActionScene();
+
+ void updateLogic();
+ void keyPressEvent(QKeyEvent *event);
+
+ /**
+ * TODO: Bind in-game background parallax-scroller to this
+ */
+ void drawBackground(QPainter *painter, const QRectF &rect);
+
+ /**
+ * Used to draw HUD, TODO: implementation
+ */
+ void drawForeground(QPainter *painter, const QRectF &rect);
+
+ /**
+ * Loads level from target location.
+ */
+ void loadMap(QString target);
+
+ /**
+ * Unloads map, releasing its resources from memory
+ */
+ void unloadMap();
+
+ /**
+ * Build wall objects
+ * @param &rect holds size of wall
+ * @param &pos holds position of wall
+ */
+ void addBlock(const QRectF &rect, const QPointF &pos, QGraphicsPixmapItem* tile);
+
+ /**
+ * calls addWall(const QRectF &rect, const QPointF &pos);
+ * used as convenience method
+ */
+ void addBlock(qreal w, qreal h, qreal x, qreal y, QGraphicsPixmapItem* tile);
+
+ /**
+ * Builds walls that surround the level.
+ * @param &v1
+ * @param &v2
+ */
+ void addEdge(const b2Vec2 &v1, const b2Vec2 &v2);
+
+private:
+
+ b2World* m_world;
+
+ Tiled::Map *m_map;
+ Tiled::MapReader *m_mapReader;
+ Tiled::OrthogonalRenderer *m_mapRenderer;
+
+ //! Level name used for records.
+ QString m_levelName;
+
+ //! Levelscore used for records.
+ int m_levelScore;
+
+ //! Map layers are drawn to these pixmaps
+ QVector<QPixmap> m_mapPixmaps;
+
+ //! Items for map layers
+ QVector<QGraphicsPixmapItem*> m_mapPixmapItems;
+
+ //! What portion of the map to draw
+ QSize m_mapWindow;
+
+ //! Background pixmap
+ QPixmap m_bgPixmap;
+ QGraphicsPixmapItem *m_bgPixmapItem;
+
+ //! What portion of the bg pixmap to draw
+ QRectF m_bgWindow;
+
+ //! Pointer for forwarding commands to main character
+ Hero* m_hero;
+
+ //! Stops graphics rendering while scene is cleared.
+ bool m_clearAlert;
+
+ //! This item contais all hud elements, rendered in drawForeground
+ HeadsUpDisplay* m_hud;
+
+signals:
+ void gameOver();
+
+public slots:
+ /**
+ * Removes a sprite from the scene
+ */
+ void removeSprite();
+};
+
+#endif // ActionScene_H
diff --git a/src/BarDisplay.h b/src/BarDisplay.h
index d1ab534..ff4ce8b 100644
--- a/src/BarDisplay.h
+++ b/src/BarDisplay.h
@@ -1,33 +1,32 @@
-#ifndef BarDisplay_h
-#define BarDisplay_h
-
-#include <QPixmap>
-
-class BarDisplay : public QPixmap
-{
-public:
- BarDisplay(int w = 250, int h = 40);
- virtual ~BarDisplay();
-
- void initShape();
-
- void collected(int);
- void consumed(int);
- void setDisplayColor(QColor col);
-
-signals:
-
-public slots:
-
-private:
- int m_partCount;
- int m_value;
- int m_maxValue;
- QColor m_displayColor;
- QVector<QPolygon> m_healthIndicators;
-
- void updateDisplay();
-
-};
-
-#endif // BarDisplay_h
+#ifndef BarDisplay_h
+#define BarDisplay_h
+
+#include <QPixmap>
+
+class BarDisplay : public QPixmap
+{
+public:
+ BarDisplay(int w = 250, int h = 40);
+ virtual ~BarDisplay();
+
+ void initShape();
+
+ void collected(int);
+ void consumed(int);
+ void setDisplayColor(QColor col);
+
+ void updateDisplay();
+
+signals:
+
+public slots:
+
+private:
+ int m_partCount;
+ int m_value;
+ int m_maxValue;
+ QColor m_displayColor;
+ QVector<QPolygon> m_healthIndicators;
+};
+
+#endif // BarDisplay_h
diff --git a/src/CircularDisplay.cpp b/src/CircularDisplay.cpp
index 7a1dc0f..509c33b 100644
--- a/src/CircularDisplay.cpp
+++ b/src/CircularDisplay.cpp
@@ -1,81 +1,91 @@
-#include <QPainter>
-#include "CircularDisplay.h"
-
-CircularDisplay::CircularDisplay(int w, int h) :
- QPixmap(w, h)
-{
- m_partCount = 5;
- m_maxValue = 50;
- m_consumeSpeed = 5;
- m_value = 10;
- m_activated = false;
-
- fill(QColor(Qt::transparent));
-}
-
-CircularDisplay::~CircularDisplay()
-{
-}
-
-void CircularDisplay::initShape()
-{
- QPainter p(this);
- QPen pen(QColor(0, 0, 0, 255));
- QBrush brush(m_displayColor);
-
- pen.setWidth(4);
- p.setPen(pen);
-
- // draw base ellipse
- p.drawEllipse(QPointF(25, 35), 20, 20);
-
- p.setBrush(brush);
-
- // first 1/4th
- //p.drawPie(5, 15, 40, 20, 0, 180 * 16);
-
- // last 1/4th
- //p.drawPie(25, 35, 40, 20, 0, -180 * 16);
-
- // upper half
- //p.drawPie(5, 15, 40, 40, 0, 180 * 16);
-
- // lower half
- pen.setWidth(2);
- p.setPen(pen);
- p.drawPie(5, 15, 40, 40, 0, -180 * 16);
-
- // draw "tick" lines
- //p.drawLine(25, 15, 25, 0); // 12 o'clock
- //p.drawLine(45, 35, 60, 35); // 3 o'clock
- //p.drawLine(25, 55, 25, 70); // 6 o'clock
-}
-
-void CircularDisplay::setDisplayColor(QColor col)
-{
- m_displayColor = col;
-}
-
-void CircularDisplay::collected(int amount)
-{
- m_value += amount;
- if (m_value > m_maxValue)
- m_value = m_maxValue;
-
- updateDisplay();
-}
-
-void CircularDisplay::activate()
-{
- m_activated = true;
-}
-
-void CircularDisplay::unactivate()
-{
- m_activated = false;
-}
-
-void CircularDisplay::updateDisplay()
-{
- // TODO: update graphics so user knows collecting stuff does help
-}
+#include <QPainter>
+#include <QDebug>
+
+#include "CircularDisplay.h"
+
+CircularDisplay::CircularDisplay(const QString& name, int w, int h) :
+ QPixmap(w, h)
+{
+ m_partCount = 5;
+ m_maxValue = 50;
+ m_consumeSpeed = 5;
+ m_value = 10;
+ m_activated = false;
+ m_name = name;
+
+ fill(QColor(Qt::transparent));
+}
+
+CircularDisplay::~CircularDisplay()
+{
+}
+
+void CircularDisplay::initShape()
+{
+ QPainter p(this);
+ QPen pen(QColor(0, 0, 0, 255));
+ QBrush brush(m_displayColor);
+
+ pen.setWidth(4);
+ p.setPen(pen);
+
+ // draw base ellipse
+ p.drawEllipse(QPointF(25, 35), 20, 20);
+
+ p.setBrush(brush);
+
+ // first 1/4th
+ //p.drawPie(5, 15, 40, 20, 0, 180 * 16);
+
+ // last 1/4th
+ //p.drawPie(25, 35, 40, 20, 0, -180 * 16);
+
+ // upper half
+ //p.drawPie(5, 15, 40, 40, 0, 180 * 16);
+
+ // lower half
+ pen.setWidth(2);
+ p.setPen(pen);
+ p.drawPie(5, 15, 40, 40, 0, -180 * 16);
+
+ // draw "tick" lines
+ //p.drawLine(25, 15, 25, 0); // 12 o'clock
+ //p.drawLine(45, 35, 60, 35); // 3 o'clock
+ //p.drawLine(25, 55, 25, 70); // 6 o'clock
+}
+
+void CircularDisplay::setDisplayColor(QColor col)
+{
+ m_displayColor = col;
+}
+
+void CircularDisplay::collected(int amount)
+{
+ m_value += amount;
+ if (m_value > m_maxValue)
+ m_value = m_maxValue;
+
+ updateDisplay();
+}
+
+void CircularDisplay::activate()
+{
+ qDebug() << "activated " << m_name;
+ m_activated = true;
+}
+
+void CircularDisplay::deactivate()
+{
+ qDebug() << "deactivated " << m_name;
+ m_activated = false;
+}
+
+bool CircularDisplay::active() const
+{
+ return m_activated;
+}
+
+void CircularDisplay::updateDisplay()
+{
+ // TODO: update graphics so user knows collecting stuff does help
+}
diff --git a/src/CircularDisplay.h b/src/CircularDisplay.h
index 1e5f0da..3982d53 100644
--- a/src/CircularDisplay.h
+++ b/src/CircularDisplay.h
@@ -1,34 +1,36 @@
-#ifndef CircularDisplay_h
-#define CircularDisplay_h
-
-#include <QPixmap>
-
-class CircularDisplay : public QPixmap
-{
-public:
- CircularDisplay(int w = 90, int h = 90);
- virtual ~CircularDisplay();
-
- void initShape();
- void setDisplayColor(QColor col);
- void collected(int amount);
- void activate();
- void unactivate();
-
-signals:
-
-public slots:
-
-private:
- int m_partCount;
- int m_maxValue;
- int m_value;
- int m_consumeSpeed;
- bool m_activated;
- QColor m_displayColor;
-
- void updateDisplay();
-
-};
-
-#endif // CircularDisplay_h
+#ifndef CircularDisplay_h
+#define CircularDisplay_h
+
+#include <QPixmap>
+
+class CircularDisplay : public QPixmap
+{
+public:
+ CircularDisplay(const QString& name, int w = 90, int h = 90);
+ virtual ~CircularDisplay();
+
+ void initShape();
+ void setDisplayColor(QColor col);
+ void collected(int amount);
+
+ void activate();
+ void deactivate();
+ bool active() const;
+
+ void updateDisplay();
+
+signals:
+
+public slots:
+
+private:
+ int m_partCount;
+ int m_maxValue;
+ int m_value;
+ int m_consumeSpeed;
+ bool m_activated;
+ QColor m_displayColor;
+ QString m_name;
+};
+
+#endif // CircularDisplay_h
diff --git a/src/CreditsScene.cpp b/src/CreditsScene.cpp
index edcee8f..65f77fc 100644
--- a/src/CreditsScene.cpp
+++ b/src/CreditsScene.cpp
@@ -1,69 +1,67 @@
-#include <QApplication>
-#include <QGraphicsTextItem>
-
-#include <QDebug>
-
-#include "GameView.h"
-#include "GraphicsButtonObject.h"
-#include "ParallaxScrollerStatic.h"
-
-#include "CreditsScene.h"
-
-CreditsScene::CreditsScene(const QString &name, const QRectF &rect, GameView *parent)
- : GameScene(name, parent)
-{
- setSceneRect(rect);
-
- QString appDir = qApp->applicationDirPath();
-
- m_background = new ParallaxScrollerStatic(this);
- m_background->setLayerWidth(rect.width());
- //m_background->addParallaxScrollItem(QString(appDir + "/gfx/bg/layer1.png"), QPointF(0,0), -2, 6);
- //m_background->addParallaxScrollItem(QString(appDir + "/gfx/bg/layer2.png"), QPointF(0,0), -1, 4);
-
- m_background->addParallaxScrollItem(QString(appDir + "/data/gfx/background/layer_three.png"), QPointF(0,0), -3, 8);
- m_background->addParallaxScrollItem(QString(appDir + "/data/gfx/background/layer_two.png"), QPointF(0,0), -2, 6);
- m_background->addParallaxScrollItem(QString(appDir + "/data/gfx/background/layer_one.png"), QPointF(0,0), -1, 4);
-
- initializeScene();
-}
-
-CreditsScene::~CreditsScene()
-{
- delete m_background;
-}
-
-void CreditsScene::initializeScene()
-{
- addTitle("Credits");
-
- QGraphicsTextItem* creditText = new QGraphicsTextItem(0, this);
- creditText->setHtml("<font color=\"white\">"\
- "<b>prism</b> (v. 0.0.3) <br><br>"\
- "Game design,<br>"\
- "concept design and<br>"\
- "programming by:<br>"\
- "Samu Laaksonen<br>"\
- "and <br>"\
- "Oskari Timperi<br><br>"\
- "Copyright (c) 2012 of aforementioned persons. All rights reserved.<br>"\
- "</font>");
- creditText->setPos(140, 130);
- creditText->setFont(QFont("Arial", 14));
-
- GraphicsButtonObject *btn;
- btn = new GraphicsButtonObject(QPixmap(qApp->applicationDirPath() + "/data/gfx/buttons/back-arrow1.png"),
- 0, this);
- btn->setPressedPixmap(QPixmap(qApp->applicationDirPath() + "/data/gfx/buttons/back-arrow2.png"));
- btn->setPos(720, 400);
- btn->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
- btn->setZValue(2);
-
- connect(btn, SIGNAL(clicked()), gameView(), SLOT(showMenuScene()));
-}
-
-void CreditsScene::updateLogic()
-{
- advance();
- update();
-}
+#include <QApplication>
+#include <QGraphicsTextItem>
+
+#include <QDebug>
+
+#include "GameView.h"
+#include "GraphicsButtonObject.h"
+#include "ParallaxScrollerStatic.h"
+
+#include "CreditsScene.h"
+
+CreditsScene::CreditsScene(const QString &name, const QRectF &rect, GameView *parent)
+ : GameScene(name, parent)
+{
+ setSceneRect(rect);
+
+ QString appDir = qApp->applicationDirPath();
+
+ m_background = new ParallaxScrollerStatic(this);
+ m_background->setLayerWidth(rect.width());
+
+ m_background->addParallaxScrollItem(QString(appDir + "/data/gfx/background/layer_three.png"), QPointF(0,0), -3, 8);
+ m_background->addParallaxScrollItem(QString(appDir + "/data/gfx/background/layer_two.png"), QPointF(0,0), -2, 6);
+ m_background->addParallaxScrollItem(QString(appDir + "/data/gfx/background/layer_one.png"), QPointF(0,0), -1, 4);
+
+ initializeScene();
+}
+
+CreditsScene::~CreditsScene()
+{
+ delete m_background;
+}
+
+void CreditsScene::initializeScene()
+{
+ addTitle("Credits");
+
+ QGraphicsTextItem* creditText = new QGraphicsTextItem(0, this);
+ creditText->setHtml("<font color=\"white\">"\
+ "<b>prism</b> (v. 0.0.3) <br><br>"\
+ "Game design,<br>"\
+ "concept design and<br>"\
+ "programming by:<br>"\
+ "Samu Laaksonen<br>"\
+ "and <br>"\
+ "Oskari Timperi<br><br>"\
+ "Copyright (c) 2012 of aforementioned persons. All rights reserved.<br>"\
+ "</font>");
+ creditText->setPos(140, 130);
+ creditText->setFont(QFont("Arial", 14));
+
+ GraphicsButtonObject *btn;
+ btn = new GraphicsButtonObject(QPixmap(qApp->applicationDirPath() + "/data/gfx/buttons/back-arrow.png"),
+ 0, this);
+ btn->setPressedPixmap(QPixmap(qApp->applicationDirPath() + "/data/gfx/buttons/back-arrow-pressed.png"));
+ btn->setPos(720, 400);
+ btn->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
+ btn->setZValue(2);
+
+ connect(btn, SIGNAL(clicked()), gameView(), SLOT(showMenuScene()));
+}
+
+void CreditsScene::updateLogic()
+{
+ advance();
+ update();
+}
diff --git a/src/HeadsUpDisplay.cpp b/src/HeadsUpDisplay.cpp
index a455c9b..14c8317 100644
--- a/src/HeadsUpDisplay.cpp
+++ b/src/HeadsUpDisplay.cpp
@@ -1,61 +1,93 @@
-#include <QPainter>
-#include <QRgb>
-#include "BarDisplay.h"
-#include "CircularDisplay.h"
-
-#include "HeadsUpDisplay.h"
-
-HeadsUpDisplay::HeadsUpDisplay(int w, int h, QGraphicsScene *anchorScene, QObject *parent) :
- QPixmap(w, h), QObject(parent)
-{
- fill(QColor(Qt::transparent));
- m_healtBar = new BarDisplay(200, 40);
- m_healtBar->setDisplayColor(QColor(255, 204, 51, 127));
- m_healtBar->initShape();
-
- m_redColor = new CircularDisplay(70, 70);
- m_redColor->setDisplayColor(QColor(127, 0, 0, 127));
- m_redColor->initShape();
-
- m_greenColor = new CircularDisplay(70, 70);
- m_greenColor->setDisplayColor(QColor(0, 127, 0, 127));
- m_greenColor->initShape();
-
- m_blueColor = new CircularDisplay(70, 70);
- m_blueColor->setDisplayColor(QColor(0, 0, 127, 127));
- m_blueColor->initShape();
-
- m_anchorScene = anchorScene;
-
- QPainter p(this);
-
- p.drawPixmap(10, 20, *m_redColor);
- p.drawPixmap(10, 120, *m_greenColor);
- p.drawPixmap(10, 220, *m_blueColor);
- p.drawPixmap(300, 430, *m_healtBar);
-}
-
-HeadsUpDisplay::~HeadsUpDisplay()
-{
-
-}
-
-CircularDisplay *HeadsUpDisplay::redDisplay() const
-{
- return m_redColor;
-}
-
-CircularDisplay *HeadsUpDisplay::greenDisplay() const
-{
- return m_greenColor;
-}
-
-CircularDisplay *HeadsUpDisplay::blueDisplay() const
-{
- return m_blueColor;
-}
-
-BarDisplay *HeadsUpDisplay::healthDisplay() const
-{
- return m_healtBar;
-}
+#include <QPainter>
+#include <QRgb>
+#include "BarDisplay.h"
+#include "CircularDisplay.h"
+
+#include "HeadsUpDisplay.h"
+
+HeadsUpDisplay::HeadsUpDisplay(int w, int h, QGraphicsScene *anchorScene, QObject *parent) :
+ QPixmap(w, h), QObject(parent)
+{
+ fill(QColor(Qt::transparent));
+ m_healtBar = new BarDisplay(200, 40);
+ m_healtBar->setDisplayColor(QColor(255, 204, 51, 127));
+ m_healtBar->initShape();
+
+ m_redColor = new CircularDisplay("red", 70, 70);
+ m_redColor->setDisplayColor(QColor(127, 0, 0, 127));
+ m_redColor->initShape();
+
+ m_greenColor = new CircularDisplay("green", 70, 70);
+ m_greenColor->setDisplayColor(QColor(0, 127, 0, 127));
+ m_greenColor->initShape();
+
+ m_blueColor = new CircularDisplay("blue", 70, 70);
+ m_blueColor->setDisplayColor(QColor(0, 0, 127, 127));
+ m_blueColor->initShape();
+
+ m_anchorScene = anchorScene;
+
+ QPainter p(this);
+
+ p.drawPixmap(10, 20, *m_redColor);
+ p.drawPixmap(10, 120, *m_greenColor);
+ p.drawPixmap(10, 220, *m_blueColor);
+ p.drawPixmap(300, 430, *m_healtBar);
+}
+
+HeadsUpDisplay::~HeadsUpDisplay()
+{
+
+}
+
+void HeadsUpDisplay::update()
+{
+ m_healtBar->updateDisplay();
+ m_redColor->updateDisplay();
+ m_greenColor->updateDisplay();
+ m_blueColor->updateDisplay();
+}
+
+CircularDisplay *HeadsUpDisplay::redDisplay() const
+{
+ return m_redColor;
+}
+
+CircularDisplay *HeadsUpDisplay::greenDisplay() const
+{
+ return m_greenColor;
+}
+
+CircularDisplay *HeadsUpDisplay::blueDisplay() const
+{
+ return m_blueColor;
+}
+
+BarDisplay *HeadsUpDisplay::healthDisplay() const
+{
+ return m_healtBar;
+}
+
+void HeadsUpDisplay::toggleRedColor()
+{
+ if (m_redColor->active())
+ m_redColor->deactivate();
+ else
+ m_redColor->activate();
+}
+
+void HeadsUpDisplay::toggleGreenColor()
+{
+ if (m_greenColor->active())
+ m_greenColor->deactivate();
+ else
+ m_greenColor->activate();
+}
+
+void HeadsUpDisplay::toggleBlueColor()
+{
+ if (m_blueColor->active())
+ m_blueColor->deactivate();
+ else
+ m_blueColor->activate();
+}
diff --git a/src/HeadsUpDisplay.h b/src/HeadsUpDisplay.h
index 940b36a..ee6e575 100644
--- a/src/HeadsUpDisplay.h
+++ b/src/HeadsUpDisplay.h
@@ -1,35 +1,41 @@
-#ifndef HeadsUpDisplay_h
-#define HeadsUpDisplay_h
-#include <QObject>
-#include <QPixmap>
-
-class QGraphicsScene;
-class BarDisplay;
-class CircularDisplay;
-
-class HeadsUpDisplay : public QObject, public QPixmap
-{
- Q_OBJECT
-public:
- HeadsUpDisplay(int w, int h, QGraphicsScene* anchorScene, QObject *parent = 0);
- virtual ~HeadsUpDisplay();
-
- CircularDisplay* redDisplay() const;
- CircularDisplay* greenDisplay() const;
- CircularDisplay* blueDisplay() const;
- BarDisplay* healthDisplay() const;
-
-signals:
-
-public slots:
-
-private:
- QGraphicsScene* m_anchorScene;
- BarDisplay* m_healtBar;
- CircularDisplay* m_redColor;
- CircularDisplay* m_greenColor;
- CircularDisplay* m_blueColor;
-
-};
-
-#endif // HeadsUpDisplay_h
+#ifndef HeadsUpDisplay_h
+#define HeadsUpDisplay_h
+#include <QObject>
+#include <QPixmap>
+
+class QGraphicsScene;
+class BarDisplay;
+class CircularDisplay;
+
+class HeadsUpDisplay : public QObject, public QPixmap
+{
+ Q_OBJECT
+public:
+ HeadsUpDisplay(int w, int h, QGraphicsScene* anchorScene, QObject *parent = 0);
+ virtual ~HeadsUpDisplay();
+
+ void update();
+
+ CircularDisplay* redDisplay() const;
+ CircularDisplay* greenDisplay() const;
+ CircularDisplay* blueDisplay() const;
+ BarDisplay* healthDisplay() const;
+
+ void toggleRedColor();
+ void toggleGreenColor();
+ void toggleBlueColor();
+
+signals:
+
+public slots:
+
+private:
+ QGraphicsScene* m_anchorScene;
+ BarDisplay* m_healtBar;
+ CircularDisplay* m_redColor;
+ CircularDisplay* m_greenColor;
+ CircularDisplay* m_blueColor;
+
+};
+
+#endif // HeadsUpDisplay_h
diff --git a/src/Hero.cpp b/src/Hero.cpp
index 5af9b6a..5567827 100644
--- a/src/Hero.cpp
+++ b/src/Hero.cpp
@@ -1,41 +1,201 @@
-#include <QApplication>
-#include <QGraphicsScene>
-#include <QGraphicsPixmapItem>
-#include <QSettings>
-#include <QDebug>
-
-#include "Hero.h"
-#include "GameScene.h"
-
-Hero::Hero(QGraphicsScene* scene, QPointF pos, QGraphicsItem* parent)
- : Character(parent, scene)
-{
- m_state = STATE_IDLE;
-
- // something small for testing purposes
- setHealthPoints(15);
-
- setPos(pos);
- setZValue(2);
-
- setShapeMode(QGraphicsPixmapItem::MaskShape);
-}
-
-Hero::~Hero()
-{
-}
-
-void Hero::advance(int phase)
-{
- Character::advance(phase);
-
- if (phase == 0)
- return;
-
- // err, no good.
- if(m_state == STATE_DEAD)
- {
- gameOver();
- //removeMe();
- }
-}
+#include <QApplication>
+#include <QGraphicsScene>
+#include <QGraphicsPixmapItem>
+#include <QSettings>
+#include <QPainter>
+#include <QDir>
+#include <QColor>
+#include <QDebug>
+
+#include "Box2D/Dynamics/b2World.h"
+#include "Box2d/Dynamics/b2Body.h"
+#include "Box2d/Dynamics/b2Fixture.h"
+#include "Box2d/Collision/Shapes/b2PolygonShape.h"
+
+#include "common.h"
+
+#include "Hero.h"
+#include "GameScene.h"
+
+Hero::Hero(QGraphicsScene* scene, QPointF pos, QGraphicsItem* parent)
+ : Character(parent, scene)
+{
+ m_state = STATE_IDLE;
+
+ // something small for testing purposes
+ setHealthPoints(15);
+
+ setPos(pos);
+ setZValue(2);
+
+ setShapeMode(QGraphicsPixmapItem::MaskShape);
+
+ m_mode = "neutral";
+
+ m_neutral = new QPixmap(32, 64);
+ m_neutral->fill(Qt::transparent);
+ setPixmap(*m_neutral);
+
+ m_red = new QPixmap(32, 64);
+ m_red->fill(Qt::transparent);
+ QPainter p;
+ p.setPen(Qt::NoPen);
+ QBrush b(Qt::transparent);
+ p.begin(m_red);
+ b.setColor(QColor(127, 0, 0, 127));
+ p.setBrush(b);
+ p.drawRoundedRect(QRect(0, 0, 31, 63), 5, 5);
+ p.end();
+
+ m_green = new QPixmap(32, 64);
+ m_green->fill(Qt::transparent);
+ p.begin(m_green);
+ b.setColor(QColor(0, 127, 0, 127));
+ p.setBrush(b);
+ p.drawRoundedRect(QRect(0, 0, 31, 63), 5, 5);
+ p.end();
+
+ m_blue = new QPixmap(32, 64);
+ m_blue->fill(Qt::transparent);
+ p.begin(m_blue);
+ b.setColor(QColor(0, 0, 127, 127));
+ p.setBrush(b);
+ p.drawRoundedRect(QRect(0, 0, 31, 63), 5, 5);
+ p.end();
+}
+
+Hero::~Hero()
+{
+ if (m_red)
+ delete m_red;
+ if (m_green)
+ delete m_green;
+ if (m_blue)
+ delete m_blue;
+ if (m_neutral)
+ delete m_neutral;
+}
+
+void Hero::bindToWorld(b2World *world)
+{
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(P2M(16), P2M(32));
+
+ m_body = world->CreateBody(&bd);
+
+ b2PolygonShape polygonShape;
+ polygonShape.SetAsBox(P2M(32.0f / 2),
+ P2M(64.0f / 2),
+ b2Vec2(P2M(32.0f / 2),
+ P2M(64.0f / 2)),
+ 0.0f);
+
+ b2FixtureDef fixtureDef;
+ fixtureDef.shape = &polygonShape;
+ fixtureDef.density = 15;
+ fixtureDef.friction = 0.05f;
+ fixtureDef.restitution = 0.25f;
+ fixtureDef.userData = this;
+
+ m_fixture = m_body->CreateFixture(&fixtureDef);
+
+ b2MassData md;
+ m_body->GetMassData(&md);
+ md.mass = 0.7f;
+ m_fixture->GetBody()->SetMassData(&md);
+
+ qDebug() << "mass: " << m_body->GetMass() << "kg";
+}
+
+void Hero::loadAnimations(const QString &animationsDirectory)
+{
+ QDir animDirs(animationsDirectory);
+
+ foreach(QString animName, animDirs.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
+ {
+ QDir anim(animationsDirectory + "/" + animName);
+
+ foreach(QString frame, anim.entryList(QDir::Files | QDir::NoDotAndDotDot))
+ {
+ addFrame(animName, QPixmap(animationsDirectory + "/" + animName + "/" + frame));
+ }
+ }
+ setAnimation("idle");
+}
+
+void Hero::advance(int phase)
+{
+ Character::advance(phase);
+
+ if (phase == 0)
+ {
+ return;
+ }
+ else if (phase == 1)
+ {
+ b2Vec2 pos = m_body->GetPosition();
+ setPos(M2P(pos.x)-16, M2P(pos.y)-32);
+ }
+
+ // err, no good.
+ if(m_state == STATE_DEAD)
+ {
+ gameOver();
+ //removeMe();
+ }
+}
+
+void Hero::updatePosition(qreal x, qreal y)
+{
+ m_body->SetTransform(b2Vec2(P2M(x), P2M(y)), 0);
+ setPos(x-16, y-32);
+}
+
+void Hero::toggleRedColor()
+{
+ if (m_mode == "neutral")
+ {
+ setPixmap(*m_red);
+ m_mode = "red";
+ }
+ else if (m_mode == "red")
+ {
+ setPixmap(*m_neutral);
+ m_mode = "neutral";
+ }
+}
+
+void Hero::toggleGreenColor()
+{
+ if (m_mode == "neutral")
+ {
+ setPixmap(*m_green);
+ m_mode = "green";
+ }
+ else if (m_mode == "green")
+ {
+ setPixmap(*m_neutral);
+ m_mode = "neutral";
+ }
+}
+
+void Hero::toggleBlueColor()
+{
+ if (m_mode == "neutral")
+ {
+ setPixmap(*m_blue);
+ m_mode = "blue";
+ }
+ else if (m_mode == "blue")
+ {
+ setPixmap(*m_neutral);
+ m_mode = "neutral";
+ }
+}
+
+
+b2Fixture* Hero::getFixture()
+{
+ return m_fixture;
+}
diff --git a/src/Hero.h b/src/Hero.h
index ec25944..2813d14 100644
--- a/src/Hero.h
+++ b/src/Hero.h
@@ -1,25 +1,54 @@
-#ifndef Hero_h
-#define Hero_h
-
-#include "Character.h"
-
-class Hero: public Character
-{
- Q_OBJECT
-
-public:
- Hero(QGraphicsScene* scene, QPointF pos, QGraphicsItem* parent = 0);
- virtual ~Hero();
-
- void advance(int phase);
-
-signals:
- void gameOver();
- void levelComplete();
- void updateUI();
-
-private:
-
-};
-
-#endif // Hero_h
+#ifndef Hero_h
+#define Hero_h
+
+#include "Character.h"
+
+class b2World;
+class b2Body;
+class b2Fixture;
+
+class Hero: public Character
+{
+ Q_OBJECT
+
+public:
+ Hero(QGraphicsScene* scene, QPointF pos, QGraphicsItem* parent = 0);
+ virtual ~Hero();
+
+ void bindToWorld(b2World* world);
+
+ void loadAnimations(const QString& animationsDirectory);
+
+ void advance(int phase);
+
+ /**
+ * Update the position of the ball. x and y are in pixels.
+ */
+ void updatePosition(qreal x, qreal y);
+
+ /**
+ * Returns the Box2D fixture for the ball.
+ */
+ b2Fixture *getFixture();
+
+ void toggleRedColor();
+ void toggleGreenColor();
+ void toggleBlueColor();
+
+signals:
+ void gameOver();
+ void levelComplete();
+ void updateUI();
+
+private:
+ QPixmap* m_red;
+ QPixmap* m_green;
+ QPixmap* m_blue;
+ QPixmap* m_neutral;
+ QString m_mode;
+
+ b2Body* m_body;
+ b2Fixture *m_fixture;
+};
+
+#endif // Hero_h
diff --git a/src/LevelSelectionScene.cpp b/src/LevelSelectionScene.cpp
index aa6c607..9c195d3 100644
--- a/src/LevelSelectionScene.cpp
+++ b/src/LevelSelectionScene.cpp
@@ -1,106 +1,104 @@
-#include <QApplication>
-#include <QDir>
-#include <QSettings>
-#include <QDebug>
-
-#include "ParallaxScrollerStatic.h"
-#include "GraphicsButtonObject.h"
-#include "GameView.h"
-#include "ActionScene.h"
-
-#include "LevelSelectionScene.h"
-
-LevelSelectionScene::LevelSelectionScene(const QString &name, const QRectF &rect, GameView *parent)
- : GameScene(name, parent)
-{
- setSceneRect(rect);
-
- QString appDir = qApp->applicationDirPath();
-
- m_background = new ParallaxScrollerStatic(this);
- m_background->setLayerWidth(rect.width());
- //m_background->addParallaxScrollItem(QString(appDir + "/gfx/bg/layer1.png"), QPointF(0,0), -2, 6);
- //m_background->addParallaxScrollItem(QString(appDir + "/gfx/bg/layer2.png"), QPointF(0,0), -1, 4);
-
- m_background->addParallaxScrollItem(QString(appDir + "/data/gfx/background/layer_three.png"), QPointF(0,0), -3, 8);
- m_background->addParallaxScrollItem(QString(appDir + "/data/gfx/background/layer_two.png"), QPointF(0,0), -2, 6);
- m_background->addParallaxScrollItem(QString(appDir + "/data/gfx/background/layer_one.png"), QPointF(0,0), -1, 4);
-
- initializeScene();
-}
-
-LevelSelectionScene::~LevelSelectionScene()
-{
- delete m_background;
-}
-
-void LevelSelectionScene::initializeScene()
-{
- addTitle("Level Selection");
-
- QSettings settings;
-
- QString path = qApp->applicationDirPath() + "/data/levels";
-
- //QDir levelDirectory(settings.value("path/levels").toString());
-
- QDir levelDirectory(path);
-
- /* TODO: check levels directory for levels (should be 6) and create corresponding buttons
- that react when pressed and lauch the level
- */
- int yoff = 200;
- int xoff = 50;
- int count = 1;
-
- Q_FOREACH(QString f, levelDirectory.entryList(QDir::Files, QDir::Name))
- {
- QString lvlNum;
- lvlNum.setNum(count);
- GraphicsButtonObject *btn = new GraphicsButtonObject(lvlNum, 0, this);
- btn->setPos(210 + xoff, yoff);
- btn->setProperty("level_path", levelDirectory.filePath(f));
-
- qDebug() << levelDirectory.filePath(f);
-
- connect(btn, SIGNAL(clicked()), this, SLOT(levelSelection()));
-
-// if(count % 4 == 0)
-// {
-// yoff += btn->boundingRect().bottom() + 20;
-// xoff = 50;
-// }
-
- count++;
- //xoff += btn->boundingRect().bottom() + 20;
- yoff += btn->boundingRect().bottom() + 10;
- }
-
- GraphicsButtonObject *btn;
- btn = new GraphicsButtonObject(QPixmap(QApplication::applicationDirPath() + "/data/gfx/buttons/back-arrow1.png"), 0, this);
- btn->setPressedPixmap(QPixmap(QApplication::applicationDirPath() + "/data/gfx/buttons/back-arrow2.png"));
- btn->setPos(720, 400);
- btn->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
- btn->setZValue(2);
-
- connect(btn, SIGNAL(clicked()), gameView(), SLOT(showMenuScene()));
-}
-
-void LevelSelectionScene::levelSelection()
-{
- QVariant level_path = sender()->property("level_path");
-
- Q_ASSERT(level_path.isValid());
-
- QString levelPath = level_path.toString();
-
- gameView()->getActionScene()->loadMap(levelPath);
- gameView()->showActionScene();
-}
-
-void LevelSelectionScene::updateLogic()
-{
- advance();
- update();
-}
-
+#include <QApplication>
+#include <QDir>
+#include <QSettings>
+#include <QDebug>
+
+#include "ParallaxScrollerStatic.h"
+#include "GraphicsButtonObject.h"
+#include "GameView.h"
+#include "ActionScene.h"
+
+#include "LevelSelectionScene.h"
+
+LevelSelectionScene::LevelSelectionScene(const QString &name, const QRectF &rect, GameView *parent)
+ : GameScene(name, parent)
+{
+ setSceneRect(rect);
+
+ QString appDir = qApp->applicationDirPath();
+
+ m_background = new ParallaxScrollerStatic(this);
+ m_background->setLayerWidth(rect.width());
+
+ m_background->addParallaxScrollItem(QString(appDir + "/data/gfx/background/layer_three.png"), QPointF(0,0), -3, 8);
+ m_background->addParallaxScrollItem(QString(appDir + "/data/gfx/background/layer_two.png"), QPointF(0,0), -2, 6);
+ m_background->addParallaxScrollItem(QString(appDir + "/data/gfx/background/layer_one.png"), QPointF(0,0), -1, 4);
+
+ initializeScene();
+}
+
+LevelSelectionScene::~LevelSelectionScene()
+{
+ delete m_background;
+}
+
+void LevelSelectionScene::initializeScene()
+{
+ addTitle("Level Selection");
+
+ QSettings settings;
+
+ QString path = qApp->applicationDirPath() + "/data/levels";
+
+ //QDir levelDirectory(settings.value("path/levels").toString());
+
+ QDir levelDirectory(path);
+
+ /* TODO: check levels directory for levels (should be 6) and create corresponding buttons
+ that react when pressed and lauch the level
+ */
+ int yoff = 200;
+ int xoff = 50;
+ int count = 1;
+
+ Q_FOREACH(QString f, levelDirectory.entryList(QDir::Files, QDir::Name))
+ {
+ QString lvlNum;
+ lvlNum.setNum(count);
+ GraphicsButtonObject *btn = new GraphicsButtonObject(lvlNum, 0, this);
+ btn->setPos(210 + xoff, yoff);
+ btn->setProperty("level_path", levelDirectory.filePath(f));
+
+ qDebug() << levelDirectory.filePath(f);
+
+ connect(btn, SIGNAL(clicked()), this, SLOT(levelSelection()));
+
+// if(count % 4 == 0)
+// {
+// yoff += btn->boundingRect().bottom() + 20;
+// xoff = 50;
+// }
+
+ count++;
+ //xoff += btn->boundingRect().bottom() + 20;
+ yoff += btn->boundingRect().bottom() + 10;
+ }
+
+ GraphicsButtonObject *btn;
+ btn = new GraphicsButtonObject(QPixmap(QApplication::applicationDirPath() + "/data/gfx/buttons/back-arrow.png"), 0, this);
+ btn->setPressedPixmap(QPixmap(QApplication::applicationDirPath() + "/data/gfx/buttons/back-arrow-pressed.png"));
+ btn->setPos(720, 400);
+ btn->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
+ btn->setZValue(2);
+
+ connect(btn, SIGNAL(clicked()), gameView(), SLOT(showMenuScene()));
+}
+
+void LevelSelectionScene::levelSelection()
+{
+ QVariant level_path = sender()->property("level_path");
+
+ Q_ASSERT(level_path.isValid());
+
+ QString levelPath = level_path.toString();
+
+ gameView()->getActionScene()->loadMap(levelPath);
+ gameView()->showActionScene();
+}
+
+void LevelSelectionScene::updateLogic()
+{
+ advance();
+ update();
+}
+
diff --git a/src/Sprite.cpp b/src/Sprite.cpp
index b921394..41a87db 100644
--- a/src/Sprite.cpp
+++ b/src/Sprite.cpp
@@ -1,108 +1,108 @@
-#include "Sprite.h"
-
-Sprite::Sprite(QGraphicsItem *parent, QGraphicsScene *scene)
- : QObject(0),
- QGraphicsPixmapItem(parent, scene),
- m_currentFrame(0),
- m_interval(1000/20)
-{
- addAnimation("default", FrameList());
- setAnimation("default");
-
- m_timer.invalidate();
-}
-
-void Sprite::addFrame(const QString &anim, QPixmap frame)
-{
- if (!m_animations.contains(anim))
- {
- FrameList l;
- m_animations[anim] = l;
- }
-
- m_animations[anim].append(frame);
-}
-
-void Sprite::addAnimation(const QString &anim, const FrameList &frames)
-{
- if (!m_animations.contains(anim))
- {
- m_animations[anim] = frames;
- }
- else
- {
- m_animations[anim].append(frames);
- }
-}
-
-void Sprite::setFrame(int frame)
-{
- if (frame < 0 || frame >= getCurrentAnimation().size())
- {
- qWarning("invalid frame number %d", frame);
- return;
- }
-
- m_currentFrame = frame;
- setPixmap(getFramePixmap());
-}
-
-int Sprite::getFrame() const
-{
- return m_currentFrame;
-}
-
-QPixmap Sprite::getFramePixmap() const
-{
- return getCurrentAnimation()[m_currentFrame];
-}
-
-int Sprite::getFrameCount() const
-{
- return getCurrentAnimation().size();
-}
-
-Sprite::FrameList Sprite::getCurrentAnimation() const
-{
- return m_animations[m_currentAnimation];
-}
-
-void Sprite::nextFrame()
-{
- m_currentFrame++;
-
- if (m_currentFrame >= getCurrentAnimation().size())
- m_currentFrame = 0;
-
- setFrame(m_currentFrame);
-}
-
-void Sprite::setAnimation(const QString &anim)
-{
- if (!m_animations.contains(anim))
- {
- qWarning("animation '%s' doesn't exist", anim.toUtf8().data());
- return;
- }
-
- if (m_currentAnimation != anim)
- m_currentAnimation = anim;
-}
-
-void Sprite::advance(int phase)
-{
- if (phase == 1)
- return;
-
- if (m_timer.isValid() && m_timer.elapsed() >= m_interval)
- {
- nextFrame();
- m_timer.start();
- }
-
- // this should be run the first time advance() is called
- if (!m_timer.isValid())
- {
- m_timer.start();
- }
-}
+#include "Sprite.h"
+
+Sprite::Sprite(QGraphicsItem *parent, QGraphicsScene *scene)
+ : QObject(0),
+ QGraphicsPixmapItem(parent, scene),
+ m_currentFrame(0),
+ m_interval(1000/20)
+{
+ addAnimation("default", FrameList());
+ setAnimation("default");
+
+ m_timer.invalidate();
+}
+
+void Sprite::addFrame(const QString &anim, QPixmap frame)
+{
+ if (!m_animations.contains(anim))
+ {
+ FrameList l;
+ m_animations[anim] = l;
+ }
+
+ m_animations[anim].append(frame);
+}
+
+void Sprite::addAnimation(const QString &anim, const FrameList &frames)
+{
+ if (!m_animations.contains(anim))
+ {
+ m_animations[anim] = frames;
+ }
+ else
+ {
+ m_animations[anim].append(frames);
+ }
+}
+
+void Sprite::setFrame(int frame)
+{
+ if (frame < 0 || frame >= getCurrentAnimation().size())
+ {
+ //qWarning("invalid frame number %d", frame);
+ return;
+ }
+
+ m_currentFrame = frame;
+ setPixmap(getFramePixmap());
+}
+
+int Sprite::getFrame() const
+{
+ return m_currentFrame;
+}
+
+QPixmap Sprite::getFramePixmap() const
+{
+ return getCurrentAnimation()[m_currentFrame];
+}
+
+int Sprite::getFrameCount() const
+{
+ return getCurrentAnimation().size();
+}
+
+Sprite::FrameList Sprite::getCurrentAnimation() const
+{
+ return m_animations[m_currentAnimation];
+}
+
+void Sprite::nextFrame()
+{
+ m_currentFrame++;
+
+ if (m_currentFrame >= getCurrentAnimation().size())
+ m_currentFrame = 0;
+
+ setFrame(m_currentFrame);
+}
+
+void Sprite::setAnimation(const QString &anim)
+{
+ if (!m_animations.contains(anim))
+ {
+ qWarning("animation '%s' doesn't exist", anim.toUtf8().data());
+ return;
+ }
+
+ if (m_currentAnimation != anim)
+ m_currentAnimation = anim;
+}
+
+void Sprite::advance(int phase)
+{
+ if (phase == 1)
+ return;
+
+ if (m_timer.isValid() && m_timer.elapsed() >= m_interval)
+ {
+ nextFrame();
+ m_timer.start();
+ }
+
+ // this should be run the first time advance() is called
+ if (!m_timer.isValid())
+ {
+ m_timer.start();
+ }
+}
diff --git a/src/common.h b/src/common.h
new file mode 100644
index 0000000..42f55f7
--- /dev/null
+++ b/src/common.h
@@ -0,0 +1,17 @@
+#ifndef COMMON_H
+#define COMMON_H
+
+// Box2D works best for objects of size 0.1m ... 10m
+// So we have a miniature world this time, makes easier to make things happen when
+// used forces are not too big, and nothing too surprising should not happen either...
+// 16px = 0.1m
+// this makes our main character as 32px * 64px ( 20cm wide and 40cm tall )
+#define _PMF (0.1f / 16.0f)
+
+#define P2M(x) ((x) * (_PMF))
+#define M2P(x) ((x) / (_PMF))
+
+#define FPS 60
+#define FRAME_INTERVAL (1000 / FPS)
+
+#endif
diff --git a/src/src.pro b/src/src.pro
index bee809d..52faf59 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -1,64 +1,156 @@
-######################################################################
-# Automatically generated by qmake (2.01a) Thu Mar 24 21:28:35 2011
-######################################################################
-
-include(../prism.pri)
-
-QT += core gui opengl
-TEMPLATE = app
-TARGET = prism
-DEPENDPATH += .
-INCLUDEPATH += . ../libtiled
-INCLUDEPATH += $${PWD}/../Box2D $${PWD}/..
-INSTALLS += target
-target.path = $${BINDIR}
-unix:DESTDIR = ../bin
-unix:LIBS += -L../lib -L/usr/local/lib -L/usr/lib -ltiled
-win32:LIBS += G:/Projects/Qt/prism/prism-build-desktop/lib/tiled.dll
-
-OBJECTS_DIR = .obj
-
-HEADERS += MainWindow.h \
- GameScene.h \
- CreditsScene.h \
- MenuScene.h \
- LevelSelectionScene.h \
- GraphicsPixmapObject.h \
- GraphicsButtonObject.h \
- ActionScene.h \
- ParallaxScrollerStatic.h \
- ParallaxScrollerItem.h \
- SceneChanger.h \
- GameView.h \
- Character.h \
- Sprite.h \
- Collectible.h \
- Hero.h \
- BasicEnemy.h \
- BarDisplay.h \
- CircularDisplay.h \
- HeadsUpDisplay.h \
- AnimatingUiElement.h \
-
-SOURCES += main.cpp \
- MainWindow.cpp \
- GameScene.cpp \
- CreditsScene.cpp \
- MenuScene.cpp \
- LevelSelectionScene.cpp \
- GraphicsPixmapObject.cpp \
- GraphicsButtonObject.cpp \
- ActionScene.cpp \
- ParallaxScrollerStatic.cpp \
- ParallaxScrollerItem.cpp \
- SceneChanger.cpp \
- GameView.cpp \
- Character.cpp \
- Sprite.cpp \
- Collectible.cpp \
- Hero.cpp \
- BasicEnemy.cpp \
- BarDisplay.cpp \
- CircularDisplay.cpp \
- HeadsUpDisplay.cpp \
- AnimatingUiElement.cpp \
+######################################################################
+# Automatically generated by qmake (2.01a) Thu Mar 24 21:28:35 2011
+######################################################################
+
+include(../prism.pri)
+
+QT += core gui opengl
+TEMPLATE = app
+TARGET = prism
+DEPENDPATH += .
+INCLUDEPATH += . ../libtiled
+INCLUDEPATH += $${PWD}/../Box2D $${PWD}/..
+INSTALLS += target
+target.path = $${BINDIR}
+unix:DESTDIR = ../bin
+unix:LIBS += -L../lib -L/usr/local/lib -L/usr/lib -ltiled
+win32:LIBS += I:\Projects\Qt\prism\prism-build-desktop\release\lib\tiled.lib
+
+OBJECTS_DIR = .obj
+
+HEADERS += MainWindow.h \
+ GameScene.h \
+ CreditsScene.h \
+ MenuScene.h \
+ LevelSelectionScene.h \
+ GraphicsPixmapObject.h \
+ GraphicsButtonObject.h \
+ ActionScene.h \
+ ParallaxScrollerStatic.h \
+ ParallaxScrollerItem.h \
+ SceneChanger.h \
+ GameView.h \
+ Character.h \
+ Sprite.h \
+ Collectible.h \
+ Hero.h \
+ BasicEnemy.h \
+ BarDisplay.h \
+ CircularDisplay.h \
+ HeadsUpDisplay.h \
+ AnimatingUiElement.h \
+ ../Box2D/Box2D.h \
+ ../Box2D/Collision/Shapes/b2Shape.h \
+ ../Box2D/Collision/Shapes/b2PolygonShape.h \
+ ../Box2D/Collision/Shapes/b2EdgeShape.h \
+ ../Box2D/Collision/Shapes/b2CircleShape.h \
+ ../Box2D/Collision/Shapes/b2ChainShape.h \
+ ../Box2D/Collision/b2TimeOfImpact.h \
+ ../Box2D/Collision/b2DynamicTree.h \
+ ../Box2D/Collision/b2Distance.h \
+ ../Box2D/Collision/b2Collision.h \
+ ../Box2D/Collision/b2BroadPhase.h \
+ ../Box2D/Common/b2Timer.h \
+ ../Box2D/Common/b2StackAllocator.h \
+ ../Box2D/Common/b2Settings.h \
+ ../Box2D/Common/b2Math.h \
+ ../Box2D/Common/b2GrowableStack.h \
+ ../Box2D/Common/b2Draw.h \
+ ../Box2D/Common/b2BlockAllocator.h \
+ ../Box2D/Dynamics/Contacts/b2PolygonContact.h \
+ ../Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h \
+ ../Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h \
+ ../Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h \
+ ../Box2D/Dynamics/Contacts/b2ContactSolver.h \
+ ../Box2D/Dynamics/Contacts/b2Contact.h \
+ ../Box2D/Dynamics/Contacts/b2CircleContact.h \
+ ../Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.h \
+ ../Box2D/Dynamics/Contacts/b2ChainAndCircleContact.h \
+ ../Box2D/Dynamics/Joints/b2WheelJoint.h \
+ ../Box2D/Dynamics/Joints/b2WeldJoint.h \
+ ../Box2D/Dynamics/Joints/b2RopeJoint.h \
+ ../Box2D/Dynamics/Joints/b2RevoluteJoint.h \
+ ../Box2D/Dynamics/Joints/b2PulleyJoint.h \
+ ../Box2D/Dynamics/Joints/b2PrismaticJoint.h \
+ ../Box2D/Dynamics/Joints/b2MouseJoint.h \
+ ../Box2D/Dynamics/Joints/b2Joint.h \
+ ../Box2D/Dynamics/Joints/b2GearJoint.h \
+ ../Box2D/Dynamics/Joints/b2FrictionJoint.h \
+ ../Box2D/Dynamics/Joints/b2DistanceJoint.h \
+ ../Box2D/Dynamics/b2WorldCallbacks.h \
+ ../Box2D/Dynamics/b2World.h \
+ ../Box2D/Dynamics/b2TimeStep.h \
+ ../Box2D/Dynamics/b2Island.h \
+ ../Box2D/Dynamics/b2Fixture.h \
+ ../Box2D/Dynamics/b2ContactManager.h \
+ ../Box2D/Dynamics/b2Body.h \
+ ../Box2D/Rope/b2Rope.h \
+ common.h
+
+SOURCES += main.cpp \
+ MainWindow.cpp \
+ GameScene.cpp \
+ CreditsScene.cpp \
+ MenuScene.cpp \
+ LevelSelectionScene.cpp \
+ GraphicsPixmapObject.cpp \
+ GraphicsButtonObject.cpp \
+ ActionScene.cpp \
+ ParallaxScrollerStatic.cpp \
+ ParallaxScrollerItem.cpp \
+ SceneChanger.cpp \
+ GameView.cpp \
+ Character.cpp \
+ Sprite.cpp \
+ Collectible.cpp \
+ Hero.cpp \
+ BasicEnemy.cpp \
+ BarDisplay.cpp \
+ CircularDisplay.cpp \
+ HeadsUpDisplay.cpp \
+ AnimatingUiElement.cpp \
+ ../Box2D/Collision/Shapes/b2PolygonShape.cpp \
+ ../Box2D/Collision/Shapes/b2EdgeShape.cpp \
+ ../Box2D/Collision/Shapes/b2CircleShape.cpp \
+ ../Box2D/Collision/Shapes/b2ChainShape.cpp \
+ ../Box2D/Collision/b2TimeOfImpact.cpp \
+ ../Box2D/Collision/b2DynamicTree.cpp \
+ ../Box2D/Collision/b2Distance.cpp \
+ ../Box2D/Collision/b2Collision.cpp \
+ ../Box2D/Collision/b2CollidePolygon.cpp \
+ ../Box2D/Collision/b2CollideEdge.cpp \
+ ../Box2D/Collision/b2CollideCircle.cpp \
+ ../Box2D/Collision/b2BroadPhase.cpp \
+ ../Box2D/Common/b2Timer.cpp \
+ ../Box2D/Common/b2StackAllocator.cpp \
+ ../Box2D/Common/b2Settings.cpp \
+ ../Box2D/Common/b2Math.cpp \
+ ../Box2D/Common/b2Draw.cpp \
+ ../Box2D/Common/b2BlockAllocator.cpp \
+ ../Box2D/Dynamics/Contacts/b2PolygonContact.cpp \
+ ../Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.cpp \
+ ../Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.cpp \
+ ../Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.cpp \
+ ../Box2D/Dynamics/Contacts/b2ContactSolver.cpp \
+ ../Box2D/Dynamics/Contacts/b2Contact.cpp \
+ ../Box2D/Dynamics/Contacts/b2CircleContact.cpp \
+ ../Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.cpp \
+ ../Box2D/Dynamics/Contacts/b2ChainAndCircleContact.cpp \
+ ../Box2D/Dynamics/Joints/b2WheelJoint.cpp \
+ ../Box2D/Dynamics/Joints/b2WeldJoint.cpp \
+ ../Box2D/Dynamics/Joints/b2RopeJoint.cpp \
+ ../Box2D/Dynamics/Joints/b2RevoluteJoint.cpp \
+ ../Box2D/Dynamics/Joints/b2PulleyJoint.cpp \
+ ../Box2D/Dynamics/Joints/b2PrismaticJoint.cpp \
+ ../Box2D/Dynamics/Joints/b2MouseJoint.cpp \
+ ../Box2D/Dynamics/Joints/b2Joint.cpp \
+ ../Box2D/Dynamics/Joints/b2GearJoint.cpp \
+ ../Box2D/Dynamics/Joints/b2FrictionJoint.cpp \
+ ../Box2D/Dynamics/Joints/b2DistanceJoint.cpp \
+ ../Box2D/Dynamics/b2WorldCallbacks.cpp \
+ ../Box2D/Dynamics/b2World.cpp \
+ ../Box2D/Dynamics/b2Island.cpp \
+ ../Box2D/Dynamics/b2Fixture.cpp \
+ ../Box2D/Dynamics/b2ContactManager.cpp \
+ ../Box2D/Dynamics/b2Body.cpp \
+ ../Box2D/Rope/b2Rope.cpp