summaryrefslogtreecommitdiffstats
path: root/pacman-c++/util.cpp
diff options
context:
space:
mode:
authortotycro <totycro@unknown-horizons.org>2011-04-09 13:54:18 +0200
committertotycro <totycro@unknown-horizons.org>2011-04-09 13:54:18 +0200
commitd547dec802f76c346538144f4eacf6d8ca6310c4 (patch)
tree50613653be09988bfd1a122496faed93c960de45 /pacman-c++/util.cpp
parent7e4bc8ece49543533c4e27f5d6bc867c1bada601 (diff)
downloadfoop-d547dec802f76c346538144f4eacf6d8ca6310c4.tar.gz
foop-d547dec802f76c346538144f4eacf6d8ca6310c4.tar.bz2
foop-d547dec802f76c346538144f4eacf6d8ca6310c4.zip
Pull up methods from mainwidget to sceneholder for sharing in both client and server
Diffstat (limited to 'pacman-c++/util.cpp')
-rw-r--r--pacman-c++/util.cpp76
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
4Transmission::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}