WormGame

Also, I’m still saving to home directory since it sounds like the prefs API may be intrusive as well and I’d like to hear what anyone has to say about Orangy Tangs comment.

[quote]Just a general question, but do people generally prefer programs to use the prefs API or files in USER_HOME? I’ve always used USER_HOME since prefs on windows will write into the registry, and for regular java games I find that just rude behaviour.
[/quote]
Interesting point. Coming from a win-NT background, I’ve never trusted HOME directories, because they’ve traditionally had lots of bugs (as you will probably know if you’ve worked somewhere with roaming profiles; last I heard, most [corporate] places using roaming NT/2k desktops hacked their windows distribution to try and workaround some of the problems).

On linux, it really irritates me to see all this crud piling up in my home direcotyr. How would YOU like it if “My Documents” kept filling up with hundreds of random directories you didn’t want, each related to a different game? I believe this was part of why MS came up with the registry in the first place?

Well…the registry does have a “search” feature ;), which works well so long as the app doesn’t deliberately try to HIDE what it’s doing using HEX key names and 5 or 6 copies of the same data, in different places, under different names.

I see what you mean though. More of a problem with regedit having a truly awful interface than anything else. PS did you know that regedit look ups (used to - sure they must have fixed it by now :)) use a straight search, hence why they take so incredibly long? Yuk. Lazy programming :(.

The other question is whether java automatically deletes the registry settings? Obviously it doesn’t at the moment, but with 1.5 and it’s use of add/remove programs for webstart apps, it could theoretically auto-remove any registry data from that app…

Heh, whenever I’ve had a win9x install corrupt itself frequently been because the registry has somehow magically corrupted itself. So I guess theres a certain amount of paranoia on my part.

[quote]On linux, it really irritates me to see all this crud piling up in my home direcotyr. How would YOU like it if “My Documents” kept filling up with hundreds of random directories you didn’t want, each related to a different game?
[/quote]
Yeah, thats my main gripe with USER_HOME. But on the otherhand at least its visible and you can easily clean it up if you know you’ve removed the game/program.

[quote]The other question is whether java automatically deletes the registry settings? Obviously it doesn’t at the moment, but with 1.5 and it’s use of add/remove programs for webstart apps, it could theoretically auto-remove any registry data from that app…
[/quote]
This is what worries me. If I play a bunch of webstart games and each one starts filling it up with all sorts of config, hiscore, replays etc. data its going to get awfully bloated, and short of manually sorting it out (ugh) its just going to sit there.

I have no idea how much of an effect such a hideously bloated registry has on startup times and so on, but it just seems silly to shove all this information in the registry when we’ve got a perfectly good filesystem avalible.

Btw, what does the prefs API use on Linux and Mac? Do they have some equivilent of the registry or is it some other method?

ok, I now get an error after choosing fullscreen or window (previously, the error would appear before clicking on this menu).

Yay score of 12196!!!

For me using files or prefs API is like using text files versus XML. The latter ones are better but people are to frightened to use them generally.

Although the prefs API uses the registry on Windows its not a wrapper for it: You cannot access data outside of a tree that is reserved for Java applications.

Want to delete a game’s configuration quickly? Why bother with the windows registry when someone used Java to access it? As an application developer provide an information like this:
“The application’s configuration is saved in the com/somecorp/someapp node in the user’s tree. If you delete it all application configuration is gone.”

Fine. I start beanshell start and type:


import java.util.prefs.*;<enter>
Preferences.userRoot("com/somecorp/someapp").removeNode();<enter>

Bingo. Thats all and it works on Linux, Mac OS and all other Java flavours too.

new version uploaded with temporary fix (JOptionPane), here is some code so I can hopefully get closer to solving the actual problem…


File hsPath = new File(System.getProperty("user.home") + "/Cyntaks/WormGame/");
      hsFile = new File(System.getProperty("user.home") + "/Cyntaks/WormGame/score.dat");
      if(!hsPath.exists())
      hsPath.mkdirs();
      if(hsFile.exists())
      {
        try 
        {
          DataInputStream dataIn = new DataInputStream(new FileInputStream(hsFile));
          highScore = dataIn.readInt();
        } catch (IOException ex) 
        {
          System.out.println("Error reading personal high score.");
          ex.printStackTrace();
        } 
      }
      else
      {
         try 
         {
          hsFile.createNewFile();
         } catch (IOException ex) 
         {
          ex.printStackTrace();
         } 
      }

hey silentx, did it tell you network available when you got that score? its high enough to be on the list, but I didnt see it there.

By clicking on “No” to tracking my personal high score the previous exceptions do not occur. BUT…

1.Windowed mode - nothing displays, just a blank blank background in a JFrame. :frowning:

  1. Fullscreen mode - game displays menu screen, but i cannot seem to gain any focus on any of the gui elements in the screen. It does not seem to respond to any keyboard or mouse inputs.

Other observations: I had a quick look around my files and found your wormdata.dat file - I opened it up but it was empty - is this the default state if you have not played the game before?

wormdata.dat… hmmm, the only file that my program creates in score.dat. I searched through all my project files for anything wormdata.dat but couldn’t find anything, but if you found the file than I guess I must have called it that at some point… The first problem that you were having is now solved if my guess at what happened is true:

You ran the program and it did not find score.dat so it created the file (empty like you said), and then the program crashed (assuming you ran it in windowed mode the first time), so data was never written to the file. This means the next time you started the program (viewing the webstart log this time) you found that there was an EOFException cause it was trying to read from a file with no data.

I fixed this by having my program write a zero to the file when it is first created, however if the empty file is still there the program will try to read it and crash so you would have to delete it for the program to run.

I deleted my own score.dat file, started the program and exited with alt+f4 and then started it back up (trying to recreate what happened to you) and it appears to be fixed now.

As for the new problem, I’ve been looking through my code to see what could cause the blank black window and once again can’t find anything. The only event listener I have registered is a KeyListener on the JFrame, or JFrame and Canvas if run in windowed mode (the canvas is not used in fullscreen). If running in fullscreen I am adding the listener like this:


device.getFullScreenWindow().addKeyListener(keyHandler);

As far as I know this is the correct way to do it.

my error - i realised that i had written wormdata.dat instead of score.dat. Sorry for any confusion. :-[

Well, I tried the same things with the score.dat file -1) entered a zero and 2) deleted the file. I no longer get the exceptions as you indicate, but still get a blank black screen when running in windowed and no input when running int fullscreen.

Not sure what the error could be. :frowning:

Please let me know when you want me to test any updates.

Working excellently in both full screen and windowed mode. Very enjoyable - and compulsive!

The control and slightly generous collision detection is good - when you die you always feel like it’s your fault. Makes me wanna have just one more go…

thanx much, thats great to hear after the not so great success rate so far :(. Glad someone noticed the collision detection, that was done on purpuse, it didnt feel right when you died just barely skimming the surface.

I finally got around to checking out the new version, and it runs fine now, the super fast movement problem isn’t an issue. Now when I die I feel like the biggest problem was the bobbing and weeving worm hypnotyzed me… to death.

yeah, I think the parallax background combined with the worms movement may have been a bit too much…