diff options
| author | totycro <totycro@unknown-horizons.org> | 2011-04-04 22:02:31 +0200 |
|---|---|---|
| committer | totycro <totycro@unknown-horizons.org> | 2011-04-04 22:02:31 +0200 |
| commit | eef1d8ea60e3797ba261ebfe61a7d1e165069ed4 (patch) | |
| tree | c10e397f58af5dafd0d450bb104fb3122bb611e2 /pacman-c++/mainwidget.cpp | |
| parent | 47ae4a32e6e81dabbd2784a4b3c9c4ad68076a50 (diff) | |
| download | foop-eef1d8ea60e3797ba261ebfe61a7d1e165069ed4.tar.gz foop-eef1d8ea60e3797ba261ebfe61a7d1e165069ed4.tar.bz2 foop-eef1d8ea60e3797ba261ebfe61a7d1e165069ed4.zip | |
Use only 1 color format for everything
Simple map parsing for Blocks and Bonus points
Diffstat (limited to 'pacman-c++/mainwidget.cpp')
| -rw-r--r-- | pacman-c++/mainwidget.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/pacman-c++/mainwidget.cpp b/pacman-c++/mainwidget.cpp index 982c809..72d9c8a 100644 --- a/pacman-c++/mainwidget.cpp +++ b/pacman-c++/mainwidget.cpp | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | #include "actor.h" | 3 | #include "actor.h" |
| 4 | #include "block.h" | 4 | #include "block.h" |
| 5 | #include "bonuspoint.h" | ||
| 6 | #include "constants.h" | ||
| 5 | 7 | ||
| 6 | MainWidget::MainWidget() { | 8 | MainWidget::MainWidget() { |
| 7 | 9 | ||
| @@ -26,8 +28,62 @@ MainWidget::MainWidget() { | |||
| 26 | loadDummyMap(); | 28 | loadDummyMap(); |
| 27 | } | 29 | } |
| 28 | 30 | ||
| 31 | // temporary | ||
| 32 | transmission::map_t createDummyMap() { | ||
| 33 | transmission::map_t map; | ||
| 34 | map = new transmission::field_t*[map_size[0]]; | ||
| 35 | for (unsigned int i=0; i<map_size[0]; ++i) { | ||
| 36 | map[i] = new transmission::field_t[map_size[1]]; | ||
| 37 | } | ||
| 38 | for (unsigned int x=0; x<map_size[0]; ++x) { | ||
| 39 | for (unsigned int y=0; y<map_size[1]; ++y) { | ||
| 40 | transmission::field_t &cur = map[x][y]; | ||
| 41 | cur = 0; | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | map[4][3] |= green; | ||
| 46 | map[4][3] |= transmission::block; | ||
| 47 | |||
| 48 | map[5][3] |= noColor; | ||
| 49 | map[5][3] |= transmission::block; | ||
| 50 | map[6][3] |= noColor; | ||
| 51 | map[6][3] |= transmission::block; | ||
| 52 | map[7][3] |= red; | ||
| 53 | map[7][3] |= transmission::block; | ||
| 54 | |||
| 55 | map[7][5] |= transmission::bonuspoint; | ||
| 56 | |||
| 57 | return map; | ||
| 58 | } | ||
| 29 | void MainWidget::loadDummyMap() | 59 | void MainWidget::loadDummyMap() |
| 30 | { | 60 | { |
| 61 | transmission::map_t map = createDummyMap(); | ||
| 62 | |||
| 63 | for (unsigned int x=0; x<map_size[0]; ++x) { | ||
| 64 | for (unsigned int y=0; y<map_size[1]; ++y) { | ||
| 65 | const transmission::field_t &cur = map[x][y]; | ||
| 66 | if (cur == 0) { | ||
| 67 | continue; | ||
| 68 | } | ||
| 69 | qDebug() << "not 0 at " << x << "," << y << ":" << cur; | ||
| 70 | |||
| 71 | Color color = static_cast<Color>(cur & transmission::color_mask); | ||
| 72 | qDebug() << "col " << color; | ||
| 73 | |||
| 74 | PixmapItem *item = 0; | ||
| 75 | if (cur & transmission::block) { | ||
| 76 | item = new Block(color); | ||
| 77 | } else if (cur & transmission::bonuspoint) { | ||
| 78 | item = new BonusPoint(); | ||
| 79 | } | ||
| 80 | Q_ASSERT(item != 0); | ||
| 81 | scene->addItem(item); | ||
| 82 | item->setPos( mapPositionToCoord(x, y) ); | ||
| 83 | } | ||
| 84 | } | ||
| 85 | |||
| 86 | /* | ||
| 31 | Actor *actor3 = new Actor(Actor::Player3); | 87 | Actor *actor3 = new Actor(Actor::Player3); |
| 32 | scene->addItem(actor3); | 88 | scene->addItem(actor3); |
| 33 | actor3->setPos(140, 100); | 89 | actor3->setPos(140, 100); |
| @@ -37,5 +93,10 @@ void MainWidget::loadDummyMap() | |||
| 37 | scene->addItem(b); | 93 | scene->addItem(b); |
| 38 | b->setPos( 100 + i*16, 200); | 94 | b->setPos( 100 + i*16, 200); |
| 39 | } | 95 | } |
| 96 | */ | ||
| 97 | } | ||
| 40 | 98 | ||
| 99 | QPoint MainWidget::mapPositionToCoord(unsigned int x, unsigned int y) | ||
| 100 | { | ||
| 101 | return QPoint(x * field_size[0], y * field_size[1]); | ||
| 41 | } | 102 | } |
