diff options
Diffstat (limited to 'pacman-c++/server.cpp')
| -rw-r--r-- | pacman-c++/server.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp index b0ac6f8..dd15934 100644 --- a/pacman-c++/server.cpp +++ b/pacman-c++/server.cpp | |||
| @@ -83,21 +83,11 @@ invalid_direction: | |||
| 83 | 83 | ||
| 84 | // <t3h g4m3 10gic> | 84 | // <t3h g4m3 10gic> |
| 85 | // TODO: support actors eating each other | 85 | // TODO: support actors eating each other |
| 86 | // old item | 86 | /* check if there's an item at new location of actor */ |
| 87 | PixmapItem *oldItem = visualMap[mapPosition.x()][mapPosition.y()]; | 87 | GameEntity *item = visualMap[newMapPosition.x()][newMapPosition.y()]; |
| 88 | if (oldItem != NULL) | ||
| 89 | { | ||
| 90 | /* set item to explicit empty | ||
| 91 | * and add actor that removed/has eaten that item | ||
| 92 | */ | ||
| 93 | if (oldItem->eaten()) | ||
| 94 | map[mapPosition.x()][mapPosition.y()] = Transmission::empty | actor->color(); | ||
| 95 | } | ||
| 96 | |||
| 97 | // new item | ||
| 98 | PixmapItem *item = visualMap[newMapPosition.x()][newMapPosition.y()]; | ||
| 99 | if (item != NULL && oldItem != item) | 88 | if (item != NULL && oldItem != item) |
| 100 | { | 89 | { |
| 90 | qDebug() << "item at new actor location found"; | ||
| 101 | if (!item->checkEnter(actor)) | 91 | if (!item->checkEnter(actor)) |
| 102 | { | 92 | { |
| 103 | /* movement invalid. e.g. move against wall */ | 93 | /* movement invalid. e.g. move against wall */ |
| @@ -105,11 +95,11 @@ invalid_direction: | |||
| 105 | } | 95 | } |
| 106 | else | 96 | else |
| 107 | { | 97 | { |
| 108 | // apply actions of entering this field | 98 | /* apply actions of entering this field */ |
| 109 | bool survive = item->enter(actor); | 99 | bool survive = item->enter(actor); |
| 110 | if (!survive) | 100 | if (!survive) |
| 111 | { | 101 | { |
| 112 | //map[newMapPosition.x()][newMapPosition.y()] = Transmission::empty; | 102 | map[newMapPosition.x()][newMapPosition.y()] = Transmission::empty | actor->color(); |
| 113 | } | 103 | } |
| 114 | } | 104 | } |
| 115 | } | 105 | } |
| @@ -134,6 +124,9 @@ invalid_direction: | |||
| 134 | map[newMapPosition.x()][newMapPosition.y()] |= Transmission::pacman | | 124 | map[newMapPosition.x()][newMapPosition.y()] |= Transmission::pacman | |
| 135 | i.key() | Util::actorMovementToTransmission(i.value()); | 125 | i.key() | Util::actorMovementToTransmission(i.value()); |
| 136 | 126 | ||
| 127 | /* DEBUG: uncomments to disable auto-movement */ | ||
| 128 | //m_actorMovements[i.key()] = Actor::None; | ||
| 129 | |||
| 137 | if (i.value() == Actor::None) | 130 | if (i.value() == Actor::None) |
| 138 | { | 131 | { |
| 139 | /* set actor to non-moving */ | 132 | /* set actor to non-moving */ |
