From a5ea024b0119a4b0fea858ae9115d744a786d3af Mon Sep 17 00:00:00 2001 From: totycro Date: Mon, 4 Apr 2011 20:35:49 +0200 Subject: change project file: use: qmake -config client or qmake -config main Added basic client gui infrastructure --- pacman-c++/client.cpp | 20 ++++++++++++++++++++ pacman-c++/client.h | 18 ++++++++++++++++++ pacman-c++/constants.h | 23 +++++++++++++++++++++++ pacman-c++/mainwidget.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ pacman-c++/mainwidget.h | 20 ++++++++++++++++++++ pacman-c++/pacman-c++.kdev4 | 3 +++ pacman-c++/pacman.pro | 18 ++++++++++++++++-- 7 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 pacman-c++/client.cpp create mode 100644 pacman-c++/client.h create mode 100644 pacman-c++/constants.h create mode 100644 pacman-c++/mainwidget.cpp create mode 100644 pacman-c++/mainwidget.h create mode 100644 pacman-c++/pacman-c++.kdev4 diff --git a/pacman-c++/client.cpp b/pacman-c++/client.cpp new file mode 100644 index 0000000..416bd12 --- /dev/null +++ b/pacman-c++/client.cpp @@ -0,0 +1,20 @@ +#include "client.h" + +Client::Client() +{ + mainWidget = new MainWidget(); + setCentralWidget(mainWidget); +} + + +int main(int argc, char ** argv) { + QApplication app(argc, argv); + app.setApplicationName("pacman-client"); + + qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); + + Client client; + client.show(); + + return app.exec(); +} diff --git a/pacman-c++/client.h b/pacman-c++/client.h new file mode 100644 index 0000000..2816ec2 --- /dev/null +++ b/pacman-c++/client.h @@ -0,0 +1,18 @@ +#ifndef CLIENT_H +#define CLIENT_H + +#include + +#include "mainwidget.h" + +class Client + : public QMainWindow { + Q_OBJECT +public: + Client(); + +private: + MainWidget *mainWidget; +}; + +#endif // CLIENT_H \ No newline at end of file diff --git a/pacman-c++/constants.h b/pacman-c++/constants.h new file mode 100644 index 0000000..278f2b3 --- /dev/null +++ b/pacman-c++/constants.h @@ -0,0 +1,23 @@ +#ifndef CONSTANTS_H +#define CONSTANTS_H + +const unsigned int map_size[2] = { 20, 20 }; +const unsigned int field_size[2] = { 16, 16 }; + +// constants for data transmission to client +namespace transmission { + + typedef unsigned int field_t; + const field_t red = (1 << 0); + const field_t blue = (1 << 1); + const field_t green = (1 << 2); + + const field_t box = (1 << 3); + const field_t foo = (1 << 4); + + typedef field_t** map_t; +} + + + +#endif // CONSTANTS_H \ No newline at end of file diff --git a/pacman-c++/mainwidget.cpp b/pacman-c++/mainwidget.cpp new file mode 100644 index 0000000..982c809 --- /dev/null +++ b/pacman-c++/mainwidget.cpp @@ -0,0 +1,41 @@ +#include "mainwidget.h" + +#include "actor.h" +#include "block.h" + +MainWidget::MainWidget() { + + QVBoxLayout *layout = new QVBoxLayout(this); + + QLabel *lbl = new QLabel("da kommt da spielstand hin", this); + layout->addWidget(lbl); + + scene = new QGraphicsScene(0, 0, 500, 500, this); + scene->setBackgroundBrush(Qt::black); + + QGraphicsView *window = new QGraphicsView(scene, this); + window->setFrameStyle(0); + window->setAlignment(Qt::AlignLeft | Qt::AlignTop); + window->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + window->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + layout->addWidget(window); + + setLayout(layout); + setWindowTitle("pacman client"); + + loadDummyMap(); +} + +void MainWidget::loadDummyMap() +{ + Actor *actor3 = new Actor(Actor::Player3); + scene->addItem(actor3); + actor3->setPos(140, 100); + + for (unsigned int i=0; i<20; ++i) { + Block *b = new Block(Actor::Player1); + scene->addItem(b); + b->setPos( 100 + i*16, 200); + } + +} diff --git a/pacman-c++/mainwidget.h b/pacman-c++/mainwidget.h new file mode 100644 index 0000000..d1ec761 --- /dev/null +++ b/pacman-c++/mainwidget.h @@ -0,0 +1,20 @@ +#ifndef MAINWIDGET_H +#define MAINWIDGET_H + +#include + +class MainWidget + : public QWidget +{ + Q_OBJECT + +public: + MainWidget(); + +private: + void loadDummyMap(); + + QGraphicsScene *scene; +}; + +#endif // MAINWIDGET_H \ No newline at end of file diff --git a/pacman-c++/pacman-c++.kdev4 b/pacman-c++/pacman-c++.kdev4 new file mode 100644 index 0000000..dbc9bc5 --- /dev/null +++ b/pacman-c++/pacman-c++.kdev4 @@ -0,0 +1,3 @@ +[Project] +Manager=KDevGenericManager +Name=pacman-c++ diff --git a/pacman-c++/pacman.pro b/pacman-c++/pacman.pro index 2bb8629..f63612d 100644 --- a/pacman-c++/pacman.pro +++ b/pacman-c++/pacman.pro @@ -1,6 +1,5 @@ QT += phonon -SOURCES += main.cpp \ - pixmapitem.cpp \ +SOURCES += pixmapitem.cpp \ actor.cpp \ animationmanager.cpp \ block.cpp @@ -13,3 +12,18 @@ RESOURCES += pacman.qrc OBJECTS_DIR = .obj MOC_DIR = .moc + + +client { + SOURCES += client.cpp \ + mainwidget.cpp + HEADERS += client.h \ + mainwidget.h + TARGET = client +} + +main { + SOURCES += main.cpp + TARGET = pacman +} + -- cgit v1.2.3