Tag: Mega Drive
This is a list of all posts, games and tutorials tagged with the tag "Mega Drive".
Color Swapping
Having to use palettes is one of those things that seem like a restriction at first, but… well okay, it is a restriction. But palettes can also be a powerful tool if you know how to use them right. One very simple but effective thing you can do is color swapping. How does it work? The Mega Drive uses a palette of 64 colors that is shared among all visual assets in a game.
How to Quickly Generate C Prototype Functions in VSCode
One of the cool things that VSCode offers is the support for extensions. And there are a ton of them. There’s pretty much one for every occasion, and if there isn’t, there probably will be soon. And since we use C, an absolute classic of a programming language, there are also some that can help us out with Mega Drive coding!
Megarunner BONUS - Tile Scrolling
Know what makes any game better? Parallax scrolling! I know that might sound like an overstatement, because it is. But parallax scrolling is really cool, so let’s add a small parallax effect to our game!
Megarunner 6 - Collision and Score
We have obstacles and the player can jump over them, but it doesn’t really matter…you don’t get rewarded when you do and you don’t get punished when you don’t. So let’s add a scoring system and collision to the obstacles so that there’s actual motivation to do things! Collision First we’ll take care of the collision detection. Go down into your main game loop and add the following if-statement after the code that moves the obstacle across the screen:
Megarunner 5 - Jumping Math
Now that we have obstacles, we need to enable the player to jump over them. However, in order to do that we need to use math. Don’t panic, SGDK makes it quite simple. Let’s go! Fixed Point Math To make the player jump we’ll have to change his vertical velocity to move him upwards, then apply gravity to pull him back down so that we get a jumping arc. We could do this using variables of type int, but this would lead to very hectic and jerky movement, because there’s just not much precision.
Megarunner 4 - Player and Obstacles
Update: Fixed a small error when importing the rock graphic. Thanks to Thiago for pointing it out!
Alright, we got the background moving, now we need a player sprite to complete the illusion. Of course we could create very long levels and have the player actually run through them, but it is way more efficient to fake endless running by just scrolling the background past the player.
Megarunner 3 - Scrolling
Welcome back! Last time we drew a background with a floor and even some street lights. This time we’ll get things moving by scrolling the background to create the illusion of endless running! Preparations As usual, we have to do a bit of preparation work. First off we’ll define a new constant at the top of the file that will store the speed at which our background will scroll. const int scrollspeed = 2; Next up we’ll set our desired scrolling mode.
Megarunner 2 - Tiles
Welcome back! Now that we have a framework, we can start building the game proper. Let’s start by importing some graphics and displaying tiles on the screen, so that our game stops looking like a text adventure. We’ll be using some graphics from the Game Creator’s Pack by Jonathan. You won’t have to download it, I’ll provide all the files you’ll need here, especially since I’ve edited some of them.
Megarunner 1 - The Framework
Welcome to a new tutorial series on Mega Drive development! Here we’ll be creating a Mega Drive game from scratch using SGDK, the Sega Genesis Development Kit. And this is what we’ll be working on: I call it Megarunner. It’s an endless runner-type game where you jump over obstacles to gain points. The game ends when you hit one of the obstacles. It’s a simple concept and thus a good way to learn about some new concepts of Mega Drive programming like scrolling and animation!
New SGDK Tutorial: Megarunner!
By now you’ve probably noticed that I’ve written a tutorial on how to create a single-player Pong game for the Mega Drive/Genesis. Well, now I’m writing another one! This time I’ll guide you through creating an endless runner where you’ll gain points by jumping over obstacles: This series will introduce new concepts such as scrolling and sprite animation, so if you want to improve your Mega Drive coding skills, head on over to the tutorials section and check it out!
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!
Megapong 9 - Game Over
Time to finish this game of ours! This time we’ll add a fail state and some general polish to complete the Megapong experience. Let’s jump right into it! Making Things Easier for Us First, let’s make things a bit easier for ourselves. We’ll have to show some messages on screen soon and we can create the following helper function to help us out: /*Draws text in the center of the screen*/ void showText(char s[]){ VDP_drawText(s, 20 - strlen(s)/2 ,15); } Put it near the top of the file, so that all functions can access it.
Megapong 8 - Score and HUD
It’s the final stretch! We already have the core gameplay, but right now our game is less a game and more of an activity center. We should add a score to make it a bit more challenging and exciting. Let’s do it! Score and HUD First we’re going to define the variables that we’ll need. At the beginning of the file, next to all our other variables, add this: /*Score variables*/ int score = 0; char label_score[6] = "SCORE\0"; char str_score[4] = "0"; int score will store our current score value.
Megapong 7 - Collisions
It’s physics time! We got two moving parts, now it’s time to smash them together. SGDK has built-in collision stuff, but we won’t need that for this simple project. The method we’re using to handle collisions is called AABB collision detection. It uses axis-aligned bounding boxes, which sounds really fancy, doesn’t it? Basically that just means we’ll be using rectangles to check for collisions, instead of the actual sprite graphics. It’s a very simple and efficient method of handling collisions.
Megapong 6 - Input and Paddles
We have a moving ball now, but a Pong game needs paddles. We’ll add one now and learn about handling input in SGDK at the same time. Let’s go! Creating a Paddle First we’ll have to create a paddle for players to control. The process is very similar to the one in the previous post, so I won’t go into as much detail this time. First, download the paddle image here.
Megapong 5 - Sprites
Now that we have a background, it’s time to get things moving! Sprites are different from tiles, so we have a few new things to learn. Let’s get into it and make a bouncing ball! Importing Sprites First of all we’ll need a sprite for our ball. You can download it here. Here’s what it looks like (scaled up 4x so you can see it better): Note that you have to download the file from the link above, right-clicking and saving the above image will not work!
Megapong 4 - Palettes
Last time we put a tile on screen, which was awesome. But the color was wrong, which wasn’t so awesome. Also, one tile doesn’t really make a background, does it? So we’ll take care of all that this time around. Let’s get started! About Palettes Okay, so why was our tile white instead of the color it should’ve been? Simply put: We didn’t tell SGDK what colors we actually wanted, so it went with the defaults.
Megapong 3 - Importing Resources
Welcome back! Last time we set up our development environment to make things easier for us. This time things will get a bit more exciting, as we’ll import a graphic and use it to draw the background for our game! We have a lot ahead of us, so let’s rock. You can either use the project from part 2 or create a new one. This one will become our game, so remember where you put it…
Tutorials and Patreon!
Want some big news? Here are some big news! I have added a brand-new tutorials section to this site…and to kick it off I’ve posted the first three installments of a new Mega Drive SGDK tutorial! In it you’ll learn how to create a Pong-like game for the Mega Drive from the ground up using SGDK. A new post will go up every week, so make sure to check back regularly!
Megapong 2 - Setting Up The Environment
Welcome back! Last time we set up SGDK and made sure everything worked. This time we’ll set up a proper development environment, which will make things a lot easier and more fun for us. Believe me, it’ll be worth it! Development Environments Code for SGDK is written in C, so you can use basically any IDE that supports C. Some popular choices are Code::Blocks or Eclipse. However, the one I use and the one I would definitely recommend is Visual Studio Code.