Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (108)
games submitted by our members
Games in WIP (536)
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  
  How do you load and setup your levels/menus?  (Read 182 times)
0 Members and 1 Guest are viewing this topic.
Offline tyeeeee1
« Posted 2014-05-15 05:14:35 »

Hey,

I've been trying to think of a good, and simple, way to load all the information (data  in text files, sprites, etc...) and setup levels/menus for my game. So-far I've managed to write up a few different methods for to load all of the files and then convert those files into Entities, interface pieces, etc... Although all of the ways I've tried do end up working to some degree, the code is an utter train-wreck compared to how nice and neat the rest of my code is. It'd probably be easier if I wanted to code more of the data and that in, but I'm trying to set it up so that you just need to have the right folder structure and files to load anything into the game.

Since it wont hurt to ask, how do you load your levels, menus, and whatever else?

Offline Cero
« Reply #1 - Posted 2014-05-15 05:22:37 »

well menus are hardcoded - what do you load ?

as for maps I just developed a map editor which serializes using kryo the map and can load it again.
Never that simple but yeah. short answer is write a parser or use serialization.

what exactly are you saving/loading ?

Offline trollwarrior1
« Reply #2 - Posted 2014-05-15 06:47:23 »

There is no simple way.

The best way to make UI I know of, is something like that:
- Make a graphical UI system yourself for you game (Like GWT / Swing). That would need to contain things like buttons, images, labels, scroll things and anything else you need;
- Now you need to use format like JSON or XML to load your menu data from these formats. I think JSON is much better for readability purposes. After you parse JSON file, you need to load each node into your UI system;
- Now that your UI system contains elements which were described in JSON, you can edit those elements to your liking in code, after they are loaded;

Again, there is no simple way to make menus. It depends on the complexity of the menus you want to achieve. The more complex the menu you want, the more messy the code will be.. That's like a fact for me at least.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline tyeeeee1
« Reply #3 - Posted 2014-05-15 06:58:10 »

well menus are hardcoded - what do you load ?

as for maps I just developed a map editor which serializes using kryo the map and can load it again.
Never that simple but yeah. short answer is write a parser or use serialization.

what exactly are you saving/loading ?

I wrote a simple framework for custom interface components. As a simple example... When creating a button I need to load the X/Y coordinates of the button along with three sprites for the default, clicked, and hovered states of the button. The same thing applies to all tiles, NPCs, etc... in the game. To make it really simple. Almost nothing is hard-coded with the way I have it set up. A few things will probably have to be hard-coded eventually, but everything is just "load-n-go" atm.

Your serialization idea sounds like a simple solution even though it would require a fair bit of extra work to setup at first. Thanks, I'll look into it.
Pages: [1]
  ignore  |  Print  
 
 

 

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

The first screenshot will be displayed as a thumbnail.

CogWheelz (16 views)
2014-07-30 21:08:39

Riven (22 views)
2014-07-29 18:09:19

Riven (14 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (32 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!