Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (115)
games submitted by our members
Games in WIP (562)
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  
  Save/load in java game with Slick2D  (Read 3683 times)
0 Members and 1 Guest are viewing this topic.
Offline JavaBiginner2013

Junior Newbie





« Posted 2013-01-02 12:32:30 »

I've just started with game development, and I have very simple "game", where I need to implement "Save/Load" option. It is should be saved to the database. Could you give some instructions, like what classes should I use? Would be very greatful


Offline P0jahn

Senior Member


Projects: 3



« Reply #1 - Posted 2013-01-02 18:55:18 »

I doubt class exists. How is that nonexistent class suppose to know what to save? How is it suppose to know about the variables your games uses when they did not exist when that nonexistent class was developed?
What you have to do, is that when the Save button is pressed, you save all the stats of the game, the health, the position of all the units etc.
Offline KevinWorkman

JGO Wizard


Medals: 70
Projects: 11
Exp: 12 years


klaatu barada nikto


« Reply #2 - Posted 2013-01-02 19:06:27 »

I don't think LWJGL has an out-of-the-box magic save feature. You're going to have to implement that yourself. Which part of this is giving you trouble?

If you've only just started, you might want to look into simply creating an XML file that you save to the hard drive and then read from to load. You might also look into serialization. Using a database is more complicated and probably overkill if you're just getting started.

Static Void Games - Play indie games, learn game programming, upload your own games!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline PeterNicholson

Senior Member


Medals: 3
Projects: 1



« Reply #3 - Posted 2013-01-02 19:42:01 »

You could try saving the "blocks" of the game in an array, and then write them to a file using the Java API` IO. Then you could have the whole game running on a server, and then have a php script to insert it into a mysql database. Smiley

Subscribe to me on YouTube: http://youtube.com/javaprogrammerguy
Offline JavaBiginner2013

Junior Newbie





« Reply #4 - Posted 2013-01-02 21:10:24 »

Oh, sorry for misunderstanding. I have very simple game, and I need to save player coordinates and all images to the database.
Offline PeterNicholson

Senior Member


Medals: 3
Projects: 1



« Reply #5 - Posted 2013-01-02 21:31:22 »

Well, as I said, you can have the game running on a server (you can use apache web server and turn you computer into a localhost server), then save the gamedata into a file, then process the file with a php script. Then you can crean. Nother php script to insert the data into a mysql database. Or you caan use a xml file. Smiley

Subscribe to me on YouTube: http://youtube.com/javaprogrammerguy
Offline Best Username Ever

Junior Member





« Reply #6 - Posted 2013-01-02 21:45:25 »

Clearly you do not know what your are talking about, don't have much programming experience, and don't know much Java. You are using jargon you don't understand. You do not use a "database" for storing game save files which suggests you don't know what a database is. There are exceptions to the rule, but if you knew well enough to identify those exceptions then you would have already had picked out an API compatible with your chosen database.

Loading and saving data is by far more trivial than any other aspect of game programming. It is just a matter of interpreting or copying raw data and is always game specific. Learn to program. Learn Java. Learn to search the internet. Then start game programming.
Offline ctomni231

JGO Wizard


Medals: 99
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #7 - Posted 2013-01-03 04:47:04 »

All you really need is simple File I/O.

Images, unless they are screenshots, should already be stored to your computer. Something tells me that you are just wondering how to save the map.

The easiest way is to find a way to input all that data into a String. Simple steps my suffice...

1) Find a way to put "all" your game data into one single String.
2) Have your program read from that String to get the map data and player coordinates.
3) Learn Java I/O to save that String into a file.
4) Learn Java I/O to load that String from the file.
5) Congratulations, you can now save and load map data.

Like BUE said, you do not need an online database to save and load data. Just a way to turn your game data into Strings, and then convert them back into code when you need it. Or, you can learn how to do Serialization, but I won't explain that here. Best of luck learning Java, and don't give up Tongue.


Offline JavaBiginner2013

Junior Newbie





« Reply #8 - Posted 2013-01-03 15:06:47 »

Thanks a lot)
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.

radar3301 (11 views)
2014-09-21 23:33:17

BurntPizza (28 views)
2014-09-21 02:42:18

BurntPizza (18 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (27 views)
2014-09-20 20:14:06

BurntPizza (29 views)
2014-09-19 03:14:18

Dwinin (46 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (102 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56
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!