Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411558 Posts in 69384 Topics- by 58443 Members - Latest Member: junkmail

May 03, 2024, 11:30:30 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Level-Editor Needed(eventually)
Pages: [1] 2 3
Print
Author Topic: Level-Editor Needed(eventually)  (Read 6045 times)
BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« on: April 03, 2010, 01:31:57 PM »

So, I have a bad feeling about this.(shameless Star Wars reference.)

I have a feeling I'll need a level editor to create my games with, at some point. To an extent, placing objects with code isn't too bad for something like a shmup or simple arcade game like, say, Pong.
But you get into something more like  Cave Story and figure out... That's not so fun. Especially when these magical things called "tiles" come into play, and you need multiple layers of them.

I've heard of and used Mappy, but it didn't really satisfy me.

What I want is my own level editor, just because I'm like that... ! I'm sure some people can relate, I like to know every little thing that's going on from A to Z and have completely control. I obviously can't do that with everything, but I think I can with a level editor. I think it's good experience, anyway.

So let's assume I have an engine which supports draw-ordering through a depth variable.(So I can sort out what gets drawn on top of what, etc.) I'd then probably want a tile system that supports multiple layers, probably arbitrary layers.(user specified depth)
Then the objects... Ohhhh, the objects. I'd have to figure out how I'd recognize and place those.

So basically here, in this topic, I want to ask questions(and hopefully get answers) on problems I have making my level editor.

Obviously the first problem I need to tackle is the file format, the way I'll communicate data from the editor to the game.
I'm thinking I'll have just a plain text file that I can read, because that's all I know how to do..!
The format consists of:
- Simple data(name, description)
- Objects (id, position coordinates, layer data)
- Tiles (id, position coordinates, layer data)

... And that's it.
... Using what I know, I figure I can do something like
Code:
NAME:Skular Meadow&
DESC:Random test level bla bla bla&
--OBJECTS
chest, 16, 16, -1
--TILES
gr1, 8, 8, 1
gr1, 16, 16, 1
gr1, 24, 24, 1
--
The problem here is that I'd have to create some sort of translation system, and if I wanted to add new objects I'd have to have some kind of translate in my code. IE:
Code:
if (name == "chest") {
    objectcontainer.addObject(GameChest(x, y, bla bla bla));
}
Then the problem comes with "bla bla bla". With some objects(in this case, a chest) I'd want to be able to specify some kind of data. In the case of a chest, it would probably be contained item data.

I've had experience reading and writing text files with my own formats before, but nothing this... big?

Anywayyyy~! I hardly know what I'm doing, so much guidance and assistance is needed. Thank you!
Logged

Chris Whitman
Sepia Toned
Level 10
*****


A master of karate and friendship for everyone.


View Profile
« Reply #1 on: April 03, 2010, 01:41:10 PM »

Since I'm doing some updates to my editor right now, I'm going to finish off this thing, and then I will be back to drop some knowledge. I've been way more organized, tool-wise, for this project and it's worked out pretty well.
Logged

Formerly "I Like Cake."
BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #2 on: April 03, 2010, 01:49:03 PM »

Many thanks~  Hand Thumbs Up Left Grin

If you'd share all you're doing with this toolset of yours I'd appreciate it. I want to eventually develop a whole toolset to build my games as well, and eventually build up to a full blown engine, or at least kick-ass software suite.
Logged

Tycho Brahe
Level 10
*****

λx.x


View Profile
« Reply #3 on: April 03, 2010, 02:27:20 PM »

have you considered using binary files for it? that way you can (potentially) dump a whole level or map in, just by writing the objects to a file
Logged
Chris Whitman
Sepia Toned
Level 10
*****


A master of karate and friendship for everyone.


View Profile
« Reply #4 on: April 03, 2010, 03:46:41 PM »

I recommend against writing structs or what-have-you in binary to file, because from platform to platform there are byte alignment and endianness issues to contend with, and it can be kind of a nightmare.

I actually use XML for basically all my files, which has its advantages and disadvantages. Advantages are that reliable tools to read and write XML files already exist, so I didn't have to worry about writing my own parser; it's cross-platform; and it's generic, so basically everything loaded from or saved to file works in the same manner. The only disadvantages are that XML is an ugly, ugly format, and that some files end up kind of bloated due to the tree structure (some of my rigging and pose information files for characters are like 500k, which is fine for a large game, but maybe not great for small freeware or what have you).

I personally still feel it was the way to go, just for portability and ease of use, but it really depends on what you're doing.

As far as the actual editor, I built a full WYSIWYG editor for basically every component of the game, including character animation:



Game areas:


Stage backgrounds:


Etc., ad nauseam.

I used CEGUI for the editor GUI, since thanks to its OpenGL drivers it runs right inside the engine, plus then I can use the tools on both my Mac and my PC. Unfortunately, it suffers from Open Source disorder, where it is very finicky, prone to crashes, and new releases are rarely properly backwards compatible. Trade-offs, I guess.

Despite the extra work in developing and managing a full tool suite, I think it has definitely been worth it for the resulting ease of use. I couldn't imagine how long it would take to edit most of this stuff by hand.

Developing the editor alongside the main code base was also a good idea. Although keeping the two synced up with features was more work, it meant I always had reasonable test data to use when testing out new features, and I think I avoided a lot of potential bugs and issues making sure the main engine components were tolerant enough to support actual production data (which might, for example, not have collision boundaries perfectly aligned or what have you).

So I don't know! In response to your file structure questions, I'd recommend something generic, and preferably a format that already exists and has widely available support, since then you just don't have to concern yourself with the specifics of parsing, and it's one less thing to test and debug. Other than that, was there anything else you wanted to know? I've been in tool development mode for this project in one stage or another for 3/4s of a year, during which I've had a chance to experiment with a lot of different approaches. If you have any other questions, fire away!
Logged

Formerly "I Like Cake."
BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #5 on: April 03, 2010, 05:40:43 PM »

Hrmm, I just looked up the structure and such of XML... And I question why I ever did my own file formats.  Crazy

Moving on I don't really know how I'm going to stab at the GUI. I don't know if I'd use Windows Forms with Visual Studio, or if I'd use wxWidgets, or CEGUI. So many choices! I know very little OpenGL, so I'd probably encounter problems. But, in parallel, I don't know how to draw polygons and images when using wx or the windows library with WinForms in MSVC++. The windows library has the most GUI options, which is a drawing point, but it also means Windows only.
Logged

TobiasW
Level 8
***


This can only end brilliantly!


View Profile WWW
« Reply #6 on: April 03, 2010, 08:15:03 PM »

Maybe this tutorial can help you as much as it helped me when I needed a level editor: "In game c++ map editor tutorial with IndieLib engine that dosen’t use tiles but pieced images like in Braid or Aquaria games" (yeah, that actually is the blog post title). It's not perfect and it has a few bugs and memory leaks, but I guess it's a better starting point than having none at all?

Hrmm, I just looked up the structure and such of XML... And I question why I ever did my own file formats.  Crazy

Heh, yes. After reading your initial post, I wanted to suggest XML too.
Logged

BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #7 on: April 03, 2010, 08:27:43 PM »

Hot damn! Dat shet is in depth!  Hand Thumbs Up Left

It's a good thing my spring break just started; hopefully I'll be done with this by the time it ends!  Durr...?

It's on the line of what I'm looking for, though, so I'm not complaining.
(actually, I wanted to do an external editor-- But whatever, right?)
« Last Edit: April 03, 2010, 08:41:05 PM by Jakman4242 » Logged

TobiasW
Level 8
***


This can only end brilliantly!


View Profile WWW
« Reply #8 on: April 03, 2010, 08:36:41 PM »

actually, I wanted to do an external editor-- But whatever, right?
Well, just don't implement any game logic in the editor and you have an "external editor". The tutorial just calls it "in game" because it suggests that you should implement said game logic in it, but that's more like a bonus exercise to do afterwards.

