Welp... I'm starting over. This engine doesn't work quite well enough to my tastes, and it'll be easier to start over and do it right then to spend weeks troubleshooting bugs. So, I'm starting over and I'm going to follow the docs I've been working with a little more closely (check the credits for the Sonic Retro website, I've been borrowing ideas from there). I'll be leaving this up for learning/documentation purposes, but otherwise this engine is outdated and hopefully you'll see a new one soon. Welcome to the sonic engine! It's a from the ground up engine that I've been working on for a couple weeks now. It is still in active development though so definitely check back later if you are interested in seeing changes. Scroll down for controls and dev information. Controls are WASD to move, crouch, and look down or up, j to jump or spindash while crouching, and r to reset if you get stuck or fall off the stage. FOR DEVELOPERS, click see inside, I tried to comment this project as well as I could and so there are lots of explanations inside. You might also find additional info in the notes and credits. If you just want to edit levels though, just go to the collision and overlay sprites and you can draw collision and visuals in the vector editor. A couple helpful tips: If you are editing the code, I tried to leave lots of comments and point out variables that can be easily edited (jump height, acceleration, deceleration, etc.). If you think any sections need commenting please let me know. Collision is made up of dots and you can visually see where collision is taking place on screen, I put in a stamp block at certain points in the code so you can see the slope detection points, the player position point, and the wall sensor points. They are a little hard to see though because they are very tiny, only 2x2 pixels in size. Try resizing them if you need to see better, just don't make it too large (probably around 200 is best) because it will affect collision detection. In addition, please note that collision with the ground does not use a traditional hitbox, instead it tests single points for collision to check for slopes and so on. Use this website for information on how sonic physics work: https://info.sonicretro.org/Sonic_Physics_Guide I pulled a lot of information from here and it could be helpful in explaining some of what's going on. Finally, feel free to ask any questions or report issues found, although I can't guaruntee I'm able to fix anything because I'm still just a guy and might just not know the answer. It's worth asking anyways though, I'm always happy to help out. Known Bugs: - sonic sometimes gets stuck in a rolling state, not allowing him to jump and usually forcing the camera to look down. - very sharp corners don't work very well. I don't think I'm going to fix this either, that is just a limitation with the engine and the extra sharp corners usually aren't necessary in level design anyways. I might want to add squishing though. - Occasionally sonic will get stuck in the ground for some reason, and then teleport somewhere else on screen. Happens most often on straight, slanted surfaces (straight lines that are at a decently steep incline) - Sonic will occasionally not go up curves, instead stopping in his tracks. Usually happens with very small curves, since instead of thinking it is a curve, it will thinks its a corner because it is too tight. Probably won't be fixing this either, if this happens in one of your levels make the curve a little bit larger. - a couple of visual bugs with walls. Not sure how to fix these. - jumping into a corner sometimes gives the player a significant amount of speed, very rare though. Definitely want to focus on bugs that are either game breaking or could softlock, because those will be most frustrating for developers and players. Future additions: - does not yet have level overlays - no layer 1/2 switching (used for loops and intersecting pathways) - squishing - badniks - hazards, spikes, etc. - death for when you fall off the stage - peel out maybe? - extended idle animations (just need to draw them) - more level design would be nice. - backgrounds - zoom - level scale (one screen of level design would take up more space, but might look more blurry/pixelated because of scaling issues) Lots of stuff that I would still like to do. As usual, any help or suggestions would be greatly appreciated. Have fun!
Credits to Sega for Sonic the Hedgehog, and the genesis sprites and gameplay. Tons of credit to https://info.sonicretro.org/Sonic_Physics_Guide and the Sonic Retro site in general for a very in depth guide on sonics physics from the original genesis games, several ideas and values were pulled straight from there to get an engine that hopefully feels quite close to the original games. This engine won't be one to one and I changed a few variable to fit my own liking/purposes, so it won't be %100 accurate but it should at least feel accurate. The Sonic Retro website doesn't credit a single author but rather "Sonic Retro Contributors," so it was probably contributed to by several people. If you are interested in creating your own sonic engine, HIGHLY recommend this site, it walks through almost every single concept you would need to know in depth so it is very helpful. Also, feel free to ask around if you do want to make an engine, would be happy to provide any help I can. Credit to various programmers on scratch and youtube for some ideas and techniques that I have picked up over the years, including for verlet integration (unknown), slope detection (some inspiration from griffpatch, see https://scratch.mit.edu/projects/788908450/ However, I did not borrow any scripts directly from griffpatch.), and the atan2 function (Zro716, see here: https://scratch.mit.edu/discuss/topic/147922/ ) Sprites were hand drawn in the vector editor but are heavily based off of the sonic 1 sprites and lightly based on the sonic 3 sprites. Credit to Sega for those sprites Studied sprite rips from spriters resource contributed by Techokami (sonic 1 Genesis for GBA), Triangly, Paraemon (sonic 3), Orbyy, Wiztoad, Troopshi (customs based off sonic 1 beta style). Level collision was also hand drawn in the vector editor. Credit to @Gangstergrape and @tomicool for inspiration. You can see their projects here: https://scratch.mit.edu/projects/883773252/ https://scratch.mit.edu/projects/975526679/ https://scratch.mit.edu/projects/74711180/ Credit to the Sonic fangame community for inspiration as well And, of course, credit to scratch and the various other programmers/animators/designers/developers out there. Keep doing good stuff. This project turned out to be significantly more difficult to pull off than I expected. I already made a similar kind of engine in the project "2D engine 2" (plus an updated version that I haven't shared yet), so I thought "oh, well I can just change a couple of variables and maybe fix a few issues and it will be fine" It almost was not fine, but I guess it turned out alright in the end. Still working out a couple of rather frustrating bugs. The goal is to make an engine that is much more stable than the one that people currently use (the Genesis Engine made by @tomicool). It's from back in 2015 and while I don't want to discredit his work (it is really good, especially for back in the day), there are a number of bugs and I think Thanks for playing!