-1

I'm making tetris game using javascript and html, my board is made up of a grid of divs.

When I rotate my tetris piece, I can rotate it into other pieces, additionally I can rotate them off the grid and onto the other side.

Please help me fix this error

1 Answers1

-1

Ah I had the same issue. The way I solved this issue is that whenever user presses a button, let's say the rotate button, but the same logic applies for any sort of movement, it will first check that when it rotates/moves will it hit any of the edges or any other block. If so, it won't rotate/move.

It's hard to give more specific advice without seeing your code.

I've attached the repo to my one if that helps.

https://github.com/Salaah01/tetris

Mine is build using react, the specific modules that may be useful are below: https://github.com/Salaah01/tetris/blob/master/src/components/Blocks/BaseShape.js https://github.com/Salaah01/tetris/blob/master/src/components/Blocks/Shapes/JShape.js

Salaah Amin
  • 382
  • 3
  • 14