From 27c10af4248bfd3150850006ecdbd6833c7c27c9 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sun, 14 Sep 2025 22:07:34 +0200 Subject: [PATCH] feat: add CheckShapeCollision() --- game/collision.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 game/collision.go diff --git a/game/collision.go b/game/collision.go new file mode 100644 index 0000000..5761563 --- /dev/null +++ b/game/collision.go @@ -0,0 +1,21 @@ +package game + +import "tetris/engine/core" + +func CheckShapeCollision(pos core.Vec2i8, shape *Shape, grid *Grid) bool { + for _, block := range shape.Coordinates() { + block = pos.Add(block) + + // Can't collide if block is above the grid. + if block.Y < 0 { + continue + } + + // Check if the block collides with the bottom of the grid. + if block.Y >= int8(grid.Height()) { + return true + } + } + + return false +}