Example #1
0
 def new_game(self):
     gb = game.Gameboard()
     gb.gamemap = gamemap.load_ascii_map(util.data_dir("testmap2.txt"))
     gb.PC = game.PC()
     gb.PC.coords = (10,5)
     gb.gamemap.objects[gb.PC.coords].append(gb.PC)
     ui.UI.new_game(self, gb)
     
     self.layers = [MapLayer(gamemap.Map(gb.gamemap.size), gb.gamemap, self), HUDLayer(gb,self)]
Example #2
0
            if isinstance(obj, terrain.Terrain):
                self.map_to_draw.set_terrain(coords, obj)
                del self.map_to_draw.objects[coords][:]
        for coords, obj in things:
            if not isinstance(obj, terrain.Terrain):
                self.map_to_draw.objects[coords].append(obj)

if __name__ == '__main__':
    import sys
    
    pygame.init()
    size = width, height = 800,  600
    screen = pygame.display.set_mode(size)

    clock = pygame.time.Clock()
    M = gamemap.load_ascii_map(util.data_dir("testmap2.txt"))
    S = SDLMap(M,M)

    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_UP:
                    S.view_y -= 16
                elif event.key == pygame.K_DOWN:
                    S.view_y += 16
                elif event.key == pygame.K_LEFT:
                    S.view_x -= 16
                elif event.key == pygame.K_RIGHT:
                    S.view_x += 16