public function availableHeightFrom($x, $y) { // get the column $col = $this->matrix->getCol($x); // make array start at correct y pos for ($i = 0; $i < $y; $i++) { array_shift($col); } foreach ($col as $k => $v) { if ($v > -1) { return $k; } } // entire height available return $this->ysize - $y; }