import arcade SCREEN_WIDTH = 1920 SCREEN_HEIGHT = 1280 SCREEN_FULL = True TILE_WIDTH = 64 TILE_HEIGHT = 32 def to_iso(tile_list): for tile in tile_list: col = tile.center_x//TILE_WIDTH row = tile.center_y//TILE_HEIGHT tile.center_x = tile.center_x - TILE_WIDTH//2 * (col-row) tile.center_y = tile.center_y - TILE_HEIGHT//2 * (row+col) return tile_list class MainView(arcade.View): def __init__(self): super().__init__() self.background_color = (100,100,200) self.tilemap = arcade.load_tilemap('./assets/level1.tmx',scaling=1) self.flor = self.tilemap.sprite_lists["flor"] self.flor = to_iso(self.flor) self.walls = self.tilemap.sprite_lists["walls"] self.walls = to_iso(self.walls) self.camera = arcade.Camera2D() def on_draw(self): self.clear() self.camera.use() self.flor.draw() self.walls.draw() def on_update(self,delta_time): self.camera.position = 800,0 def on_mouse_press(self,x,y,but,mod): world_point = self.camera.unproject((x,y)) tile_col = world_point.x//TILE_WIDTH tile_row = world_point.y//TILE_HEIGHT sheet = arcade.load_spritesheet('./assets/tiles/64x64.png') textures = sheet.get_texture_grid((64,64),16,184) self.walls.append( arcade.Sprite( textures[165], center_x=tile_col*TILE_WIDTH + TILE_WIDTH//2, center_y=tile_row*TILE_HEIGHT+TILE_HEIGHT ) ) if __name__ == '__main__': window = arcade.Window( SCREEN_WIDTH, SCREEN_HEIGHT, 'Isometric game', fullscreen=SCREEN_FULL) view = MainView() window.show_view(view) arcade.run()