Driftwood2D / Driftwood

Driftwood 2D Tiling Game Engine and Development Suite
http://tileengine.org/
MIT License
24 stars 1 forks source link

entity._tile_cross() doesn't work on entities bigger than a tile #138

Open seisatsu opened 7 years ago

seisatsu commented 7 years ago

With pixel mode tile collision, do entities actually always collide with the center of the tile, or will a really wide or really tall entity collide in the wrong place? We have only tested with entities about the size of a tile.

A FIXME comment has been added to the function.

pmer commented 7 years ago

I made an entity that is 36 pixels tall and am seeing some odd behaviors:

pmer commented 7 years ago

Found an issue.

When an entity is being drawn, the (entity.x, entity.y) coordinate represents the top-left corner of the bottom tile where the entity is standing. This is how tall entities were originally envisioned. All entities would have a 1×1 tile base but their graphics could be taller and that would cause them to appear tall. (The specific code here is the code that revolves around the tall_amount variable in AreaManager.__build_frame.)

But inside entity._tile_cross() and friends, the (entity.x, entity.y) coordinate represents the top-left of the whole entity.

They disagree!

pmer commented 7 years ago

Let's separate the concepts of entity size and entity graphic size. All entities are 1×1 tile in size. We'll handle big and small entities in #91. For now, an entity's graphic, which can be of any size, is anchored to the bottom center of the entity and can extend up, left, and right from the entity.

This is an expansion of the tall entity concept. It keeps compatibility with the current player.png sprite.

seisatsu commented 7 years ago

I had already assumed the problem with tall entities. Let's go ahead and do what you just said.

pmer commented 7 years ago

I think #137 will fix this issue, too.