-
Notifications
You must be signed in to change notification settings - Fork 1
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
Tiles on the same layer as an entity in pixel mode need special treatment. #162
Comments
This reminds me of Paper Mario style graphics. Wouldn't a game would just want to keep tiles and entities on separate layers? Although there is still the problem of entities overlapping each other which we might want to solve by sorting entities by Y-position before rendering. |
Here's some psuedocode for your idea of entities “passing through” tiles. # Iterate backward. Start with the bottom row & move our way up.
for z in range(len(self.layers)-1, -1):
# Get all entities on this layer.
entities = self.entities[z]
# Sort the entities by Y-position. FYI, sorted() returns a copy of the original list.
entities = sorted(by_y, entities)
for y in range(self.height):
# Draw a row of tiles.
for x in range(self.width):
draw_tile(x, y, z)
# Draw entities on this row.
while len(entities) > 0 and entities[0].y >= y:
entities[0].draw()
entities.shift()
# Pump remaining entities. They are all above the first tile row.
while len(entities) > 0:
entities[0].draw()
entities.shift() |
Try walking along the side of the building toward the roof in the testing world to see where the problem is a problem. |
Do you think “pass through” tiles will provide a solution to the side/roof behavior? |
Closing this issue as a duplicate of #137. |
If a bush is on the same layer as the player, and they stand in front of it, they render on top of it, as expected. However if they stand behind it, they still render on top of it! While this makes perfect sense programmatically, it makes no sense aesthetically. Some special treatment is needed.
Suggested solution: While an entity's xy position is overlapping any part of the lower half of a tile on the same layer, the entity draws on top. Otherwise, it draws underneath. Once an entity's y position is further north than the halfway point of the tile, it "passes through".
The only other clean way I can think of to fix this issue is to not allow entities to overlap nowalk tiles at all in pixel mode, and I think we already decided against that.
The text was updated successfully, but these errors were encountered: