Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (492)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
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 2024 times)
0 Members and 1 Guest are viewing this topic.
Offline MOEP_BIBER

Senior Newbie





« Posted 2011-06-03 10:59:42 »

Hey Guys,
i am currently trying to implement a level editor into my little 2d sidescrolling jump n run.
I got it working since yesterday, but i dont know how i should save the levels.
What the level editor is doing:
i draw rectangles with my mouse ingame and those ectangles are getting saved in an rectangle-arraylist.
How can i save that Rectangle arraylist in an txt document or something so i can reload my levels?

thx 4 ur help
moep
Offline Captain Awesome

Junior Member


Medals: 2


Hi


« Reply #1 - Posted 2011-06-03 12:30:26 »

The easiest way is to use java serialization
Offline MOEP_BIBER

Senior Newbie





« Reply #2 - Posted 2011-06-03 12:48:51 »

OK thank you i will look into that tomorrow.

Another question:
how can you "blockify" ur world?
I mean games like minecraft or terraria have everything seperated into blocks.
I think handling everything in blocks is making some stuff easier.
How can i achieve that?

Greetings moep.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline evilfrenchguy

Junior Member


Medals: 3



« Reply #3 - Posted 2011-06-03 12:49:46 »

Yeah, serialization is the best way.

Any objects of classes that you make that need to be saved should implement the Serializable interface. This marks the class so Java knows that objects of that class might need to have a "snapshot" taken and tucked away in an encrypted file. What I mean by that is that it will save the state of the object, so it remembers what values your variables were set to.

You don't need to override any methods for the Serializable interface. It's just a flag for Java. Any objects that are inside Serializable objects also need to be marked. If you look at the javadocs, most classes implement Serializable.

Let me know if you need an example of saving/loading these files.
Offline evilfrenchguy

Junior Member


Medals: 3



« Reply #4 - Posted 2011-06-03 12:54:35 »

"Blocks" are good and common ways to do platformers.

Try making a Block class that has an Image and a size in it. Then, your levels can be a 2D array of Block objects! Experiment with that, see how you like it.
Offline MOEP_BIBER

Senior Newbie





« Reply #5 - Posted 2011-06-03 13:06:26 »

ah ok that sounds nice.
I will try serialization and that block thingy tomorrow or the day after tomorrow and give feedback then.
You can post an example of saving/loading if you want to, but as i said i cant test the next 2 days.

Thanks for your help =)

Greetings moep.
Offline zoto

Senior Member


Medals: 4



« Reply #6 - Posted 2011-06-03 13:09:10 »

The block thingy is called Tile based games.
Offline MOEP_BIBER

Senior Newbie





« Reply #7 - Posted 2011-06-03 13:20:59 »

Ok thank you^^
Im sry this is my first game and im programming it since about 2 weeks so im not that experienced yet =)
Offline cylab

JGO Ninja


Medals: 45



« Reply #8 - Posted 2011-06-03 15:48:34 »

For tile based games, take a look at Tiled: http://www.mapeditor.org/. It's written in C++, but has a java library included to load the created maps.

Mathias - I Know What [you] Did Last Summer!
Offline Zushii

Senior Newbie





« Reply #9 - Posted 2011-06-05 15:26:51 »

Terraria has basically made a huge grid. Each "block" in the grit has a id (e.g. stone,silver etc. or maybe numbers like 02,05).

The game then starts to render the gameblocks according to the grid. The player in Terraria moves freely, and only interacts with the blocks on the grid, not the grid itself. 
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Rejechted

Senior Member


Medals: 1
Projects: 1


Just a guy making some indie games :D


« Reply #10 - Posted 2011-09-21 13:34:04 »

Sorry to bump.  

I'm working on a slightly more advanced level editor for an action RPG.  Serialization works fine if you only have one type of object or world element.  What happens when you want to introduce different types of terrain objects, objects that you can interact with, fixed-location enemies, and pickups, all with various fields, into your level file?

Serialization seems a bit crazy at this point because all of those different types of game objects come with their own set of fields that we want to define in the editor (initial stats for a fixed position enemy for example).  Additionally "Event-type objects" like switches or buttons, which need to be placed and scripted in this editor, are a lot more complex than simply storing a bunch of tile data for blocks.

EDIT: If anyone is still reading this thread, I'll give a bit of an update on how we are attacking the problem.

Essentially the types of objects we can add to the game are constructed with primitives or things derived from primitives (A string tells our texture loader what image the entity should have, for example).  If we know everything that goes into constructing our object, and those things are primitive, we can (safely?) serialize them without fear of locking ourselves into a certain class architecture.  We simply write out a collection of "things" we need to rebuild the object in order, and have static builder methods for the few types of things we need to build that know what order to expect the serialized data to be in.  Not much different from serialization, but instead of a new version of the class that requires new fields to be imported completely breaking our system, we just output an extra field when we save the object data, and provide a default if the "builder" method is loading an older version for which that field was NYI.

Blog for our project (Codenamed Lead Crystal): http://silvergoblet.tumblr.com
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.

Nickropheliac (16 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (33 views)
2014-08-22 19:31:30

atombrot (42 views)
2014-08-19 09:29:53

Tekkerue (41 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (26 views)
2014-08-16 06:20:21

Tekkerue (37 views)
2014-08-16 06:12:11

Rayexar (73 views)
2014-08-11 02:49:23

BurntPizza (49 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!