[java] I need some help.
Well, I''m making a online multiplayer game (not saying any details) but i was wondering if is possible to update it over the internet even though you will have to download my game onto your computer. For example say a person downloads it and starts playing (remember that this is an online multiplayer game) but then i want to add a new item to the game, so can i make it so the game updates and the new item will be in the game and the person can use it?
A person I know says this is impossible, that they will have to redownload a different version of the game that has the item in it. So my question is "can i make it so the game updates and the new item will be in the game and everybody can use it?" because I don''t want people to have to redownload the game everytime I add something new into it.
If im understanding you right, you could just transfer it to them, without them even knowing im guessing. I dont see why theyd have to re-download the entire program. What my group did for a project a ways back was, check a hard-coded version number against the current server one, if it was different, we''d send them the new files, and off theyd go. That way the user didnt have to redownload everything. Hope that helps. o_O
A Java "program" is really just a loose bundling of classes. Java is very dynamic, and downloading new items into a running game is definitely something Java can handle. You''ll need to get to know class loaders, and probably URLClassLoader would do what you need. If not you may need to write your own class loader, which is fairly involved but not too bad. Then with class loader in hand, your game can load new classes whenever it wants, then create objects out of them. Being an online multiplayer game possibly complicates things, but it''s definitely doable.
You would only have to deal with class loaders if you wanted to update the game while it was being played. If you wanted to do a check before the game starts, that would be even easier. Just write a little check program that runs before your game loads any classes. Have it download all the new files, then start the game. The new classes will automatically be picked up.
Your biggest problem would be if your program is in a jar file. You then either have to add the new files to the jar file or download a separate jar and make sure the separate jar is in the classpath ahead of the main jar.
With the second option, you will start having a lot of jar files floating around. With the first option you just have to write a bit of code to add the incoming files to the existing jar. This is not too difficult as the SDK has built in APIs for handling jar/zip files.
First make it work,
then make it fast.
--Brian Kernighan
The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities. We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)
Do not interrupt your enemy when he is making a mistake. - Napolean Bonaparte
Your biggest problem would be if your program is in a jar file. You then either have to add the new files to the jar file or download a separate jar and make sure the separate jar is in the classpath ahead of the main jar.
With the second option, you will start having a lot of jar files floating around. With the first option you just have to write a bit of code to add the incoming files to the existing jar. This is not too difficult as the SDK has built in APIs for handling jar/zip files.
First make it work,
then make it fast.
--Brian Kernighan
The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities. We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)
Do not interrupt your enemy when he is making a mistake. - Napolean Bonaparte
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement