Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Level Editor?  (Read 1211 times)
0 Members and 1 Guest are viewing this topic.
Offline Wolfner

Senior Newbie





« Posted 2010-07-11 12:20:01 »

Hi there,

I was wondering if there are any good tutorials for writing a basic level editor.

Cheers
Wolfner

[IMG]http://www7.pic-upload.de/19.06.11/f6qp8oiqop8s.gif
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 12


Game Engineer


« Reply #1 - Posted 2010-07-11 20:07:46 »

I'd just try to learn Java Swing and then decide the format your level files are going to be saved/loaded in. Otherwise it's up to you on what's best for your game.

For saving files, take a look at ObjectOutputStream and ObjectInputStream, they're probably the easiest and most powerful methods.

See my work:
OTC Software
Offline JL235

JGO Coder


Medals: 10



« Reply #2 - Posted 2010-07-12 19:49:01 »

For saving files, take a look at ObjectOutputStream and ObjectInputStream, they're probably the easiest and most powerful methods.
I disagree. I'd output the contents in a text format, like XML, and then read it back in to recreate the objects. I believe there is an XML parser in the Java API, but I've not used it. The reason I don't recommend serialization is because it breaks the moment you alter the classes, which limits how maintainable it can be.

If you do save your levels as plain text then you might find their size becomming quite bloated (like in the magabytes). This can be especially true with all the tags in an XML based format. If this happend then I'd recommend compressing the contents when saved and decompress when you load as plain text compresses _very_ well and should solve this issue.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 12


Game Engineer


« Reply #3 - Posted 2010-07-12 21:06:11 »

I disagree. I'd output the contents in a text format, like XML, and then read it back in to recreate the objects. I believe there is an XML parser in the Java API, but I've not used it. The reason I don't recommend serialization is because it breaks the moment you alter the classes, which limits how maintainable it can be.

If you do save your levels as plain text then you might find their size becomming quite bloated (like in the magabytes). This can be especially true with all the tags in an XML based format. If this happend then I'd recommend compressing the contents when saved and decompress when you load as plain text compresses _very_ well and should solve this issue.
Well you don't want to write MyCoolEntity directly to the disk, you want to write SavedEntity to the disk that contains information on how to construct the desired MyCoolEntity. As for altering the classes, all you need to do is declare a serialVersionID (paraphrasing the variable name) for any Serializable and then just keep it the same. That will avoid any issues reading old save files unless you drastically change the data. If you're still worried about losing data across versions you can use Externalizable instead of Serializable, but it's quite slow and fairly annoying to use in comparison.

IMO the reason not to bother with text is because it's too easy for people to mess with and ends up with a bloated file size. It's also slower to read and to write. But that's not to say I haven't made text-based level file systems many a time before, because I have.

See my work:
OTC Software
Offline Nate

JGO Kernel


Medals: 129
Projects: 3
Exp: 14 years


Esoteric Software


« Reply #4 - Posted 2010-07-12 22:41:21 »

Text is generally better because it is easier to see what is going on when something doesn't parse. The stored data is likely to change over time, so this will happen. Also, obviously hand edits can be done easily. Text compresses well enough.

Java's built-in serialization sucks for many reasons, so I would avoid using the Serializable interface even if you want to go with binary. Using DataInputStream/DataOutputStream is an ok way to go, but you will have to manually write code for each piece of data you want to save. You might check out Kryo for an easier way to go:
http://code.google.com/p/kryo/

If you don't mind another shameless plug, I would recommend YamlBeans:
http://code.google.com/p/yamlbeans/
This writes/reads Java beans to/from a nice, human readable text format without you having to write the code to serialize each bit of information. It can write an entire object graph, so you can still have nice OO level storage.

Offline DavidX

Senior Newbie





« Reply #5 - Posted 2010-07-13 09:15:48 »

Either save the output in a text form (SGML, XML) or a binary form which can be reconstructed to form the level structure.

For a binary structure, the structure will most probably analogous to the following:

1  
2  
3  
4  
 <4 bytes> - Number of objects
 Repeat Number of objects {
  Object information
 }


which is analgous to this in a XML structure:

1  
2  
3  
4  
5  
6  
7  
8  
9  
<Objects>
 <Object1>
  <Attr1="Something" />
  <Attr2="Something>
   <SometingInsideAttr2="
Something Else" />
  </Attr2>
 </Object1>
 ...... And so on
</Objects>


Binary will probably be faster to load, but XML will be easier to edit, (well that depends on how good your Level Editor is.)

I wouldn't really recommend ObjectInputStream and ObjectOutputStream, you might encounter problems loading old levels with a new version of the game.
Offline gouessej

« In padded room »



TUER


« Reply #6 - Posted 2010-07-20 19:56:23 »

Give a look at the level editor of JME 3 and maybe at JFPSM Wink

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (53 views)
2014-04-15 18:08:23

BurntPizza (51 views)
2014-04-15 03:46:01

UprightPath (65 views)
2014-04-14 17:39:50

UprightPath (48 views)
2014-04-14 17:35:47

Porlus (65 views)
2014-04-14 15:48:38

tom_mai78101 (89 views)
2014-04-10 04:04:31

BurntPizza (149 views)
2014-04-08 23:06:04

tom_mai78101 (245 views)
2014-04-05 13:34:39

trollwarrior1 (203 views)
2014-04-04 12:06:45

CJLetsGame (210 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!