Sign in to follow this  
BFMVfavorite

making a level editor

Recommended Posts

Hello all, I've been attempting at making games for the last 2 years, but none of them have ever really worked out. I finally figured out that making a game would be so much easier if i had a level editor. i was thinking of a level editor where i have my own custom file to work with, and a drag and drop system. when i say that i mean i just have to click on what type of enemy or object i want and drag it to wherever, and can pick up to MAX_ENEMIES. i'll probably need to study up on pointers for this, but can anyone tell me how to get started with this, how to get it done, and any suggestions? Thanks a bunch, -Nathan

Share this post


Link to post
Share on other sites
C#.NET or VB.NET are good for level editors. Programming an editor won't solve your problems though. Programming the game usually tells you what the editor needs to be able to accomplish. I guess I'm confused as to why having custom files would help you so much?

I only suggest using .NET for it's GUI and speed of development, so if you have your own GUI, by all means you can use that.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
this really depends a lot on what kind of game it is
how the maps work
tilebased rpg and quake are pretty different..



as for the drag and drop thing and other gui stuff... honestly I never did anything that polished for my own map editor; mostly just keyboard inputs and a very simple (self implemented) drag/drop

if you want it to be pretty im sure someone else will suggest a nice library of stuff for that...

Share this post


Link to post
Share on other sites
it would be for an acrade style top down shooter (2D). well i would probably mostly want it simple, and im guessing drag and drop isnt simple, so maybe ill go for just the keyboard input, that sounds much easier.
but for my programming i'm using C++ and OpenGL, in the IDE MSVC++.NET, but never have learned .net...is this still makeable in c++, or will it be a lot harder without using C# or .NET?

Thanks,
-Nathan

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
2 years is a long amount of time for almost anything unless you are making a new fighter jet or atomic bomb. You need to work harder son.

Share this post


Link to post
Share on other sites
haha i know. well im in a bunch of honors and AP classes, and trying to get those grades up. highschool is a bitch. so all this programming is mostly on the side, and not a fulltime thing, maybe an hour or two on the weekends. not to mention part of those 2 years was learning all the stuff.

but anyways, does anyone have any comments, suggestions, or answers?

Thanks :)

[Edited by - BFMVfavorite on March 7, 2007 11:15:42 PM]

Share this post


Link to post
Share on other sites
Um, ya it's actually kinda a Chicken and an Egg problem I found as well when designing my 3D engine. I ended up going with a pre-existing format for several reasons.

The biggest 1 was, it was a 3D engine, and the tools for generating 3D levels for this format were awesome and I knew them well.

And 2, developing an engine is a huge under taking. There will be a long time when you don't have too much to show that will impress anyone but your self. So developing your own data format as well as tools for it extends that massively creating a time table that will probably kill your project because, lets face it, we all want something to show from our time. And it will just take you forever to produce a product on that time table.

Especially if your just learning programming.

If I can bestow one piece of advice on you it would be this:
It's ok to stand on the shoulders of others.

I always wanted to do everything from the ground up. Not use other peoples stuff. Even thought it necessary to write my own String class. But when you get down to it. I don't care how "low level" you think your getting. You are still standing on thousands of others shoulders. Just accept that fact, and find the shoulders you need to stand on to make something fun. Of course learn something from every project, but don't reinvent the wheel every time.

I'm sorry, I guess that didn't answer your question. But to be blunt, if you need to *start* learning about pointers. You probably need to rethink the scope of your project. Start small, then slim it down 10 times. That will be a good starter project. Check this out, it was the first game I ever made. Yes cheesy, and lame, but got me started.

Share this post


Link to post
Share on other sites
thanks for all that advice. first thing i wanted to address is, sorry if i made it sound like i was still learning how to program. i've learned C++ and OpenGL pretty well (and i know how to use pointers). i mentioned that part of the 2 years i've been programming, a year of it was learning them. so i know how to program fairly well.
next, yes i know its a pain to start everything from scratch, and would make much more sense to use another library or in my case level editor already made, but i think it would be a great learning experience if i made my own, not to mention i would enjoy making it, even though it would probably be problem after problem.

