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
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.
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.
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.
Oh, sorry for misunderstanding. I have very simple game, and I need to save player coordinates and all images to the database.
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.
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.
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…
- Find a way to put “all” your game data into one single String.
- Have your program read from that String to get the map data and player coordinates.
- Learn Java I/O to save that String into a file.
- Learn Java I/O to load that String from the file.
- 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 :P.
Thanks a lot)