def tiled_npc_set(self): tiled_npc_sprite = arcade.SpriteList(use_spatial_hash=True, spatial_hash_cell_size=32) villager_list = arcade.process_layer(self.my_map, "villager", scaling=2, use_spatial_hash=True, hit_box_algorithm="None") for v in villager_list: x, y = pixel_to_grid(v.center_x, v.center_y) villager = Villager(x=x, y=y) tiled_npc_sprite.append(villager) citizen_list = arcade.process_layer(self.my_map, "citizen", scaling=2, use_spatial_hash=True, hit_box_algorithm="None") for c in citizen_list: x, y = pixel_to_grid(c.center_x, c.center_y) citizen = Citizen(x=x, y=y) tiled_npc_sprite.append(citizen) return tiled_npc_sprite
def tiled_map_obj_set(self): tiled_map_obj_sprite = arcade.SpriteList(use_spatial_hash=True, spatial_hash_cell_size=32) door = arcade.process_layer(self.my_map, "door", scaling=2, use_spatial_hash=True, hit_box_algorithm="None") up_stairs = arcade.process_layer(self.my_map, "up_stairs", scaling=2, use_spatial_hash=True, hit_box_algorithm="None") down_stairs = arcade.process_layer(self.my_map, "down_stairs", scaling=2, use_spatial_hash=True, hit_box_algorithm="None") for m in door: x, y = pixel_to_grid(m.center_x, m.center_y) obj = DoorH(x=x, y=y) obj.scale = 2 obj.texture = m.texture obj.blocks = True tiled_map_obj_sprite.append(obj) for m in up_stairs: x, y = pixel_to_grid(m.center_x, m.center_y) obj = Up_Stairs(x=x, y=y) obj.scale = 2 # obj.texture = m.texture obj.blocks = True tiled_map_obj_sprite.append(obj) for m in down_stairs: x, y = pixel_to_grid(m.center_x, m.center_y) obj = Down_Stairs(x=x, y=y) obj.scale = 2 # obj.texture = m.texture obj.blocks = True tiled_map_obj_sprite.append(obj) return tiled_map_obj_sprite
def __init__(self, width, height): self.width = width self.height = height self.tiles = [[TILE.EMPTY for y in range(height)] for x in range(width)] self.actor_tiles = [[TILE.EMPTY for y in range(height)] for x in range(width)] self.item_tiles = [[TILE.EMPTY for y in range(height)] for x in range(width)] self.PLAYER_POINT = pixel_to_grid(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2)
def draw_select_mouse_location(self): """ マウス操作時のグリッド表示""" mouse_x, mouse_y = self.mouse_position grid_x, grid_y = pixel_to_grid(mouse_x, mouse_y) center_x, center_y = grid_to_pixel(grid_x, grid_y) arcade.draw_rectangle_outline(center_x=center_x, center_y=center_y, width=SPRITE_SIZE * SPRITE_SCALE, height=SPRITE_SIZE * SPRITE_SCALE, color=arcade.color.RAJAH, border_width=2)
def tiled_floor_set(self): tiled_floor_sprite = arcade.SpriteList(use_spatial_hash=True, spatial_hash_cell_size=32) floors = arcade.process_layer(self.my_map, "floor", scaling=2, use_spatial_hash=True, hit_box_algorithm="None") for f in floors: x, y = pixel_to_grid(f.center_x, f.center_y) floor = Floor(x=x, y=y) floor.scale = 2 floor.texture = f.texture floor.color = COLORS.get("dark_ground") tiled_floor_sprite.append(floor) return tiled_floor_sprite
def tiled_wall_set(self): tiled_wall_sprite = arcade.SpriteList(use_spatial_hash=True, spatial_hash_cell_size=32) walls = arcade.process_layer(self.my_map, "wall", scaling=2, use_spatial_hash=True, hit_box_algorithm="None") for w in walls: x, y = pixel_to_grid(w.center_x, w.center_y) wall = Wall(x=x, y=y) wall.scale = 2 wall.texture = w.texture wall.blocks = True wall.color = COLORS.get("dark_ground") tiled_wall_sprite.append(wall) return tiled_wall_sprite
def player_set(self, player): self.player = player self.player.x, self.player.y = pixel_to_grid(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2)