in the end, once i've at least attempted at making my own, i don't think i'm gonna use someone else's engine or level editor. so i'm guessing if you want to sum it up quickly, this is how you would do it? keyboard input, write all the positions of the different objects you've place in the file, and then load the file you wrote with your level editor into your game, and display the objects that way? a very vague summary, but is that the gist of it?

Share this post


Link to post
Share on other sites
Are you talking about a generic editor for creating arbitrary 3D meshes? And being able to do stuff like texture paint and UV map? Or are you talking about something where you just take maybe a level mesh and place in different object meshes and generic scripts and triggers, etc.? Because if you are talking about the former, you are in for doozy. Experienced programmers who are paid full time have a hard time pulling that off in a reasonable time frame. My suggestion would be to modify the Q3 engine - its OSS now, and modify its level editor radiant to serve your purpose.

http://ioquake3.org/
http://www.qeradiant.com/

Edit: i see you are dealing with 2D top-down shooter. Are you talking something like the old classic 1942? Well thats not too bad. And no, drag and drop isn't that hard, if you know what you are doing and the API isn't too hard to learn. On that note, MFC is pretty daunting for people who hare just started programming. You need to learn more about the event handling mechanism in MSVC. You can design your form directly in MSVC, and then add callbacks to handle mouse events. The code for declaring MFC message handlers looks pretty ugly. It uses paramterized macros. Fortunately you can mostly ignore it (sometimes you do have to deal with it, but for simple stuff you shouldn't)

What I envision is that you have a bunch of objects with x,y positions per level, I'd assume constrained to some constant width? So you would have maybe an object panel and then a canvas which you scroll up and down select the object, then click the mouse to add to a position on the map.

Share this post


Link to post
Share on other sites
Quote:
What I envision is that you have a bunch of objects with x,y positions per level, I'd assume constrained to some constant width? So you would have maybe an object panel and then a canvas which you scroll up and down select the object, then click the mouse to add to a position on the map.


that's exactly what i had in mind. it would be simple enough to just write it to a file that has the same format as a .txt (althought i'd probably name it something more like .map), and then i would just have to parse it into my game. i've already started it, and haven't had any complications besides getting string input....i can only input one at a time, so it's impossible to write a word unless it has one letter in it, or put in a number that has 2 or more digits. how do you get started with that kind of stuff? i'm just using Win32 for window creation.

Share this post


Link to post
Share on other sites
Well I have MSVS .NET (old 2003 version, but it works for me). I remember starting this stuff way back in college.

If you aren't already familiar with it, what you need to wrap your head around is the concept of *event handlig*. You basically supply the Windowing system with functions that are called when certain events occur (like say a button is pressed or a mouse is clicked on the screen)

Recently though, I've done alot of programming in Java. It is much cleaner and easier to use than C++/MFC. I've done very little raw Win32 programming. Bring up a frame with a button that does something like say "Hello World" when its pressed takes all of 10 lines in Java. If you use the MFC AppWizard in MSVC you have at least 5-6 files with a bunch of macros, #defines and other cruft. A total mess.

Share this post


Link to post
Share on other sites
My suggestion is to write the editor so it can be used in-game. If you have the display working with your engine and some good design, it shouldn't be that hard. First you should be able to display hand-written files before you have to edit them. The "file" could be a long lists of assignments such as
world[4][4] = WATER;
or something loaded from an actual file, as long as you don't have
if(x==4&&y==4) drawWater();
. Then look up imgui on how to do buttons, and perhaps text fields, if that is still necessary(or use the press A-key approach). Then do a "tool-approach", ie press one button and click where you want that action to take place. A tool could be place-a-water-tile, and another could be place-a-monster.

hth

[Edited by - sirGustav on March 10, 2007 1:56:51 AM]

Share this post


Link to post
Share on other sites
thanks a bunch for all the replies guys. that link you gave me looks really good sirGustav, and SunDog yeah i agree code always ends up getting messy with win32. getting text fields and buttons in there will be a big help, and once i've got that done, only have to write the file to level.map or something like that. looks like i have my work cut out for me, and thanks for getting me headed in the right direction.

Share this post


