Deprecated: Creation of dynamic property wpdb::$categories is deprecated in /home/atzok/atzok.com/wp-includes/wp-db.php on line 760

Deprecated: Creation of dynamic property wpdb::$post2cat is deprecated in /home/atzok/atzok.com/wp-includes/wp-db.php on line 760

Deprecated: Creation of dynamic property wpdb::$link2cat is deprecated in /home/atzok/atzok.com/wp-includes/wp-db.php on line 760

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /home/atzok/atzok.com/wp-includes/comment-template.php on line 1745

Deprecated: Creation of dynamic property Yoast\WP\SEO\Main::$helpers is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/lib/abstract-main.php on line 65

Deprecated: Creation of dynamic property WP_Block_Type::$skip_inner_blocks is deprecated in /home/atzok/atzok.com/wp-includes/class-wp-block-type.php on line 357

Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/conditionals/third-party/elementor-edit-conditional.php on line 22

Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/conditionals/third-party/elementor-edit-conditional.php on line 28

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/atzok/atzok.com/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/atzok/atzok.com/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/atzok/atzok.com/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property Yoast\WP\SEO\Surfaces\Classes_Surface::$container is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/surfaces/classes-surface.php on line 20

Deprecated: Creation of dynamic property Yoast\WP\SEO\Main::$classes is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/lib/abstract-main.php on line 65

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$page_type is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 43

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$robots is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$title is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$source is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64
Isometric Coordinate Algorithms - ATZ OK
Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$meta_description is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$canonical is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$rel_prev is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$rel_next is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$open_graph_locale is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$open_graph_type is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$open_graph_title is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$open_graph_description is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$open_graph_url is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$wordpress_site_name is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$open_graph_site_name is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$company_name is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$site_represents is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$open_graph_publisher is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$open_graph_article_publisher is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$open_graph_article_author is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$open_graph_article_published_time is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$open_graph_article_modified_time is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$open_graph_enabled is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$open_graph_image_id is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$open_graph_image is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$open_graph_images is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$twitter_card is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$twitter_card is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$twitter_title is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$twitter_description is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$twitter_image is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$twitter_creator is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$twitter_site is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$estimated_reading_time_minutes is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$canonical is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$main_schema_id is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$site_url is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$schema_article_type is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$site_name is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$site_represents_reference is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$id is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$main_image_id is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$main_image_url is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$schema_page_type is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$title is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$has_image is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$description is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$breadcrumbs is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64

Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/generators/schema-generator.php on line 185

Deprecated: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$schema is deprecated in /home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php on line 64
Uncategorized

Isometric Coordinate Algorithms

Just thought I’d share the final functions I settled on for isometric coordinate calculations. Unlike most of the others I’ve seen around the web, these account for:
* Origin offset
* Tile-based position offset
* Varied scale
* Any aspect ratio (not just 2:1)

    def GetScreenPositionForTile(self, map_pos, view, origin, offset, delta=None):
        if self.projection == Layer.Projections.BirdsEye:
            screen_x = origin[0] + map_pos[0] * self.tile_width
            screen_y = origin[1] + map_pos[1] * self.tile_height
            
            if delta is not None:
                screen_x += delta[0]
                screen_y += delta[1]
        elif self.projection == Layer.Projections.Isometric:
            map_pos = (map_pos[0] - offset[0] / self.scale, map_pos[1] - offset[1] / self.scale)
            screen_x = origin[0] - (map_pos[1] * self.tile_width / 2) + (map_pos[0] * self.tile_width / 2) - (self.tile_width / 2)
            screen_y = origin[1] + (map_pos[1] * self.tile_height / 2) + (map_pos[0] * self.tile_height / 2)
            
            if delta is not None:
                iso_delta_x = (delta[0] - delta[1]) / 2 * self.tile_aspect
                iso_delta_y = (delta[1] / 2) + (delta[0] / 2)
                
                screen_x += iso_delta_x
                screen_y += iso_delta_y
        
        return screen_x, screen_y

 

    def GetTileAtScreenPosition(self, screen_pos, view, offset):
        origin_x, origin_y = self.GetOrigin(view)
        map_x_screen = screen_pos[0] - origin_x
        map_y_screen = screen_pos[1] - origin_y
        
        if self.projection == Layer.Projections.BirdsEye:
            map_x = map_x_screen / self.tile_width
            map_y = map_y_screen / self.tile_height
            map_delta_x = map_x_screen % self.tile_width
            map_delta_y = map_y_screen % self.tile_height
        elif self.projection == Layer.Projections.Isometric:
            map_x_raw = map_y_screen + int(map_x_screen / self.tile_aspect)
            map_y_raw = map_y_screen - int(map_x_screen / self.tile_aspect)
            
            map_x = map_x_raw / self.tile_height
            map_y = map_y_raw / self.tile_height
            
            map_delta_x = map_x_raw % self.tile_height
            map_delta_y = map_y_raw % self.tile_height
            
            map_x += offset[0] / self.scale
            map_y += offset[1] / self.scale
        
        return map_x, map_y, map_delta_x, map_delta_y

I could comment the code better of course, but I think it’s actually pretty straightforward and self-explanatory.

Full code: http://ohshitzombies.com/PallidumZ/trunk/game/board/Layers.py


Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/atzok/atzok.com/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/atzok/atzok.com/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/atzok/atzok.com/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/atzok/atzok.com/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/atzok/atzok.com/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/atzok/atzok.com/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home/atzok/atzok.com/wp-includes/class-wp-term.php on line 198