(Nonetheless, if you think you can do it, do it. It is far from being easy, but it sure speeds up the map creation process...)
Logged

BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #9 on: April 03, 2010, 08:44:06 PM »

Well I'm a strong believer in fine separation.

An alternative, personally, that I would do is have the "test" button start the game with the specified level file so it just jumps into that level on startup.

But, that's just me.  Durr...?
Logged

raigan
Level 5
*****


View Profile
« Reply #10 on: April 04, 2010, 05:00:53 AM »

I would urge you to take a look at markup languages beyond XML, there are many which are simpler and/or less ugly and/or easier to work with. Here are a few examples:

YAML: http://www.yaml.org/start.html
JSON: http://www.json.org/
Mungo: http://www.bananattack.com/mungo/
SDL: http://en.wikipedia.org/wiki/Simple_Declarative_Language

SDL would be my pick, but sadly the website seems to be down.. Sad
Cached version: http://74.125.93.132/search?q=cache:JUNrrgdVy_wJ:sdl.ikayzo.org/+simple+Declarative+languagew&cd=1&hl=en&ct=clnk&gl=ca
Logged
Eraser
Guest
« Reply #11 on: April 04, 2010, 06:53:25 AM »

What I'm currently using for my tile-based game is the Tiled editor (from mapeditor.org). It outputs XML or base64, I opted for XML output, which I then run through my custom parser which transforms it into my own format (to save on disc space... XML is huge, and I had trouble writing a base64 parser). Creating a parser is certainly is a lot better than trying to reinvent something as complex as a map editor.
Logged
Chris Whitman
Sepia Toned
Level 10
*****


A master of karate and friendship for everyone.


View Profile
« Reply #12 on: April 04, 2010, 08:08:13 AM »

Yeah, since a few of my files have ballooned up to almost 500k, I've been thinking of switching file formats to something less bulky. Ideally I'd like to find something with an existing parser instead of writing my own, though, since I'd prefer to have something reliable and already tested (and I hate reinventing the wheel).

Anyway, it sounds like you haven't really settled on whether you want to develop simply a tool suite or a whole engine, so I might recommend you figure out what your technical requirements are going to be before you start working on tools.

I too would recommend doing an in-game or in-engine editor. That way you can reuse all your engine code instead of writing everything twice, and you can test functionality while also using your editor. But yeah, a generic editor is a pretty big project, and even then when you start developing a game to make use of it you might find you need additional features, so I would recommend having some goal in mind before you get started.
Logged

Formerly "I Like Cake."
BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #13 on: April 04, 2010, 09:50:47 AM »

Well, ideally, I want an environment that compliments and improves my workflow as much as possible.
Since my games are usually relatively simple, I can only think I'd require a map editor.

I do know what I need-- I've planned quite a bit on paper prior to this topic. I want a dynamic level editing engine, so I may use it across many of my projects. In my game framework there's objects, and tiles. To get the editor to recognize these, I've thought of some kind of file to define objects and tiles with a name and reference image. I'm not sure how I'd create these, but I'm sure creating them manually wouldn't exactly be difficult. Smiley

Most of what is hampering me, is that I want to use a 'real' GUI system. I'd prefer to have everything be visual rather than keyboard shortcuts. This really isn't an excuse to the creation process, and GUI is obviously not exactly necessary, but it would really come in handy and increase usability for collaboration, or in the rare event I might release this tool for others to use.

With objects in the game, I want them to be able to take custom parameters. Like I mentioned, I would want objects like Chests to be able to have a specified item, rather than making a new child Chest object and defining it's item within the code. It's something I still need to work out myself, since I don't know how loading XML works and I'm not sure how I'd load in, say, boolean or integer data. I'm imagining I'd have to convert from string.
Logged

oahda
Level 10
*****



View Profile
« Reply #14 on: April 04, 2010, 10:18:47 AM »

