PaulB-H / breakout

Breakout made with Phaser
https://paulbh.com/breakout
3 stars 0 forks source link

Wall Parsing and Tile Placements "Off-Grid" #9

Closed PaulB-H closed 7 months ago

PaulB-H commented 11 months ago

These are actually made with a bunch of circles, since arcade physics doesn't support slopes.

It only worked out so-so, and can still cause very unexpected rebounds.

This issue might have been caused by my attempts to make a double width wall since 1px walls seems to let balls through occasionally

image

PaulB-H commented 11 months ago

Almost fixed...

image

PaulB-H commented 11 months ago

Because there are no angled walls in phaser arcade by default (I think there is a plugin though) I created angled walls by using a line of ellipses. This is mostly working, however does not always cause a bounce back in the expected direction, and I still have issues with balls ghosting through them occasionally.

image

The cause of this issue has been related to how I actually draw each item in the collision group, not using the correct dimensions, getting the tile object / collision object confused.

PaulB-H commented 11 months ago

Fixed with 25be1ba76cc49121effe452311461604aa2232d1

Walls are now a pixel-perfect match with Tiled

image

PaulB-H commented 11 months ago

Seemed fixed, but only when placements line up nicely with the 16x16 grid in phaser, when they dont, things had weird gaps

PaulB-H commented 11 months ago

I got the position of custom collision objects fixed, and then noticed blocks were not placed quite correctly..

Without light2d pipeline: image

With light2d plugin: image

We can see the red overflow is where the square SHOULD be, and where it thinks it is...

But after enabling the ligh2d plugin I have not been able to stop them from shifting right and down 1 px...

PaulB-H commented 11 months ago

As long as the tile is within its normal 16x16grid position, it doesn't get messed up...

If I try and move it 1px out of that, the bug happens as we can see with the right side in the example below

image

PaulB-H commented 11 months ago

Another discovery...

This is only happening to 16x16 blocks when they are placed at an odd offset from the grid in tiled...

Here we have no offset, our 16x16 tile lines up with the 16x16 grid in tiled, and it renders fine in game: image

In game we see no overflow of the debug object anywhere, we know the tile is placed correctly:

image

Now, if we move everything ONE pixel up and ONE right: image

We can see in game overflow from the debug object, our tile placement is not correct: image

But now, if we move it one more pixel up and right, so its 2 px off grid: image

It renders in game without any overflow again: image

We can see this repeat at 4, 8, px off center all rendering fine, with odd numbers creating incorrect placement.

BUT when we turn off the Light2D pipeline, we can place tiles off grid and they render just fine: image

PaulB-H commented 7 months ago

Opened an issue in phaser related to this.

https://github.com/phaserjs/phaser/issues/6698

Closing as I don't need to fix it for this project.