diff options
| -rwxr-xr-x | main.py | 87 | ||||
| -rw-r--r-- | resources/colors | 8 | ||||
| -rw-r--r-- | resources/grass.png | bin | 0 -> 200 bytes | |||
| -rw-r--r-- | resources/road2.png | bin | 0 -> 244 bytes | |||
| -rw-r--r-- | resources/road4.png | bin | 0 -> 258 bytes | |||
| -rw-r--r-- | resources/road6.png | bin | 0 -> 253 bytes | |||
| -rw-r--r-- | resources/water.png | bin | 0 -> 200 bytes |
7 files changed, 95 insertions, 0 deletions
@@ -0,0 +1,87 @@ +#! python + +"""MinCity + + + +(C) 2015 Timo Wilken +""" + +from enum import Enum, unique +from array import array + +import pygame +from pygame.locals import * + + +@unique +class Tile(Enum): + def __init__(self, value=None): + self._value_ = len(self.__class__.__members__) + 1 + self.image_name = self._name_ + + water = () + grass = () + road2 = () + road4 = () + road6 = () + + +class CityMap: + """What's where in the city. + + The following map: + + 0123 + 4567 + 89AB + + is stored internally as an array with the following contents: + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B] + """ + + def __init__(self, width, height): + self._width = width + self._height = height + self._tiles = array('L') + + def get_tile(self, x, y): + return Tile(self._tiles[x + y*self._width]) + + def __len__(self): + return self._width, self._height + + def __getitem__(self, key): + try: + x, y = key + return self.get_tile(x, y) + except TypeError: + return Tile(self._tiles[key]) + + +def load_images(): + pass + + +def main(): + pygame.init() + surface = pygame.display.set_mode((640, 480)) + + images = load_images() + map = CityMap(16, 16) + + run = True + while run: + for e in pygame.event.get(): + if e.type == QUIT: + run = False + break + surface.fill((0xFF, 0xFF, 0xFF)) + pygame.display.update() + + pygame.quit() + + +if __name__ == '__main__': + main() + diff --git a/resources/colors b/resources/colors new file mode 100644 index 0000000..1e8f0bf --- /dev/null +++ b/resources/colors @@ -0,0 +1,8 @@ +asphalt 282b2a +road markings: + white dddddd + yellow e5d663 +concrete +grass 4dbd33 +water 0b57a4 + diff --git a/resources/grass.png b/resources/grass.png Binary files differnew file mode 100644 index 0000000..628f8dc --- /dev/null +++ b/resources/grass.png diff --git a/resources/road2.png b/resources/road2.png Binary files differnew file mode 100644 index 0000000..8177894 --- /dev/null +++ b/resources/road2.png diff --git a/resources/road4.png b/resources/road4.png Binary files differnew file mode 100644 index 0000000..892f014 --- /dev/null +++ b/resources/road4.png diff --git a/resources/road6.png b/resources/road6.png Binary files differnew file mode 100644 index 0000000..59c40dd --- /dev/null +++ b/resources/road6.png diff --git a/resources/water.png b/resources/water.png Binary files differnew file mode 100644 index 0000000..50dc239 --- /dev/null +++ b/resources/water.png |
