Formatted and added a checking for triangles in the game loop