Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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 9293 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 Devvie

Medals: 1
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 Plugged Duke »

Medals: 283
Projects: 12
Exp: 12 years - Coding Tutorials!

« 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. - Coding Tutorials!
Happy Coding forum - Come say hello!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline PeterNicholson

Senior Devvie

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

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
Offline Best Username Ever

Junior Devvie

« 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  

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

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

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

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

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

nelsongames (158 views)
2018-04-24 18:14:32

ivj94 (901 views)
2018-03-24 14:47:39

ivj94 (162 views)
2018-03-24 14:46:31

ivj94 (813 views)
2018-03-24 14:43:53

Solater (177 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!