Tag: Mega Drive

This is a list of all posts, games and tutorials tagged with the tag "Mega Drive".

Megarunner BONUS - Tile Scrolling

| #Mega Drive #SGDK #Megarunner

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

| #Mega Drive #SGDK #Megarunner

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

| #Mega Drive #SGDK #Megarunner

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. So we’ll just use floats, right? That way we can get smoother movement.

Megarunner 4 - Player and Obstacles

| #Mega Drive #SGDK #Megarunner

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

| #Mega Drive #SGDK #Megarunner

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. In main(), add this line after VDP_setPlanSize(32,32);:

Megarunner 2 - Tiles

| #Mega Drive #SGDK #Megarunner

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.

But first, let’s change the background color! Our game will take place during the day, so let’s make the background a nice sky blue. Of course you could create a solid blue tile and populate the background with it, but that would be a waste of data. There is a far easier option! Call the following function at the beginning of main(), after setting our joypad callback:

Megarunner 1 - The Framework

| #Mega Drive #SGDK #Megarunner

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:

images/megarunner.gif

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!

| #Mega Drive #Ramblings

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:

megarunner.gif

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!

| #Mega Drive #SGDK #Megapong

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

Megapong 9 - Game Over

| #Mega Drive #SGDK #Megapong

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. As you can see, this function takes a string (that is, a char[]) and then draws this string in the center of the screen using VDP_drawText and the power of math. This spares us from always having to specify the x- and y-positions of the text we want to draw.

Megapong 8 - Score and HUD

| #Mega Drive #SGDK #Megapong

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. char label_score[6] will be the label of our score HUD element. char str_score[4] will store our current score value as a string.

Megapong 7 - Collisions

| #Mega Drive #SGDK #Megapong

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

| #Mega Drive #SGDK #Megapong

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. This is what it looks like (at 2x scale):

Megapong 5 - Sprites

| #Mega Drive #SGDK #Megapong

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):

images/ballpreview.png

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

| #Mega Drive #SGDK #Megapong

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. This might sound weird to you if you’ve done any gamedev on modern systems recently, because there, just loading an image is enough; the engine will display it as is. However, older consoles like the Mega Drive were a lot more restricted in memory and general technical capability, so they used palettes to handle colors. The Mega Drive can handle 4 palettes with 16 colors each, of which a total of 61 can be displayed at once. That might not sound like a lot, but you can do a lot of amazing things with that!

Megapong 3 - Importing Resources

| #Mega Drive #SGDK #Megapong

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!

| #Mega Drive #Ramblings

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

| #Mega Drive #SGDK #Megapong

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. It’s free, open source, cross-platform, extremely customizable and offers extensions that make SGDK coding easier! All explanations and steps given here will be for VSCode, so if you want to follow along I’d definitely recommend downloading it. However, if you’re already familiar with another C environment, feel free to stick with it. You shouldn’t have much trouble getting SGDK to comfortably work in it if you know what you’re doing. Now, let’s get cracking!

Megapong 1 - Hello Mega Drive World!

| #Mega Drive #SGDK #Megapong

Welcome to my new tutorial series on Mega Drive development! In it we will be creating a Mega Drive game from scratch using SGDK, the Sega Genesis Development Kit. This awesome piece of software allows you to program games for the Mega Drive in C instead of ASM, which makes things a whole lot easier. I will show you how to set up your development environment, how to import graphics, how to put things on the screen, how to control them and have them collide…

Creating Graphics for the Mega Drive

| #Mega Drive #SGDK #Misc

When it comes to making graphics for the Mega Drive, there are a number of programs available that you can use. It doesn’t really matter if you’re using software specifically designed for retro pixel art or more modern graphics suites like Photoshop or GIMP, as long as your program supports the use of palettes. However, even when your software is capable of creating images that SGDK can process, there are still a number of restrictions you have to keep in mind when designing and drawing your sprites and tiles. I thought I’d give you a quick rundown on what you need to keep in mind to create your own graphics for your Mega Drive game.