Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (780)
Games in Android Showcase (233)
games submitted by our members
Games in WIP (856)
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 4190 times)
0 Members and 1 Guest are viewing this topic.

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
Offline Captain Awesome

Junior Devvie

Medals: 2


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

The easiest way is to use java serialization

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 Devvie

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 Devvie

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.

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 Devvie

Medals: 4

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

The block thingy is called Tile based games.

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 Kernel

Medals: 188

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

For tile based games, take a look at Tiled: 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 Devvie

Medals: 2
Projects: 2

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.

Silver Goblet Games' first released product:
Pages: [1]
  ignore  |  Print  

hadezbladez (695 views)
2018-11-16 13:46:03

hadezbladez (342 views)
2018-11-16 13:41:33

hadezbladez (677 views)
2018-11-16 13:35:35

hadezbladez (167 views)
2018-11-16 13:32:03

EgonOlsen (2360 views)
2018-06-10 19:43:48

EgonOlsen (2472 views)
2018-06-10 19:43:44

EgonOlsen (1462 views)
2018-06-10 19:43:20

DesertCoockie (2127 views)
2018-05-13 18:23:11

nelsongames (1902 views)
2018-04-24 18:15:36

nelsongames (2569 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 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‑
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!