Jump to content
  • Advertisement
Sign in to follow this  
Teenage Death Boy

C# Map Editor For Tile-Based OpenGL Platformer

This topic is 4849 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok so I have been making good progress with my first major OpenGL (using SDL for window creation etc) game. It's about time I get a level editor up and running so my artist can begin bringing the levels designed to existance. I havn't really had much experience in any Win32 app programming or anything. I have used Delphi to a fair extent, and picked up a trial of Borland C++ Builder from my Uni. However, my friend has a spare copy of "Sams Teach Yourself the C# Language in 21 Days" which he bought mistakenly, so I can use. Yeah, I know, the "Sams Teach Yourself In 21 Days" is hardly the best line of books, but I thought I would give learning C# a try with the help of the internet, as I often read it recommended for some quick app creation. So here is the actual question. I don't think learning C# will be a problem but how exactly do I approach displaying the level within the editor? I've used the level editors for the big games (ie Farcry, UnrealEd, Hammer etc) but would I need to somehow incorporate OpenGL to do all the displaying of the tiles etc? If so, I have no idea how to go about it. Or is the answer to use a huge array of image controls or something? I highly doubt it would be feasible to have hundreds of controls showing the tiles. Oh and I havn't really begun C# but how would you recommend I handle scrolling the map? Is it similar to Delphi where I can somehow use a scrollbar control? Any help is appreciated as I am kind of lost. Thanks

Share this post


Link to post
Share on other sites
Advertisement
In C#, you could just override the OnPaint event on the form, and do all the drawing of the tiles yourself. In your case, I would have 1 panel containing all the tiles that can be used on the left.

The "big" or main panel would show the map. You would just draw the map in there the same way as you do in your engine, except you draw inside the OnPaint() event of your panel.

Make sure to have a class that holds the map and links to the tiles that are avaliable to you(Make a single cache to hold ALL avaliable tiles with for instance IDs to save to the map). You could start out with specifying the map size, 128 x 128 tiles. Such a class could look like:


public class Map
{
private Tile[,] mapTiles = null;
private Size size = null;

public Map(Size mapSize)
{
size = mapSize;

mapTiles = new Tile[size.Width, size.Height];
for (int x = 0; x < size.Width; ++x)
{
for (int y = 0; y < size.Height; ++y)
{
// init to some sort of terrain tile
mapTiles[x, y] = TileCache.GetTile("terrain");
}
}
}

// Index, so you can do map[x, y]
public Tile this[int x, int y]
{
get
{
return mapTiles[x, y];
}
set
{
mapTiles[x, y] = value;
}
}
}



Rendering and things can be done in the OnPaint, but you should be able to figure that out.

Toolmaker

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!