Skip to content
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

Closed
seisatsu opened this issue Sep 29, 2017 · 7 comments
Closed

Comments

@seisatsu
Copy link
Member

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.

@seisatsu seisatsu added this to the Alpha-0.0.9 milestone Sep 29, 2017
@pmer
Copy link
Member

pmer commented Sep 29, 2017

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.

@pmer
Copy link
Member

pmer commented Sep 29, 2017

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()

@seisatsu
Copy link
Member Author

Try walking along the side of the building toward the roof in the testing world to see where the problem is a problem.

@pmer
Copy link
Member

pmer commented Sep 29, 2017

What's the relationship between this issue and #137?

My intuition says that fixing #137 would also fix the roof problem.

@pmer
Copy link
Member

pmer commented Sep 29, 2017

Do you think “pass through” tiles will provide a solution to the side/roof behavior?

@seisatsu
Copy link
Member Author

Ok, on second thought, pass-through tiles will not fix the roof behavior. You are right that fixing #137 will fix this issue, rather this kind of situation just won't happen anymore with smart pixel-based collisions. Best to just fix #137.

@pmer pmer added the duplicate label Sep 30, 2017
@pmer
Copy link
Member

pmer commented Sep 30, 2017

Closing this issue as a duplicate of #137.

@pmer pmer closed this as completed Sep 30, 2017
@pmer pmer removed this from the Alpha-0.0.9 milestone Sep 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants