def _add_decoration(decoration_sprite: Sprite, game_state: GameState, snapped_mouse_world_position): if len( game_state.decorations_state.get_decorations_at_position( snapped_mouse_world_position)) == 0: decoration_entity = create_decoration_entity( snapped_mouse_world_position, decoration_sprite) game_state.decorations_state.add_decoration(decoration_entity)
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
def decoration(sprite: Sprite): decoration_entity = create_decoration_entity((0, 0), sprite) e = MapEditorWorldEntity(decoration_entity.sprite, (0, 0)) e.decoration_sprite = sprite return e
def deserialize(data) -> DecorationEntity: return create_decoration_entity(data["position"], Sprite[data["sprite"]])