def wall(wall_type: WallType):
     entity = create_wall(wall_type, (0, 0)).world_entity
     e = MapEditorWorldEntity(
         entity.sprite,
         (entity.pygame_collision_rect.w, entity.pygame_collision_rect.h))
     e.wall_type = wall_type
     return e
예제 #2
0
def _add_wall(game_state, snapped_mouse_world_position: Tuple[int, int],
              wall_type: WallType):
    if len(
            game_state.walls_state.get_walls_at_position(
                snapped_mouse_world_position)) == 0:
        wall = create_wall(wall_type, snapped_mouse_world_position)
        game_state.walls_state.add_wall(wall)
예제 #3
0
 def _set_wall(self, world_pos: Tuple[int, int], wall_type: WallType):
     existing_walls = self.game_state.game_world.walls_state.get_walls_at_position(
         world_pos)
     if len(existing_walls) > 0:
         if existing_walls[0].wall_type == wall_type:
             return
         for w in existing_walls:
             self.game_state.game_world.walls_state.remove_wall(w)
     wall = create_wall(wall_type, world_pos)
     self.game_state.game_world.walls_state.add_wall(wall)
     self._notify_ui_of_new_wall_positions()
예제 #4
0
    def _create_floor_tiles_and_walls_from_grid(self, grid: Grid, xrange: Tuple[int, int], yrange: Tuple[int, int]) -> \
            Tuple[List[DecorationEntity], List[Wall]]:
        decorations: List[DecorationEntity] = []
        walls: List[Wall] = []

        for y in range(yrange[0], yrange[1]):
            for x in range(xrange[0], xrange[1]):
                position = (x * CELL_SIZE, y * CELL_SIZE)
                is_even_cell = x % 2 == 0 and y % 2 == 0  # ground sprite covers 4 cells, so we only need them on even cells
                if is_even_cell and any([grid.is_floor(c) for c in [(x, y), (x + 1, y), (x, y + 1), (x + 1, y + 1)]]):
                    decorations.append(create_decoration_entity(position, Sprite.DECORATION_GROUND_STONE))
                if grid.is_wall((x, y)):
                    wall_type = self.determine_wall_type(grid, (x, y))
                    walls.append(create_wall(wall_type, position))
        return decorations, walls
예제 #5
0
 def deserialize(data) -> Wall:
     return create_wall(WallType[data["wall_type"]], data["position"])