Link to post
Share on other sites
Just my general thoughts on this issue:

I started making a level editor for my game in C# for WinForms (the game was made in C++ with OpenGL and SDL). I really liked WinForms and it made some of the things I was doing incredibly easy, even though I had no prior experience with it. All seemed well, until I started wanting to be able to edit some of the more complicated things. Then I started getting massive amounts of almost repeat code between my C# level editor and my C++ game, but still having to basically rewrite it since I was using a different language and libraries. In the end, my engine far surpassed the capabilities of the editor because I had no desire to recode many things again in a (just enough different that I had actually rewrite things) language.

The best move I made for that editor was to switch it to using the same code base as the rest of my code. That is, I turned the engine into a static library and used that in both my editor (which I also am now writing in C++) and my regular game. The cons of having two separate code bases that did the same thing outweighed the benefits I got from using C# and WinForms over C++ and my home-brew GUI.

Share this post


Link to post
Share on other sites
Quote:
Original post by sirGustav
My suggestion is to write the editor so it can be used in-game. If you have the display working with your engine and some good design, it shouldn't be that hard. First you should be able to display hand-written files before you have to edit them. The "file" could be a long lists of assignments such as
world[4][4] = WATER;
or something loaded from an actual file, as long as you don't have
if(x==4&&y==4) drawWater();
. Then look up imgui on how to do buttons, and perhaps text fields, if that is still necessary(or use the press A-key approach). Then do a "tool-approach", ie press one button and click where you want that action to take place. A tool could be place-a-water-tile, and another could be place-a-monster.

hth


I think you have a good suggestion in separating the display portion from the editing. Following the MVC (Model-View-Controller) in these situations can simplify things alot.

I don't think he necessarily has to start with loading map data from a file though. To test stuff you can just generate objects in code and put them in the map. Then do the callbacks that place map features. In my current game I am building, I started out with the map editor and scenario editor and only moved on to the actual game engine code once those were mostly complete.

BTW you may want to go with tiles for the map, at least for positions of objects. They are are much simpler than some unrestricted movement system, especially for things like collision detection. If you wanted, the background could still be an arbitrary image so that things don't appear to 'blocky', and you could let the ship be at an arbitrary position within the tile so things look much more smooth. ( I think Starcraft used a system like this) If you want to go this route, head on over to Isometric Land!

Share this post


Link to post
Share on other sites
A map editor can be one of the biggest projects you'll create so make sure you know what you're doing. Not only do you need to be very familiar with how games work and what needs to be written in order to complete a game, but you also need to be comfortable working with Windows (or your OS of choice).

There are literally thousands of API calls for whatever OS you're using and you'll need a good chunk of them to make an editor.

Having said that, this book helped me greatly as did this application (Mappy). You may also want to check out the Quake 1 or Quake 3 source code, I'm pretty sure both come with the QERadiant source code which can point you in the right direction with a lot of the Windows API calls you'll need.

As far as which comes first, the editor or the engine, I recommend the editor. How will you test your engine without test data? Why not build the test data as you build the engine, via the editor?

Share this post


Link to post
Share on other sites
ok ha i have one little problem, and this is kinda of a pathetic thing to get stuck on. how do i keep making copies of enemies? i have a class object, and in that has the variables for position and type stored (type is for what type of enemy). how would i make it so that i can make an unlimited amount of enemies? i want to be able to make a new enemy everytime i press a certain key.

Thanks guys

Share this post


Link to post
Share on other sites
LOL n00b alert! Well - it would be something like this:

[source lange="cpp"]

.h:

class Enemy {

private:

int health;
int weaponDamage;
int rateOfFire;
int x;
int y;

// whatever other variables you need to encapsulate enemy state (and depending on how what you need you may not need to store position)

public:
Enemy(int health, int weaponDamage, int rateOfFire, nt x, int y);

void setHealth(int newHealth)
int getHealth();

// whatever other functions relevant to your game

}
.cpp

Enemy::Enemy(int health, int weaponDamage, int rateOfFire, int x, int y)
this->health = health;
this->weaponDamage = weaponDamage
// .... etc

}

