Collision Detections - DerekJi/ngtetris GitHub Wiki

As moving the running piece, all occupied blocks should not

  • be outside of the playfield
    1. NOT over the right wall:

      bX = pX + bx < W

    2. NOT over the left wall:

      bX = pX + bx >= 0

    3. NOT over the bottom:

      bY = pY + by < H

  • be overlapped by any existing occupied blocks in the playfield

    PlayField[bY][bX] < 1

image