BEsharkounet/Tetris-Godot-4

Bug with L piece

Closed this issue · 5 comments

Hello there,

I was planning to use your project as a starting base for a game I am making. While I decided to make a lot of the code from scratch, seeing your Godot implementation helped me structure my code better.

However, when playing yours, I noticed that when you rotate the orange L piece it goes into the wall for a short moment and then it gets pushed back into the level but in an awkward offset that takes it out of the grid.

Interestingly, when I was developing mine, I wasn't tracing your code line by line or anything, but somehow I have the same bug where the L piece is able to clip into the walls. The weirdest thing is that in both of our projects it doesn't happen with the blocks that are already placed.

In my case I'm using world boundaries, so I thought that might be it, but in your case you are using StaticBody2Ds for those too.

I am so puzzled by this that I needed to share it with you. Maybe we can come with an explanation as to why this happens? I sorted it out on my code with an ugly hack, but I'd like to understand what's going on.

Thanks for putting your code out there btw

Thanks fir replying, I really appreciate it.

If you can't recreate the bug, just note that I'm using 4.2 and if you still can't, then I can make a video and we can try to think about what's going on.

I am reaching the same conclusion in regards to the physics. Dunno why in most cases the collision checks are reliable, but some weird edge cases just don't detect a collision.

I am working on keeping track of collisions using a grid and then I stick to the Tetris Guideline when it comes to edge cases. I might end up hardcoding some behaviours but that's probably the right way to do it without relying on collision detection.

If you want to improve the code knock yourself out! I'd be interested on seeing it. However, I don't have an use for it anymore. I really appreciate your work already it helped me lots!

I really liked what you did with the 2 "fixed blocks" and the 2 "moving" ones. I took that from your design.

Thanks for replying!