-
Notifications
You must be signed in to change notification settings - Fork 343
Scene Manager and Tilemap Rework #891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tilemap Module
This contains a re-worked tilemap module.
It has been moved into a package rather than being a single module. It still only consists of one module, but it's been moved into a package to make it easier to break apart or add modules to later on.
The tilemap module has been re-worked to be object oriented as opposed to before where it was completely static.
Previously, a map was loaded in using the
read_map
function and then you would load in each layer as SpriteLists individually using that map object.With the re-worked module, there is a new
TileMap
class, and aload_tilemap
function which returns that class to load in a map.Now when you pass in the map, all layers are automatically loaded in, including both Tile layers and Object layers. Objects are loaded in as a new type found in
arcade_types.py
calledTiledObject
. This contains the name of the object, it's properties, and a "shape" which uses Arcades existing types for Points, PointLists, and Rect.All of the layers are then stored in OrderedDicts. One for the SpriteLists from tile layers, and one for the TiledObjects from the object layers. The keys for these dicts are their names, and they are ordered according to their order in the Tiled map.
The platformer tutorial has been updated to work with the new module, but all other Tiled documentation still needs updated.
One challenge this presented was how to deal with per layer options, like for instance using spatial hash to load one layer and not for another. Since they are all being loaded automatically, it means users can no longer specify these things on a per layer basis when loading them in.
To solve this, you can now pass a
layer_options
dictionary to either the__init__
of the TileMap class or theload_tilemap
function. This dictionary can be used to pass those options based on the layer name, see below for an example:Any of the options that could previously be used, can be passed through this dictionary. Right now that consists of
use_spatial_hash
,scaling
,hit_box_algorithm
, andhit_box_detail
.Scene Manager
The new scene manager module contains a
Scene
class which essentially stores SpriteLists and provides functions to update/draw them.The Scene class maintains a list and a dictionary. They both contain the same SpriteLists, the list is what is used to draw from, to maintain the draw order of SpriteLists. The dictionary is used by most of the helper functions to provide users with a way to name their SpriteLists and work on them easily without having to maintain what index they're in.
It also provides a classmethod helper function to create a Scene from a TileMap object. This will take in all of the SpriteLists from a TileMap and put them in the proper draw order and name them according to the Tiled layer name.
The platformer tutorial has been updated to use the Scene class, but other documentation and examples specific to the scene class still needs created.
The Scene is entirely optional, you can still maintain and draw SpriteLists manually as has been done previously, but this provides a very streamlined process for handling a larger number of SpriteLists, and the integration with the TileMap makes loading in and drawing a Tilemap extremely trivial.