I'd recommend using Nokia Qt for the GUI.

As for the file format, I would probably prefer creating one myself.
Some simple markup language of my own flavour, encrypted by the editor and decrypted by the engine.

Decrypted, perhaps this would be the look I'd aim for:

Code:
Tileset:
graphics/tiles/house.png
1 1 8 9 1
2 1 9 9 1
2 1 10 9 1
2 1 11 9 1
3 1 12 9 1
;

Object:
Rock
8 9 2
9 9 2
;

Tileset: declares a new tileset.
First line is the graphic path.
Other lines are for placing tiles; tileX, tileY, x, y, layer.
Semicolon ends it.

Object: declares new objects of a certain kind.
First line is the object class name.
Other lines are for placing them; x, y, layer.
Semicolon ends it.

For example.
Logged

BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #15 on: April 04, 2010, 10:59:09 AM »

For now, I think I'd prefer to go the easy route with XML.  Hand Thumbs Up Left
If the file size becomes an issue later on, I'll definitely write my own format and parser again. But for now, I just want it to work.

And thanks for that link to Qt! I'm surprised I haven't heard of it. Looks very sexy! /downloads
[EDIT]
So, I just downloaded Qt, and it's slow as tits! It doesn't appear to use much processor power, and the GUI elements are reaction(like they'll do their animation when my mouse hovers over them), but when I click or etc. there won't be a reaction for at least 20 seconds or more.
Has anyone else encountered this problem? I have all the latest stuff, I believe, since I downloaded from their website. Even though, it seems like people were having similar problems with Qt creator 1.1.
« Last Edit: April 04, 2010, 12:03:26 PM by Jakman4242 » Logged

oahda
Level 10
*****



View Profile
« Reply #16 on: April 04, 2010, 12:16:45 PM »

For now, I think I'd prefer to go the easy route with XML.  Hand Thumbs Up Left
If the file size becomes an issue later on, I'll definitely write my own format and parser again. But for now, I just want it to work.

And thanks for that link to Qt! I'm surprised I haven't heard of it. Looks very sexy! /downloads
[EDIT]
So, I just downloaded Qt, and it's slow as tits! It doesn't appear to use much processor power, and the GUI elements are reaction(like they'll do their animation when my mouse hovers over them), but when I click or etc. there won't be a reaction for at least 20 seconds or more.
Has anyone else encountered this problem? I have all the latest stuff, I believe, since I downloaded from their website. Even though, it seems like people were having similar problems with Qt creator 1.1.
40 minutes is an incredible time for you to have acquired it at all, since the library takes several hours to compile.
Maybe you've just been playing around with Qt Creator? I've actually never tried that myself. I've just used the C++ library and coded my stuff. You should, too. It's a ridiculously simple library to use if you look in the documentation and you know the language.
Logged

BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #17 on: April 04, 2010, 02:42:15 PM »

Ah, okay.

I had just downloaded the 'full suite' or whatever, which includes their Qt Creator, and I dove into that. It hates me, I'm just going to go all code.  Hand Fork Left Ninja Hand Knife Right

[EDIT]
I figured it out. It doesn't agree with me using a Wacom Bamboo mouse, for some reason.  Crazy
« Last Edit: April 04, 2010, 03:40:17 PM by Jakman4242 » Logged

nikki
Level 10
*****


View Profile
« Reply #18 on: April 05, 2010, 04:55:02 PM »

i am writing my own gui system, Its not very hard, but it takes some time to get the behaviours exactly like you want them.

Eventually you'l be making your GUI-editor too (maybe even with some xml..), if you'l follow this route, wich is nice or not, depending on your tastes and philosophies
Logged
BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #19 on: April 05, 2010, 05:34:26 PM »

I don't exactly understand what you're saying in that post; your grammar is pretty horrible there. Smiley
It's intriguing what you might mean, but I don't want to guess.
Logged

Pages: [1] 2 3
Print
Jump to:  

Theme orange-lt created by panic