Jump to content
Sign in to follow this  
  • entries
    686
  • comments
    1952
  • views
    387723

Create your own level! Yay!

Sign in to follow this  
Stompy9999

68 views

If you don't play this demo, the tourists win.

I happened to read the interview with the creators of Professor Fizzwizzle. Professor Fizzwizzle is one of my favorite games that I've seen here, so I was really glad to see that it is an IGF finalist. It's very inspirational seeing that 2D games still have a good place, seeing as that's really all I want to create.

It seems also that they just used plain SDL, without OpenGL. This was also very good to hear, because personally I'm not really interested in using OpenGL since I'm just going to be creating 2D games. They did use pre-rendered 3D models to create the graphics, though, which is something that seems to be more common in 2D games nowadays.

Ok, I said I would write a tutorial on creating your own level, so here it is:

----------------------------------------------------------------

Creating your own Stompy level

One interesting thing about Stompy's Revenge is the cability to create each level with it's own look. In theory, anybody can create a level for the game with enough patience, but it's hard to understand how the levels work just by looking at the files. So, that's why I'm writing this tutorial.

However, keep in mind that I never had the intention for anyone but me to be creating levels for this game. Therefore, you'll probably notice that the method for creating levels is pretty convoluted.

For the sake of this tutorial, I will call the level "tutorial".

Step 1: Create the background

Open up paint, or whatever image editor you use. Set up a new image with a size of 640x480 pixels. After that, simply draw what you want the background of the level to look like. Keep in mind when you are drawing it that your background will be repeated constantly throughout the level. So try to make it look natural.

When you're done, save the image to the folder gfx/bgs, and name it "tutorial.png".

Step 2: Create the tile graphics

Each level can have a maximum of 9 different types of tiles. The image files for the tiles are called 0.png, 1.png, etc, corresponding to what tile they represent. For the sake of this tutorial, we'll make two types of tiles.

First, go into the folder gfx/tiles. In there, create a new folder called "tutorial".

Second, open up your image editor and set up a new image with a size of 32x32 pixels. Fill the image with the color pink (r=255, g=0, b=255). Pink is the transparent color in this game, so this will just create a blank tile. Save this image in the folder you created as "0.png".

Third, set up a new image with the same size. In this image, draw what you want a basic tile to look like (examples include grass, dirt, etc). When you're done, save this image in the same folder, but call it "1.png".

If you've done this correctly, you should have a folder gfx/tiles/tutorial, and inside it two files, "0.png" and "1.png".

Step 3: Edit the tile data

First, download this little program. It's a program I created to generate a generic level. When you run it, it will simply create a file named "map.txt", which is basically just a generic level that's empty except for a floor. Rename the file to "tutorial.txt", and move it to the folder called "Levels".

If you open up "tutorial.txt", you should see a collection of numbers, 0s and 1s in this case. These numbers correspond to the images that you drew in Step 2. A 0 is blank tile, while a 1 is the tile that you drew. You can simply edit the level by changing these numbers. Remember, any tile with a number above 0 will register as a collision in the game.

I recommend you don't edit the file until you've tested the map, which I'll explain in Step 5.

Step 4: Adding enemies

This is probably the hardest part of the whole process. If you open up one of the files in the folder "Scripts" (except for "LevelLoad.txt"), you'll see something like this:

Quote:

RobotGuard 1300 397 1
BombBot 400 410 0


These are little enemy codes that tell the game where to place the enemy in the level. So far they follow this form:

[type of enemy] [x-location] [y-location] [direction]

in place of [type of enemy], you could place these:

RobotGuard
BombBot
SniperBot
MegaRG

I think [x-location] and [y-location] are pretty self explainitory. They're the coordinates of the enemy in the level.

[direction] is what direction the enemy starts of facing. Only two values can go here, 0 or 1. 0=Right and 1=Left.

For now, just create a blank text file called "tutorial.txt", and save it in the folder "Scripts". I recommend only trying to add enemies after you've tested the level.

Keep in mind that adding enemies will be very difficult, because of how exact you need to be. For instance, the RobotGuard needs to be placed exactly above the floor, and if it is even a pixel off, will produce unexpected results.

Step 5: Running your map

By now, you should have the following:

1. An image file in "gfx/bgs" called "tutorial.png".
2. A folder called "gfx/bgs/tutorial", with "0.png" and "1.png" in it.
3. A file called "tutorial.txt" in the folder called "Levels".
4. Another file called "tutorial.txt" in the folder called "Scripts".

If you have all of these things, go into the folder "Scripts" and open the file called "LevelLoad.txt". Change it so this file says "tutorial" instead of "city". Now run the game.

You should now be playing the game in the map you made. If it doesn't work, you will know, because the game will crash.

-----------------------------------------------------------------

I realize that I'm awful at writing tutorials, so please feel free to leave a comment if you have any questions.
Sign in to follow this  


6 Comments


Recommended Comments

Awesome!

Just found another bug. If you change weapons, the flying bullets from the previous gun disappear.... Keep it goin, this is pretty kick ass.

Share this comment


Link to comment
Sadly I'm aware of this bug, but I can't think of a way to fix it. The bullets are part of the weapon class, so once it's switched, they dissapear too.

Share this comment


Link to comment
I think I'm gonna wait for an editor on this one... ;) A system where you import your background, then scroll around and just click and it automatically saves it. That probably wouldn't be too hard to rig up.

When I do bullets / bullet-type things in my games, I usually make them a separate class, something like...

class BULLET {
int x, y;
int state;

void Draw();
}

#define MAX_BULLETS 256
BULLET bullet[MAX_BULLETS];

Then I just use a loop checking bullet states to decide whether to draw them or not. Oh, I guess there'd be velocity and direction and all that in the class, etc. I'm sure there are more elegant solutions than mine, but I like to do things the old-fashioned way sometimes. ;)

Share this comment


Link to comment
Fairly off-topic: One of the creators of Professor Fizwizzle actually runs the Game Programming Wiki.

I'm not sure how this will be helpful to you, but there you have it. [grin]

Share this comment


Link to comment
Yeah, I know. I've used it a few times as a reference. I think they have some good stuff in there.

Share this comment


Link to comment
For CSRPG2, I wrote a unified editor that had crappy "forms" that produced entity definitions, and saved them properly.

It was a terrible, barely-usable editor but it was a hell of a lot better than ruining my eyesight typing data into the entity files. [grin]

Consider taking the time to add an entity-placement feature, you'd be surprised how useful it is. Same with flood fill.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!