One of my favorite FOSS packages is Box2D (https://t.co/U6YASPel7V). By studying the API’s and the source code for Box2D you can learn an awful lot about how 2D games work and are programmed.