943,923 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 905
  • Java RSS
Jun 3rd, 2008
0

Need suggestions: Update Checking, Score keeping, and Submitting scores online.

Expand Post »
1.) Update Checking.
2.) Score/Record keeping.
3.) Submitting score online.


Update Checking:
Currently, my program connects to a URL and checks if a new version is available. If one is, it simply opens up a dialog saying a new version is out and to go download it...
Is there a way to have it automatically open the path to the newest version in the users browser? Or if it's not too confusing, have it auto download the latest update?


Score/Record keeping:
I can make it save high scores during the single gaming session, but once the game exits and the user opens it back up, all the scores start at 0 again... I'm thinking the easiest way to do this is to have the highest score write to a .txt before exiting and on next run, retrieve the highest score from that .txt file again, that way it's never lost.
My concern with this, is someone cheating and just editing the value in the .txt file and bragging that they finished the game in 3 seconds. Is there a better way to do this?


Submitting scores online:
I know how to retrieve text from a URL, but how can you write to a URL if you don't have write permissions? I know a lot of websites have a "Submit" button which obvious takes in what people fill in and saves it. How can I take that same idea to log players high scores to my website?

Any ideas?
Reputation Points: 72
Solved Threads: 6
Junior Poster
TheWhite is offline Offline
174 posts
since May 2008
Jun 3rd, 2008
0

Re: Need suggestions: Update Checking, Score keeping, and Submitting scores online.

Click to Expand / Collapse  Quote originally posted by TheWhite ...
Update Checking:
Currently, my program connects to a URL and checks if a new version is available. If one is, it simply opens up a dialog saying a new version is out and to go download it...
Is there a way to have it automatically open the path to the newest version in the users browser? Or if it's not too confusing, have it auto download the latest update?
Web Start would certainly handle that. As for your program downloading the update itself, sure, you could download a new version as a stream from a socket. If you want it to auto-update though, the updater will have to run as a separate JVM process since you can't replace your jar file while you are running it.
Quote ...
Score/Record keeping:
I can make it save high scores during the single gaming session, but once the game exits and the user opens it back up, all the scores start at 0 again... I'm thinking the easiest way to do this is to have the highest score write to a .txt before exiting and on next run, retrieve the highest score from that .txt file again, that way it's never lost.
My concern with this, is someone cheating and just editing the value in the .txt file and bragging that they finished the game in 3 seconds. Is there a better way to do this?
You could write the file as binary instead of txt, but really if someone wants to fiddle with it they will. You could encrypt it, but do you really care that much?
Quote ...
Submitting scores online:
I know how to retrieve text from a URL, but how can you write to a URL if you don't have write permissions? I know a lot of websites have a "Submit" button which obvious takes in what people fill in and saves it. How can I take that same idea to log players high scores to my website?
Well, you will probably need to put a script up (php, perl, python, whatever your host allows) to accept and store the scores.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007
Jun 3rd, 2008
0

Re: Need suggestions: Update Checking, Score keeping, and Submitting scores online.

Thanks Ezzaral.. Awesome advice like always

I was hoping for an easier way to do the updater...
I ended up finding the following source code which opens the default browser and specified URL.... Since I already have it set up to check if a new version is available, I can have it point to the main webpage instead so they can download it manually... works perfect..

Here it is if anyone else is interested:

Java Syntax (Toggle Plain Text)
  1. public void openURL(String url) {
  2. String osName = System.getProperty("os.name");
  3. try {
  4. if (osName.startsWith("Mac OS")) {
  5. Class fileMgr = Class.forName("com.apple.eio.FileManager");
  6. Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] {String.class});
  7. openURL.invoke(null, new Object[] {url});
  8. }
  9. else if (osName.startsWith("Windows"))
  10. Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
  11. else {
  12. //assume Unix or Linux
  13. String[] browsers = { "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" };
  14. String browser = null;
  15. for (int count = 0; count < browsers.length && browser == null; count++)
  16. if (Runtime.getRuntime().exec( new String[] {"which", browsers[count]}).waitFor() == 0)
  17. browser = browsers[count];
  18. if (browser == null)
  19. throw new Exception("Could not find web browser");
  20. else Runtime.getRuntime().exec(new String[] {browser, url});
  21. }
  22. }
  23. catch (Exception e) {
  24. JOptionPane.showMessageDialog(null, errMsg + ":\n" + e.getLocalizedMessage());
  25. }
  26. }
Reputation Points: 72
Solved Threads: 6
Junior Poster
TheWhite is offline Offline
174 posts
since May 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: When would one ever use the Method class?
Next Thread in Java Forum Timeline: Java Random Access File... Help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC