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: 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 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

Warning: Cannot modify header information - headers already sent by (output started at /home/atzok/atzok.com/wp-includes/wp-db.php:760) in /home/atzok/atzok.com/wp-includes/feed-rss2.php on line 8
<br /> <b>Deprecated</b>: Creation of dynamic property Yoast\WP\SEO\Surfaces\Classes_Surface::$container is deprecated in <b>/home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/surfaces/classes-surface.php</b> on line <b>20</b><br /> <br /> <b>Deprecated</b>: Creation of dynamic property Yoast\WP\SEO\Main::$classes is deprecated in <b>/home/atzok/atzok.com/wp-content/plugins/wordpress-seo/lib/abstract-main.php</b> on line <b>65</b><br /> <br /> <b>Deprecated</b>: Creation of dynamic property Yoast\WP\SEO\Context\Meta_Tags_Context::$page_type is deprecated in <b>/home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php</b> on line <b>43</b><br /> <br /> <b>Deprecated</b>: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Term_Archive_Presentation::$pagination is deprecated in <b>/home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/archive-adjacent-trait.php</b> on line <b>29</b><br /> <br /> <b>Deprecated</b>: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Term_Archive_Presentation::$source is deprecated in <b>/home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php</b> on line <b>64</b><br /> <br /> <b>Deprecated</b>: Creation of dynamic property Yoast\WP\SEO\Presentations\Indexable_Term_Archive_Presentation::$title is deprecated in <b>/home/atzok/atzok.com/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php</b> on line <b>64</b><br /> Algorithms Archives - ATZ OK https://www.atzok.com NO CARRIER Thu, 14 Apr 2016 22:21:31 +0000 en-US hourly 1 https://wordpress.org/?v=5.9.9 Isometric Coordinate Algorithms https://www.atzok.com/2009/07/17/isometric-coordinate-algorithms/?utm_source=rss&utm_medium=rss&utm_campaign=isometric-coordinate-algorithms Fri, 17 Jul 2009 14:19:41 +0000 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:…

The post Isometric Coordinate Algorithms appeared first on ATZ OK.

]]>
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

The post Isometric Coordinate Algorithms appeared first on ATZ OK.

]]>
Pathfinding algorithms in Demon Keeper https://www.atzok.com/2009/06/30/pathfinding-algorithms-in-demon-keeper/?utm_source=rss&utm_medium=rss&utm_campaign=pathfinding-algorithms-in-demon-keeper Tue, 30 Jun 2009 10:49:41 +0000 While ZedZed required only simple directional pathfinding (zombies are stupid, so advanced pathfinding is not needed), Demon Keeper required some more advanced techniques to facilitate targeting. I found a great A* tutorial, and some great additional information, which helped me get started, but it wasn’t quite what I needed. The first thing I did was…

The post Pathfinding algorithms in Demon Keeper appeared first on ATZ OK.

]]>
While ZedZed required only simple directional pathfinding (zombies are stupid, so advanced pathfinding is not needed), Demon Keeper required some more advanced techniques to facilitate targeting.

I found a great A* tutorial, and some great additional information, which helped me get started, but it wasn’t quite what I needed. The first thing I did was to split out the core logic into a function, and create two functions to access it for either a targeted A* route finder, or a Dijkstra search of multiple potential targets. The latter ended up being more heavily used for actions like finding the closest nearby hostile to attack, whereas the A* function is then used to maintain a route once the target is acquired.

What still remains insufficient however, is a node’s binary state of being either a pass or block in pathing. This created two problems: actors immediately in the way of the moving sprite would block its progress flat, and targetable features with no pathing data would return as unreachable. The ultimate solution to this was to pass in three separate path arrays: the board, the features, and the actors.

These three boards may then be analyzed in different ways, depending on where in the path you are. The actor board may be ignored entirely in all but the first move (since that’s the only one in which you can count on it being a factor), or weighted in a node’s F-value, based on distance (i.e. an actor blocking a node will have less value the further it is away from origin). The feature board will be used for the path along the way, but ignored at the final destination point, allowing for blocking features to be targeted, but still routed around along the way.

The post Pathfinding algorithms in Demon Keeper appeared first on ATZ OK.

]]>