From 536ddd91ae7f162045226d4b358ba95d678f6deb Mon Sep 17 00:00:00 2001 From: manuel Date: Fri, 15 Apr 2011 03:20:17 +0200 Subject: add support for random bonus points --- pacman-c++/util.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'pacman-c++/util.cpp') diff --git a/pacman-c++/util.cpp b/pacman-c++/util.cpp index 2a3b78a..708d005 100644 --- a/pacman-c++/util.cpp +++ b/pacman-c++/util.cpp @@ -77,7 +77,13 @@ namespace Util void placeActors(Transmission::map_t map, unsigned int players, const Color::Color *colors) { - int mindistance = 5; +#if 0 + for(unsigned int i = 0; i < players; ++i) + map[i][0] = colors[i] | Transmission::pacman | Transmission::direction_none; + return; +#endif + + int mindistance = Constants::Game::player_minimum_distance; /* this outer loop is used if there are no more valid places left * so we can change mindistance */ @@ -107,9 +113,9 @@ namespace Util int rand = (int) (validpos.size() * (qrand() / (RAND_MAX + 1.0))); QPoint newpos = validpos.at(rand); map[newpos.x()][newpos.y()] = colors[i] | Transmission::pacman | Transmission::direction_none; + qDebug() << "Actor" << i << "at" << newpos; actors.append(newpos); validpos.removeAt(rand); - qDebug() << "actor" << colors[i] << "at" << newpos; QMutableListIterator j(validpos); while(j.hasNext()) @@ -123,14 +129,14 @@ namespace Util if (validpos.empty()) { qWarning() << "There are no more valid positions for actors left on the map"; - mindistance -= 2; + mindistance -= Constants::Game::player_distance_decr; break; } } } } - void makePoints(Transmission::map_t map) + void fillPoints(Transmission::map_t map, Transmission::field_t type) { /* auto place normal points*/ for (unsigned int x = 0; x < Constants::map_size.width; ++x) @@ -139,7 +145,7 @@ namespace Util { Transmission::field_t &cur = map[x][y]; if (cur == Transmission::none) - cur |= Transmission::point; + cur = type; else if (cur == Transmission::point) cur = Transmission::none; } -- cgit v1.2.3