Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
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 creator  (Read 2615 times)
0 Members and 1 Guest are viewing this topic.
Offline cubemaster21
« Posted 2012-05-24 10:56:47 »

I've recently begun on a new game called "Waffleocolypse". I have the character, platforms, coins to collect, and one enemy. I would like to make a level creator, but I don't know where to start. I also need a method of saving that world to some sort of format that can be read by the game in order to play it. Does anyone have any experience in this that can help?

Check out my game, Viking Supermarket Smash
http://www.java-gaming.org/topics/iconified/28984/view.html
Offline Giovanni

Junior Devvie




chop!


« Reply #1 - Posted 2012-05-24 12:25:11 »

I suppose that you are talking about a 2D game. You could either use Tiled, a tile based 2D editor, or just save and load the levels from plain text files. I have never used Tiled so I can't tell you how it works. However, for the text files you might represent every entity of your game with a number, e.g.: 0 = character, 1 = coin etc.

You should google a little bit for parsing text files in Java.
Offline krasse
« Reply #2 - Posted 2012-05-24 12:31:56 »

I have used Tiled and I strongly recommend it for tile-based games. It also supports polygons, but it is not as well developed in that area (yet?).

Tiled can save levels in both XML and JSON.

Good luck!

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

Junior Devvie


Medals: 2
Projects: 1



« Reply #3 - Posted 2012-05-24 17:16:13 »

I have used Tiled and I strongly recommend it for tile-based games. It also supports polygons, but it is not as well developed in that area (yet?).

Tiled can save levels in both XML and JSON.

Good luck!

Also, if you use the Slick2D library (as I do) then there's a class that automatically loads a tiled map from the Tiled program. There's a very useful Camera class that's on the Slick2D forum which really needs to be in the core Slick2D code.  That camera class scrolls around the Tiled map object.

As far as saving data here's one way:
Create a level configuration class which holds all the level data.  It has nothing to do with how the level works, it's only a list of objects on the level and the tiled background which the level should use.  Create and fill that class and then marshal it to XML using Jaxb. Inside your game just get the XML filename and marshal it back form XML to Java and it will automatically create and fill your level configuration class.

There are many ways to do this.  You could also use Java Serialization.  With Serialization every time you change the format of the class you're saving the old serialized file will no longer work.  So be aware of that.  It's easier than Jaxb, but as things change serialization can be frustrating because you have to re-save your level to get the new serialization file.
Offline cubemaster21
« Reply #4 - Posted 2012-05-24 19:31:58 »

The problem is that I'm not using tile based.... It's side scroller...

Check out my game, Viking Supermarket Smash
http://www.java-gaming.org/topics/iconified/28984/view.html
Offline krasse
« Reply #5 - Posted 2012-05-24 20:37:16 »

The problem is that I'm not using tile based.... It's side scroller...

So you can not represent the level with tiles or is the problem something else?

What are you planning to use for representation? Polygons? Pixels?

I can not really recommend Tiled for polygons. I tried to use it for this game but it is lacking a lot of useful features for polygon manipulation.

Offline cubemaster21
« Reply #6 - Posted 2012-05-24 21:33:31 »

The problem is that I'm not using tile based.... It's side scroller...

So you can not represent the level with tiles or is the problem something else?

What are you planning to use for representation? Polygons? Pixels?

I can not really recommend Tiled for polygons. I tried to use it for this game but it is lacking a lot of useful features for polygon manipulation.
I was planning on using sprites to represent it. The problem would be creating a system that stores ArrayLists to a sort of file that I can reopen with the game and parse out the List.

Check out my game, Viking Supermarket Smash
http://www.java-gaming.org/topics/iconified/28984/view.html
Offline Tom-Todd

Senior Newbie





« Reply #7 - Posted 2012-05-24 21:37:54 »

I'm making a sidescrolling platformer, which is what I gather you're making, a tile map, should be fine for doing a sidescroller, it's what Im using, plus its easy to do everything can be stored in a 2 dimensional array.
Offline krasse
« Reply #8 - Posted 2012-05-25 07:03:18 »

So by "sprites" you maybe mean positioned rectangles, maybe rotated/scaled etc.?

Tiled is pretty good for custom rectangles, but if you want them scaled or rotated with a custom pivot point, I would use something else Smiley. Its probably OK if you just have an angle property and that the pivot point is always in the center.

Here is an example of a (JSON) Tiled level that uses positioned rects and polygons
It represents the first level in that game I referred to earlier.

Here are some more examples: Gui components, Icons, A ship, Font!

Offline matheus23

JGO Kernel


Medals: 114
Projects: 3


You think about my Avatar right now!


« Reply #9 - Posted 2012-05-25 15:11:20 »

So by "sprites" you maybe mean positioned rectangles, maybe rotated/scaled etc.?

Tiled is pretty good for custom rectangles, but if you want them scaled or rotated with a custom pivot point, I would use something else Smiley. Its probably OK if you just have an angle property and that the pivot point is always in the center.

Here is an example of a (JSON) Tiled level that uses positioned rects and polygons
It represents the first level in that game I referred to earlier.

Here are some more examples: Gui components, Icons, A ship, Font!

I'm just intrested... How do you acctually use JSON files?

They are simple... Do you need to write a parser yourself, or are there libs in the Java SE? I really like them...

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline sproingie

JGO Kernel


Medals: 202



« Reply #10 - Posted 2012-05-25 16:28:56 »

You use a third party JSON parser, and there's more of those than you can shake a stick at.  Two really good ones to get you started:

https://github.com/rzwitserloot/com.zwitserloot.json

http://jackson.codehaus.org/


Offline matheus23

JGO Kernel


Medals: 114
Projects: 3


You think about my Avatar right now!


« Reply #11 - Posted 2012-05-25 16:34:45 »

You use a third party JSON parser, and there's more of those than you can shake a stick at.  Two really good ones to get you started:

https://github.com/rzwitserloot/com.zwitserloot.json

http://jackson.codehaus.org/

That README from the first one looked really impressive...
totally offtopic: Why the heck use XML? Parsing XML is much slower, than parsing JSON, I'm sure!

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline sproingie

JGO Kernel


Medals: 202



« Reply #12 - Posted 2012-05-25 16:42:42 »

There are a few reasons some data formats choose XML:

  • It can have comments
  • Deep nesting has more visual cues (no counting curly braces)
  • It's easier to put nearly arbitrary text in CDATA sections
  • Entities give you a sort of primitive #define-ish macro system built in
  • There's a lot of tools for querying (DOM, xpath, xquery), validating (xsd, rng), and transforming (xinclude, xslt)


What's nice about Jackson and XStream is that you can use the same API for both XML and JSON.  
Offline krasse
« Reply #13 - Posted 2012-05-25 17:25:52 »

I would have used XML if I didn't create the game in Javascript. I use XML for everything else if I get the chance.

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.

rwatson462 (33 views)
2014-12-15 09:26:44

Mr.CodeIt (23 views)
2014-12-14 19:50:38

BurntPizza (51 views)
2014-12-09 22:41:13

BurntPizza (84 views)
2014-12-08 04:46:31

JscottyBieshaar (45 views)
2014-12-05 12:39:02

SHC (59 views)
2014-12-03 16:27:13

CopyableCougar4 (60 views)
2014-11-29 21:32:03

toopeicgaming1999 (123 views)
2014-11-26 15:22:04

toopeicgaming1999 (114 views)
2014-11-26 15:20:36

toopeicgaming1999 (32 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!