Mega Drive SGDK Megapong

In this tutorial series you will learn how to make a simple single-player Pong-like game for the Sega Mega Drive using SGDK! If you just want to see the full source code, you can get it from Github.

These tutorials are powered by Patreon!

Become a Patron!

Megapong BONUS - Flashing!


Alright, we have a complete and working game now. We have graphics, gameplay, scores, game overs…sound is still missing, true, but that’s a topic for another tutorial. However, we can still add something to make our game a bit better: The almighty Juice.

In order to juice things up as it were, we’re going to make the ball flash when it’s hit by the paddle. It’s a small effect, but an important one when it comes to retrogaming. Hitting Robotnik wouldn’t be as satisfying if he didn’t flash, after all. So let’s do this!

images/flashing.gif

This content is a Thank You for my patrons on Patreon. Please enter the password you received to view it.

360J+FCI6obVm2rqDDE99XAqghd4bw3kVQuKt6qxmgqzZNMuV3weyifQ2szeJiO5IdlxwEVWVJ5JjelfU3ZjEtTlwFGv2+MVVgN9VUGVPMoqdy+vGaixboIXXz6rSXQqqFtDocSbp33UCiWyrGEdMIV1pXZIwP5K4WmmF6ByL6Wm9Ss1TcpE32eVomMzRVQusbp2/IFZmznRyylkn5eKXjyk5sJgitiAREuUGfzxKjueY2bs5/sp02aoMQpJVJc9nq5LZ6xL9cHyXdmMjOmJ4hmbbSrdGmKqXXSM3cNkJuUh2OSpuc3561rI3pm4FnfR7+jq3AiqZzZr+JdG3RYxhcBZH4DXUrK8/wZPXKT+ZuMeMpbnnagbPjXjsx0OIHUa5dezR/xr+1svMM+2ATyQD1vR/EyIA0rjzDkt5YfaNazLXwZ/KKcvz492jVZLefN9Yf/7Kunom9bPgxgxAuoPnUX1SYOBNpe1HWGSlKtgYU1ao4bO6JSkiI4FIPglw1qOYPuy0gPr/p5tVWk7qaJZJ/HHdUUIOtPaHJMiUTH+3TKxakADaMayYJgx4oTatiIy6P4IOT41QT3RmxRU0Ac5Puar4q4gHeERRus0W1oi/PE9dyFeiFM99yGt9lVHahkFYAccc3n0oZTjaXmXMUKLwQki6fIdAF/VgUwKoRztHtSUtcjltOu1lBjV+bzbLmpVDvA5oAU4hfR17j+UvFSghK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zNACoWGJ5OpWzO9/TDwLuznEgKEDlsccNuaLnTkG6nLzwMcziJd7oTAi/adMMLnT1YNTkawPV3jj/mpdjMtjlJg4L4bzG/f7UySIVfSP8558blIUDooiEWe//NVDvYi3b9gGEPHtuend1tVWGZ6UvR9mmS4woPkcYwg82BG+fPfYX5Qg4LH9KjaoJU+Njc6HaDat02607sgDsmmGVV4YBMxOt0I0lTEufdXJgppsn1ZYKL4+8HVUdVqaH8kF4fzcbQxOUlnsIwuCg3RLjH2yA6HdmlmB16GGvtqZmEmuytOuocbJjzECqIQPYHOMFrBzMT1Xi+9g6zD/FyhBJ6COQjt8O76Vj97AOAiz4HMkMOm3c0tgYCPuIn2/1ehO0mQOaPWCLl3fEODr1KYjBZZ56mMnGpupRD5bahJR2FSgwHNu8RMAE3xrpUubtSLcRp16LLw0r1ZtR4N4MgX38+SKaskMUKS1O3iKTN/ctVbPym790D3w9O/mNRZu/BpSxAX8qJX7PRgdbBA==

If you have any questions, comments or criticism, post them in the comments below or reach out to me on Twitter @ohsat_games! Special thanks to Stephane Dallongeville for creating SGDK and everyone in the SGDK Discord for their help and keeping the dream alive!

Take It to the Next Level!

Want to boost your Mega Drive coding skills? Get exclusive bonus steps and project files for each tutorial by supporting me on Patreon!

Become a Patron!
Just Want to Buy Me a Coffee?

Check out the rest of this tutorial series!

  • Megapong 1 - Hello Mega Drive World!
  • Megapong 2 - Setting Up The Environment
  • Megapong 3 - Importing Resources
  • Megapong 4 - Palettes
  • Megapong 5 - Sprites
  • Megapong 6 - Input and Paddles
  • Megapong 7 - Collisions
  • Megapong 8 - Score and HUD
  • Megapong 9 - Game Over
  • Megapong BONUS - Flashing!
  • Get Words in Your Inbox!

    Be oldschool and sign up for my newsletter to occasionally get updates and ramblings! Just enter your email address, prove you're not part of Skynet and you're good to go!



    I will not send you spam or sell/give your email address to someone else.  You can of course unsubscribe at any time. By clicking the subscribe button above, you confirm that you have read and agreed to our privacy policy.

    By using the Disqus service you confirm that you have read and agreed to the privacy policy.

    comments powered by Disqus

    New SGDK Tutorial: Megarunner!

    November 4, 2019
    Mega Drive Ramblings

    Tutorials and Patreon!

    September 2, 2019
    Mega Drive Ramblings

    Adventures in Mega Drive Coding Part 7: Handling Input

    December 19, 2018
    Mega Drive C