Followings are some algorithms and specifications found in a U.S. patent regarding certain Sonic game(s). Hopefully it'll give us insights into how the Sonic game engine works. Note that it may very well be illegal to use the exact same algorithms in your fan-made game!
The following is provided as an educational reference only. DO NOT REGARD ANYTHING ON THIS PAGE AS THE OFFICIAL, LEGAL DOCUMENTATION FOR THE GAMES. IT'S YOUR RESPONSIBILITY TO CONTACT THE APPROPRIATE DEPARTMENT(S) FOR OFFICIAL, COMPLETE, AND UP-TO-DATE INFORMATION.