source for a simple map-editor wrote in c

Started by
27 comments, last by GameDev.net 18 years ago
Hi, i'm new in this forum. I want to create a simple map-editor in C, but i need some tutorials or source of other map-editors... thank you.
Advertisement
A map editor for what? 2D or 3D? What sort of game?

For some games Notepad is an adequate map editor, so no-one can possible help you without some more specifics.
Hi ... I understand @Bob Janova you are perfectly right. I want an example for a map-editor (or a tutorial) 2D ,not 3D . I need for a strategy game.
I repeat : A SIMPLE MAP-EDITOR. I find a long time a tutorial, but he included allegro.h ( and I dont know hwo installing this library) I use Visual C++ 6
I know only create problem for highschool(-school:PASCAL :((boring; Home:C/C++-)

P.S. sorry for my bad english (with this problem, I learn English(very well) and i please ,you when i wrong in a senteces with a gramatical problem, tell me!!! )
thank you in advance.


Map editors can get very complex very quickly. I would advise against trying to get the souce code for a complete editor and modifying it. It would be far better for you to start from the ground up and learn the basics as you go along. Learning the details of tile based engines will allow you to build a much better editor and then go onto developing games with it. If you jump in with someone elses code, you might be able to figure it out, but you'll probably spend a lot of time trying to make it do what you want.


There's a lot of info on this site for tile based games here:

Gamedev tile based stuff

And another site with a lot of useful stuff on it is:

Amit's game programming info

There's loads more too I'm sure.


PS. Most of your English was actually very good.
This looks like a good tutorial for creating a tile-based map editor in C from scratch.
It uses allegro. You can follow method B to install allegro for Visual C++.

When writing a tile based map editor the biggest challenge is to react on keyboard and mouse clicks. Allegro has functions to do this, as well as functions to do all the drawing of the tiles, so it will make life much easier for you.

Creating the editor with native WIN32 API is possible but more complex.
Here is an example on creating a level editor.

Here is another tutorial based on SDL.

If you have a RAD tool like Delphi (pascal) or Borland C++ Builder (C++) it can be done quite easy. They both have functions for handling graphics, keyboard and mouse.
Well, for a simple strategy game with a rectilinear grid I would say use Notepad as your map editor! Each character position represents one tile in the game, and different letters can be used for different types of tile (blank space for an open tile, dots for water, T for trees etc).

If you want to include entities in the map, below the section that defines the terrain you can just list them. I.e.
# Example map file with a riverT  TT T    ...         TT T T TT     ...   T   T T TT T      ...         T T TT      .. .          T  T        ...                     ...            # Below a blank line, list entities# type, team, x, ybuilding_hq1,team_0,0,1unit_civilian,team_neutral,16,5


Obviously you need to write a parser for the entity lines if you do this, but it is very easy to do so.

Once you have a game engine, you can re-use parts of it to create a level editor in which tiles are displayed in the same way as they are in the game, entities can be placed and edited and so on. But that can wait until later.
I agree with Bob Janova that you can leave the map editor until later. Most professional games will probably have the level editor first, but when doing it on your own it can save a lot of time to get the basic game up and running first.

I wrote a platform game similar to Sonic The Hedgehog that had an in-built editor. This was a lot easier, since I could use much of the same code to handle user input, rendering the map etc.

You can also use bitmap images as maps, and have different colours for different objects. Green for trees, blue for water etc. This has an added advantage that you can use the bitmap image as a sort of mini-map in the game itself, which would be handy in an RTS game.
@pulpfist and @DumbBill thank you for answers! This tutorial i talk and me
http://www.adersoftware.com/src/editor.html This tutorial is not for OOP or something else... (so i dont need to know programming on windows for this tutorial, dont I?)
I choose METHOD B(with instaling allegro.h) -I wait a good internet ,because i use a DIAL-UP, for download this paches.

A question : What means "TILE"

@Bob Janova and @DumbBill: you jocking me ? be serious!

"# Example map file with a river
T TT T ... TT
T T TT ... T T T
TT T ... T
T TT .. . T
T ...
...

# Below a blank line, list entities
# type, team, x, y
building_hq1,team_0,0,1
unit_civilian,team_neutral,16,5"

NOT BAD! :):D But I want to use allegro :P

off-topic
I decided to create a game not for a internet which means like that
www.bitefight.com (he is for the internet) (sorry if I do ads),but only for computer (for DOS)
I used function Sleep for waiting some min or sec.
What you say?(when you know i am a beginner in C\C++ , I know only programming for DOS)

Quote:
http://www.adersoftware.com/src/editor.html This tutorial is not for OOP or something else... (so i dont need to know programming on windows for this tutorial, dont I?)

Thats right. You dont need to know OOP or Win32 API.
Quote:
A question : What means "TILE"

A tile is usually no more than a small image.
A tileset is a collection of tiles.

Here is a good tileset for free that can be used to make a game level.

The level in a 2d game is created by drawing tiles side by side.

Quote:
off-topic
I decided to create a game not for a internet which means like that
www.bitefight.com (he is for the internet) (sorry if I do ads),but only for computer (for DOS)
I used function Sleep for waiting some min or sec.
What you say?(when you know i am a beginner in C\C++ , I know only programming for DOS)

When you say DOS, do you mean the text console?

Programming with graphics is a bit more difficult than text only.

If you are unexperienced, setting up allegro with Visual Studio can be difficult. I have not done it myself for years so I am not sure.

Good luck =)

[Edited by - pulpfist on March 13, 2006 4:07:48 PM]
hi, text console ! I have a change?
I decided to don't learn grahics for DOS, what u say ?
"If you are unexperienced, setting up allegro with Visual Studio can be difficult." WHY IS DIFFICULT? if i read Method B and if I installing this lib. I will read tutorials!

"I have not done it myself for years so I am not sure."
I don't understand what mean this sentences...

regards.

This topic is closed to new replies.

Advertisement