void Enemy::setHealth(int newHealth) { this->health = newHealth; }
int getHealth() { return health; }
///etc...


Your engine code:
#include <vector>

std::vector<Enemy*> *enemies = new std::vector<Enemy*>();
enemies->add(new Enemy(10, 1, 1, 10, 10));
enemies->add(new Enemy(10, 1, 1, 15, 20);



You could subclass a generic Enemy class and store lots of different types of enemies that behave differently. If you are going to end up having more than a few dozen though, and they are all merely variations on a similiar thing (like something that just sits there and shoots a gun at the player, but maybe with different fire rates and damage), I wouldn't subclass too much as having too many class files can clutter up your code base.

Share this post


Link to post
Share on other sites
Quote:
Original post by SunDog
I don't think he necessarily has to start with loading map data from a file though. To test stuff you can just generate objects in code and put them in the map.
What I meant (and tried to say) was that his game code should be up to the task to make into a level-editor. I've seen alot (too many) people asking for how to fly before they can walk :)

Share this post


Link to post
Share on other sites
Don't make a level editor if you don't have to:

1. When initially developing the engine, hard-code a simple map.
2. Once that becomes impractical for level design consider:

a. Use an existing editor and have your game read the output from whatever format that makes
b. Use an existing editor and write some kind of converter into a more convenient format
c. Building some minimal level editing into your game

---

Personally I'd say:
- 2d tiles - use either a text editor (for small maps with many different tiles) or paint program (large maps with few tiles)
- 2d vectors - consider a 2d vector editor, e.g. Inkscape SVG editor or similar (maybe even Flash if you have a licence for that)
- 3d stuff - consider using an existing modelling program and reading stuff in from the simplest, easiest format it makes. You might need to swap some components or mirror stuff, but you'll get the gist easily enough.

Object placement is generally a little more tricky, but you can have a composite approach, e.g. design your map with an existing tool, but place objects in the map using an in-game editor.

It is far better to write a converter than an editor - it's an easier program to write and maintain. Existing editors generally already have features like undo, copy & paste etc, so you should use them.

Mark

Share this post


Link to post
Share on other sites
To expand what markr wrote:

For 3d level editing, using an existing 3d package (such as 3ds Max) is a very viable solution. The names of the nodes/models in 3ds Max can refer to script files. These script files would then define game-specific properties. You can even have portals, trigger planes etc. defined in 3ds Max using geometry.

Writing an exportor for 3ds max is trivial compared to writing an a full-blown editor.

If you find at a later date that 3ds max doesn't cut it, then you could always write a custom editor.

Share this post


Link to post
Share on other sites
For the first several month of my game project, I used a text file to specify a tile-based heightfield and mesh map, and then turned this into triangles during level load time.

It was a very good way to get something up & running quickly game-wise without going down a rathole. I would recommend this approach or trying an existing editor.

Share this post


Link to post
Share on other sites
Quote:
Original post by BFMVfavorite
haha i know. well im in a bunch of honors and AP classes, and trying to get those grades up. highschool is a bitch. so all this programming is mostly on the side, and not a fulltime thing, maybe an hour or two on the weekends. not to mention part of those 2 years was learning all the stuff.

but anyways, does anyone have any comments, suggestions, or answers?

Thanks :)


Personally i would get yourself a sheet of A4 grid lined paper, and then open up notepad. Honestly and setup a simple *.ini file, which has something like

enemy=50,60
enemy=70,100


blah,blah.

These may be the positions on the map or whatever. But they will give you a map layout that your want to then attack the game part. Killing the enemies :)

Dont get bogged down with the editor. This itself can take a year to write. Say the unreal editor as an example has been around i guess for years now.

Honestly, design on paper. The ini parser will be a good exercise anyway, and its how we prototyped our last released game. We did end up with an editor but not for protoyping.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Anonymous Poster
2 years is a long amount of time for almost anything unless you are making a new fighter jet or atomic bomb. You need to work harder son.


That's nice. Cut him down Mr Anonymous. You don't know his schedule, his learning stage or anything else pertinent. Give him a break.

Share this post


Link to post
Share on other sites

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

Sign in to follow this