diff options
| author | manuel <manuel@mausz.at> | 2011-04-09 15:05:45 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2011-04-09 15:05:45 +0200 |
| commit | 7bfd0036b3297992dc6644eecfcbab5325756a1d (patch) | |
| tree | 326166529ad460a2801fdb7e251c4c26a3441170 /pacman-c++/util.cpp | |
| parent | 9f896b86b671b3a05314d2013a315d996b456f95 (diff) | |
| parent | d547dec802f76c346538144f4eacf6d8ca6310c4 (diff) | |
| download | foop-7bfd0036b3297992dc6644eecfcbab5325756a1d.tar.gz foop-7bfd0036b3297992dc6644eecfcbab5325756a1d.tar.bz2 foop-7bfd0036b3297992dc6644eecfcbab5325756a1d.zip | |
Merge branch 'master' of ssh://manuel.mausz.at/foop
Conflicts:
pacman-c++/pacman.pro
Diffstat (limited to 'pacman-c++/util.cpp')
| -rw-r--r-- | pacman-c++/util.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/pacman-c++/util.cpp b/pacman-c++/util.cpp new file mode 100644 index 0000000..185b0a6 --- /dev/null +++ b/pacman-c++/util.cpp | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | #include "util.h" | ||
| 2 | |||
| 3 | // temporary | ||
| 4 | Transmission::map_t createDummyMap() | ||
| 5 | { | ||
| 6 | Transmission::map_t map; | ||
| 7 | map = new Transmission::field_t*[Constants::map_size.width]; | ||
| 8 | for (unsigned int i = 0; i < Constants::map_size.width; ++i) | ||
| 9 | map[i] = new Transmission::field_t[Constants::map_size.height]; | ||
| 10 | |||
| 11 | for (unsigned int x = 0; x < Constants::map_size.width; ++x) | ||
| 12 | { | ||
| 13 | for (unsigned int y = 0; y < Constants::map_size.height; ++y) | ||
| 14 | { | ||
| 15 | Transmission::field_t &cur = map[x][y]; | ||
| 16 | cur = Transmission::none; | ||
| 17 | } | ||
| 18 | } | ||
| 19 | |||
| 20 | |||
| 21 | const char *tmpl[] = { | ||
| 22 | " # # ", | ||
| 23 | " #### ###### # #### # # ###### ### ", | ||
| 24 | " # # ", | ||
| 25 | " # ##### # # # # # ### # # # ", | ||
| 26 | " # # # # # # # # # # ## # # ", | ||
| 27 | " # # # # # # # # ### # # # # ", | ||
| 28 | " # # # # # # # # # # # # ## # ", | ||
| 29 | " # # ### ##### # ### # # # ", | ||
| 30 | " ### # ", | ||
| 31 | " # # ### #### #### #### ##### ", | ||
| 32 | " #### # #..# #..# #..# # # ", | ||
| 33 | " # # ### #..# #..# #### # # # # ", | ||
| 34 | " # # # #..# #..# # # ", | ||
| 35 | " # #### # #### #### # # ##### # ", | ||
| 36 | " # # ", | ||
| 37 | " #### ###### # ##### # ####### ### ", | ||
| 38 | " # # " | ||
| 39 | }; | ||
| 40 | |||
| 41 | for (unsigned int x = 0; x < Constants::map_size.width; ++x) | ||
| 42 | { | ||
| 43 | for (unsigned int y = 0; y < Constants::map_size.height; ++y) | ||
| 44 | { | ||
| 45 | Transmission::field_t &cur = map[x][y]; | ||
| 46 | cur = Transmission::none; | ||
| 47 | if (tmpl[y][x] == '#') | ||
| 48 | cur |= Color::none | Transmission::block; | ||
| 49 | /* this is a simple hack to create areas where no | ||
| 50 | * autoplaced points will be placed (see below) | ||
| 51 | */ | ||
| 52 | else if (tmpl[y][x] == '.') | ||
| 53 | cur |= Transmission::point; | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | map[0][0] |= Transmission::bonuspoint; | ||
| 58 | map[1][0] |= Color::red | Transmission::pacman | Transmission::direction_right; | ||
| 59 | //map[2][0] |= Color::blue | Transmission::pacman | Transmission::direction_up; | ||
| 60 | //map[3][0] |= Color::green | Transmission::pacman | Transmission::direction_down; | ||
| 61 | |||
| 62 | /* auto place normal points*/ | ||
| 63 | for (unsigned int x = 0; x < Constants::map_size.width; ++x) | ||
| 64 | { | ||
| 65 | for (unsigned int y = 0; y < Constants::map_size.height; ++y) | ||
| 66 | { | ||
| 67 | Transmission::field_t &cur = map[x][y]; | ||
| 68 | if (cur == Transmission::none) | ||
| 69 | cur |= Transmission::point; | ||
| 70 | else if (cur == Transmission::point) | ||
| 71 | cur = Transmission::none; | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | return map; | ||
| 76 | } | ||
