diff options
| author | totycro <totycro@unknown-horizons.org> | 2011-04-09 15:08:13 +0200 |
|---|---|---|
| committer | totycro <totycro@unknown-horizons.org> | 2011-04-09 15:08:13 +0200 |
| commit | 979c3b4528da1608404d6e163211280fee5da9c5 (patch) | |
| tree | dd5584640933fc6bce1820bcc452af74d356396f /pacman-c++/sceneholder.cpp | |
| parent | d547dec802f76c346538144f4eacf6d8ca6310c4 (diff) | |
| download | foop-979c3b4528da1608404d6e163211280fee5da9c5.tar.gz foop-979c3b4528da1608404d6e163211280fee5da9c5.tar.bz2 foop-979c3b4528da1608404d6e163211280fee5da9c5.zip | |
added some utility
Diffstat (limited to 'pacman-c++/sceneholder.cpp')
| -rw-r--r-- | pacman-c++/sceneholder.cpp | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/pacman-c++/sceneholder.cpp b/pacman-c++/sceneholder.cpp index 83025d5..ba9cc97 100644 --- a/pacman-c++/sceneholder.cpp +++ b/pacman-c++/sceneholder.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include "actor.h" | 6 | #include "actor.h" |
| 7 | #include "bonuspoint.h" | 7 | #include "bonuspoint.h" |
| 8 | #include "point.h" | 8 | #include "point.h" |
| 9 | #include "util.h" | ||
| 9 | 10 | ||
| 10 | SceneHolder::SceneHolder(QWidget* parent): QWidget(parent) | 11 | SceneHolder::SceneHolder(QWidget* parent): QWidget(parent) |
| 11 | { | 12 | { |
| @@ -66,27 +67,8 @@ void SceneHolder::updateMap(const Transmission::map_t& map) | |||
| 66 | actor->setPos(mapPositionToCoord(x, y)); | 67 | actor->setPos(mapPositionToCoord(x, y)); |
| 67 | } | 68 | } |
| 68 | 69 | ||
| 69 | Actor::Movement direction = Actor::None; | 70 | Actor::Movement direction = |
| 70 | switch (cur & Transmission::direction_mask) | 71 | Util::transmissionMovementToActor(cur & Transmission::direction_mask); |
| 71 | { | ||
| 72 | case Transmission::direction_none: | ||
| 73 | direction = Actor::None; | ||
| 74 | break; | ||
| 75 | case Transmission::direction_left: | ||
| 76 | direction = Actor::Left; | ||
| 77 | break; | ||
| 78 | case Transmission::direction_right: | ||
| 79 | direction = Actor::Right; | ||
| 80 | break; | ||
| 81 | case Transmission::direction_up: | ||
| 82 | direction = Actor::Up; | ||
| 83 | break; | ||
| 84 | case Transmission::direction_down: | ||
| 85 | direction = Actor::Down; | ||
| 86 | break; | ||
| 87 | default: | ||
| 88 | Q_ASSERT(false); | ||
| 89 | } | ||
| 90 | //actor->move(direction, mapPositionToCoord(x, y)); | 72 | //actor->move(direction, mapPositionToCoord(x, y)); |
| 91 | } | 73 | } |
| 92 | else | 74 | else |
| @@ -112,4 +94,11 @@ void SceneHolder::updateMap(const Transmission::map_t& map) | |||
| 112 | QPoint SceneHolder::mapPositionToCoord(unsigned int x, unsigned int y) | 94 | QPoint SceneHolder::mapPositionToCoord(unsigned int x, unsigned int y) |
| 113 | { | 95 | { |
| 114 | return QPoint(x * Constants::field_size.width, y * Constants::field_size.height); | 96 | return QPoint(x * Constants::field_size.width, y * Constants::field_size.height); |
| 115 | } \ No newline at end of file | 97 | } |
| 98 | |||
| 99 | QPoint SceneHolder::CoordToMapPosition(unsigned int x, unsigned int y) | ||
| 100 | { | ||
| 101 | return QPoint(x / Constants::field_size.width, y / Constants::field_size.height); | ||
| 102 | } | ||
| 103 | |||
| 104 | |||
