The third assignment required the class recreate an old Sega game using the MIT Scratch developer toolkit. Admittedly, I’ve never been a fan of Sega games so it was a difficult task to come up with a game to make. Ultimately though, I decided on building the original Sonic game. This was because I wanted to focus more on the character mechanics this round, instead of gameplay and level mechanics like I did with the Nintendo game.
Sonic is, at first a seemingly simple platformer game. It isn’t really until you look at the range of animations and character interactions included that you can begin to see how complicated the game is. A single sprite sheet for the main character includes over thirty sprites, compiled this become the animations for jumping, running, rolling, and walking. I decided I really wanted to replicate this, along with the signature fast paced running mechanic.
So with all the elements I needed decided on, I started constructing a scene, pulling elements from the game to build a basic level that includes the mechanics I need. This comprised of a sloped game world, and the classic “loop” block. While I intended to include the tunnels, time constraints proved difficult.
A staple of platformer games, is naturally the scrolling worlds. This was easy to achieve through a method called “Parallax Scrolling”, though the limitations of Scratch meant that I would have to get a little creative this time. Scratch doesn’t allow sprites to extend beyond the dimensions of the stage fully. If I wanted to have a long level, I would have to splice my world up into segments, and using code, move them independently of each other. Instead of moving the character along the “x” axis, I simply move the world around him. Then, I offset all the stages depending on their load order. For example, the first chunk would have no offset, the second would be offset by 400pixels (the length of the stage), the third twice the amount and so on.
A relatively unseen element of its age, are sloped environments. This proved to be an interesting challenge as I would have to allow for the player to move around hills and such without breaking the game. This was done, however not as well as I would like, via a simple collision detection system. If the player was touching the ground, push him up until he isn’t. If he isn’t touching the ground, push him down until he is. The allows the player to stay exactly in between the ground and “air”. However it causes a lot of jumping, which is something I couldn’t fix. The next biggest challenge was momentum. This was an exciting challenge for me to tackle, and required a lot of unexplored concepts. In the game, sonic can build up speed, allowing him to navigate the world. At the core of the mechanic, I have an acceleration variable, which builds up when the movement keys are pressed, but declines when they’re released. Then I have, in the animations function, trigger points for the different animations. When a certain speed is reached, an animation trigger is broadcast telling the sprites to update to one of the four implemented animations. Idle, Walking, Running, and Rolling. This allowed me to easily change the animations depending on user interactions with little demand.
This was the hardest part of the game demo, and sadly still requires a bit of polish. To recreate the games “loop”, I looked towards a few methods. I decided on using the mathematical model for orbiting. When the player hits a trigger point, it will create a centerpoint around the loop, which the player will orbit. When the system has detected that its done a full circuit, or the players acceleration has declined, it will reverse or terminate the orbit. This creates the loop effect. It took a lot of work to implement and sadly requires a lot more polish, but given the time constraints I was very happy with the outcome.
While I accomplished much of the original games mechanics in the conception build, I found I was severely limited by the Scratch Engine yet again. I was disappointed with what I couldn’t accomplish, but very happy with what I was able to do with the time constraints. The coding process was streamlined due to more experience with the product and I enjoyed myself immensely this time with the project. I originally intended for much more, such as tunnels, like I said earlier but it would be too complicated to create.