Bunny Golf

Well, I’m impressed at your hole-in-one, even if the game isn’t. ;D

Actually, I thought I’d changed the levels so that holes-in-one are impossible - but apparently not. They probably should be impossible in two-player mode, but you’re right that they need some kind of acknowledgement in one-player mode.

Cheers,
Simon

Holes in one should be possible in 2 player mode; there’s nothing wrong with it!

Update: new, improved grass.

I might add that this isn’t Bunny Golf, it’s Bunny Midget Golf :wink:

I’d heard of Mini Golf and Crazy Golf… but Midget Golf sounded like the product of a cruel and twisted mind until Wikipedia told me that it was just another name for the same thing. :wink:

Yes, you’re right. It’s Bunny Mini/Crazy/Midget Golf without the novelty obstacles (at least for now).

Simon

Thinking about it, someone really should make a game called “Crazy Midget Minigolf”. A title like that is too good to waste!

The varying levels of grass really adds depth to the game, but the friction needs to be calibrated a bit. It removes the skill part and makes your progression much more based on the luck of where you are placed since you only regain a small amount of lives after each stage and some placements will require more moves than others.

EDIT: still addictive, but more from the frustration value :slight_smile:

Okay, I’ve figured out what it’s all about now! Every arrangement can be solved in two moves … interesting thought!

Hi, keldon. Thanks for the comments!

Pretty much every update to the game has reduced the friction of the rough grass. The friction needs to be reasonably high though for the rough grass to act as barrier – but new players always seem surprised by how rough it is. Playing Tip: AVOID THE ROUGH GRASS! Maybe if I replaced the rough grass with pools of magma people would get the idea. ;D

Yes, that’s the way the (one-player) game has ended up. The levels have been carefully designed so that you can always get in the hole in two shots (or moves, or hops), and your number of lives doesn’t reduce provided that you don’t take more than two shots per hole. Run out of lives and the game ends, of course.

I thought at first about giving the game the same rules as golf, with a final score compared with par after nine or eighteen holes… but I suspect that a lot of people would lose interest before completing that number of holes. :frowning:

I’m all ears if anyone has better suggestions for how the game should be played!

Simon

Update: The final version! http://www.dishmoth.com/BunnyGolf.html

At least, it’s the final version unless you guys think otherwise! ;D

(In particular, I’ve only been able to check the full-screen mode on some older versions of Windows, so any feedback on how well that works would be welcome.)

Cheers,
Simon

I have tested your game. There are 2 problems :

  • I have no sound, it doesn’t come from my configuration as my own game works and uses sound too
  • the fullscreen mode doesn’t work on my computer, I get a completely gray window
    I have no trace of exception in the log or in the console. I’m ready to test it again if you need some help. My computer works under Mandriva Linux 2007, my web browser is firefox, my graphics card is an ATI Radeon 9250 Pro, I have 2 GB DDRAM, I use KDE window manager. Please tell me how you implemented your fullscreen mode. It is really simple, you only have to create an undecorated window as tall as the screen size. I don’t know where the problem of sound comes, I use JOGG and JORBIS, I have no problem.

Your game is quite pleasant in spite of these bugs. Good luck and using Java Web Start is an excellent idea. ;D

Hi, gouessej! Thanks for testing the game. I’d be very grateful for any further testing you could do to help me get rid of those bugs.

To test the sound, I’ve uploaded a new version of the JAR in which one of the sound effects is loaded from a WAV rather than an OGG file. If you hear a sound when the mouse pointer moves over one of the buttons on the title screen, then I’m playing WAV files correctly and it’s the OGG files that are the problem.

I’m loading the sound effects into Clip objects and playing them with

  clip.stop();
  clip.flush();
  clip.setFramePosition(0);
  clip.start();

For WAV files, the code to load them is

  AudioInputStream audioStream = AudioSystem.getAudioInputStream(url);
  clip = AudioSystem.getClip();
  clip.open(audioStream);
  audioStream.close();

For OGG files, I’m using Jorbis to read the file as PCM data, and then creating a Clip in the following way:

  private Clip newClip(int    sampleRate, 
                       int    numChannels,
                       byte[] pcmBytes) throws IOException {

    int     bitsPerSample = 16;
    boolean isSigned      = true,
            isBigEndian   = false;
    AudioFormat format = new AudioFormat((float)sampleRate, bitsPerSample,
                                         numChannels, isSigned, isBigEndian);

    Clip clip = null;
    try {
      clip = AudioSystem.getClip();
      clip.open(format, pcmBytes, 0, pcmBytes.length);
    } catch ( Exception ex ) {
      throw new IOException("failure during creation of Clip (" + ex + ")");
    }
  
    return clip;
    
  }

The console output may say if there’s a problem decoding the OGG files. Could you download the JAR file and run it using the following command?

java -enableassertions -jar BunnyGolf.jar debug

The console output should then include a few lines of info for each OGG file that is loaded. For example, the last block of OGG output should look like:

Decoding Ogg Vorbis bitstream 
Bitstream is 1 channel, 44100Hz 
Encoded by: Xiph.Org libVorbis I 20020717 
Constructing clip, 20096 bytes of PCM data 

That’s all I can think of for now for debugging the sound.

As for full-screen mode, the code looks something like the following.

public class MainWindow extends JFrame {

  ...

  GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
  if ( device.isFullScreenSupported() ) {
    device.setFullScreenWindow((Window)this);
    mIsFullScreen = true;
  }

  ...

  if ( mIsFullScreen ) {
    createBufferStrategy(2);
    mBufferStrategy = getBufferStrategy();
  } else {
    mGameCanvas.createBufferStrategy(2);
    mBufferStrategy = mGameCanvas.getBufferStrategy();
  }

  ...

}

Can you see any problem with that? The code in full is a bit convoluted (spread between several classes) so I’ll hold off posting it for the timebeing. I’m going to hunt around for some more examples of full-screen mode being used to see if those show me where I’m going wrong.

Thanks again for your help.
Simon

After catching up on a bit of reading (here, here, here) I’ve tried modifying the code so that it only switches to full-screen mode on an undecorated Frame (rather than a decorated JFrame).

Let’s see if that helps any.

I tried to launch your JAR and again your game through Java Web Start:

  • still no wound (javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 44100.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian not supported.)
  • the window is as tall as the screen but it remains gray and the taskbar is drawn onto your window

Please do something like this:

public final class GameView extends Frame {

setLocation(0,0);//sets the window at the topleft corner
setUndecorated(true);//makes the decoration disappear
setIgnoreRepaint(true);//prevents the system from calling repaint automatically
//gets the size of the screen
screenWidth=(int)Toolkit.getDefaultToolkit().getScreenSize().getWidth();
screenHeight=(int)Toolkit.getDefaultToolkit().getScreenSize().getHeight();
setSize(screenWidth,screenHeight);
//bug fix : under Linux, sometimes the window was drawn below the taskbar
setResizable(true);

setVisible(true);

This was an extract from my source code, feel free to use it, it is under GPL license version 2. I use JORBIS too, look at main.SoundSystem in my source code.

I’m guessing that the problem with the sound is that on some platforms the number of source lines into a Mixer is restricted. That could be what’s triggering the LineUnavailableException when I try to open 50 Clips at the start of game. I’ve adjusted the code now so that it reads in all the PCM data for the sound effects right at the start, but only creates a Clip object when it’s time to play an effect. It also discards each Clip when it’s finished playing so that there are never too many active lines to the Mixer at any time. Hopefully that will fix the problem.

I’ve also tried adjusting the full screen code a bit, but I’m not optimistic about it having improved anything. I believe I’m doing everything you suggest, and everything that’s described in Sun’s FSEM tutorial, so I don’t really know what else to try.

If you could try the game again and see if it’s working better now I’d appreciate it.

Cheers,
Simon

One good point : I heard something just at the beginning of the game, a short noise.

But I had an exception and the screen remains gray:
Exception in thread “Thread-6” java.util.NoSuchElementException
at java.util.LinkedList.remove(LinkedList.java:788)
at java.util.LinkedList.removeFirst(LinkedList.java:134)
at BunnyGolf.SoundEffect.play(SoundEffect.java:115)
at BunnyGolf.Sounds.playGrabMeSound(Sounds.java:317)
at BunnyGolf.Button.aftermath(Button.java:163)
at BunnyGolf.SpriteManager.advance(SpriteManager.java:156)
at BunnyGolf.GameManager.advance(GameManager.java:62)
at BunnyGolf.MainWindow.run(MainWindow.java:302)
at java.lang.Thread.run(Thread.java:619)

Don’t give up, I’m sure it is only a very small problem. Don’t forget to authorize your window to be resized to solve the problem of the taskbar drawn onto your game. A bug is not the end of a game. If you’re not convinced, look at the list of the known bugs of my game.

Oops! Silly bug was causing the exception. Fixed now, I hope.

I think the default Sound Mixer on your system must really hate playing Clip objects! I’ve changed the code to hunt for a better Mixer when it starts up. I’d be interested to know what it finds – if you run the JAR from the command line as you did before (java -jar BunnyGolf.jar debug) so that it produces console output, then it should list at the start all of the Mixers it finds, and how many Clips each claims to support. The output for me is:

Default Sound Mixer: Primary Sound Driver, version Unknown Version, max lines unrestricted 
Sound Mixer 0: Primary Sound Driver, version Unknown Version, max lines unrestricted 
Sound Mixer 1: ESS Maestro, version Unknown Version, max lines unrestricted 
Sound Mixer 4: Java Sound Audio Engine, version 1.0, max lines 32 
Using Sound Mixer: Primary Sound Driver, version Unknown Version, max lines unrestricted

I’m guessing that your default Mixer will have max lines as a relatively small number.

Let’s see if the sound works now at least!

Cheers,
Simon

My system loves playing clip objects as it already works fine for my own game. Look at this:

Default Sound Mixer: V8237 [plughw:0,0], version 1.0.12, max lines 4
Sound Mixer 0: V8237 [plughw:0,0], version 1.0.12, max lines 4
Sound Mixer 1: V8237 [plughw:0,1], version 1.0.12, max lines 1
Sound Mixer 2: Java Sound Audio Engine, version 1.0, max lines 32
Using Sound Mixer: Java Sound Audio Engine, version 1.0, max lines 32

The sound works fine. ;D

The fullscreen mode doesn’t work, it is still grey BUT the taskbar is no more drawn onto your window ;D!! You’re close to your aim.
Resize: window (tile 35) -> full screen (width 1280, height 960, tile 40)

Ah, the “max lines 4” bit must be what was causing me the problems. In the old code, when I opened 50 Clips during start up, it was probably throwing an exception after the fourth Clip. Now that I’m searching for the “best” Mixer (“Java Sound Audio Engine” in your case) rather than the default, and not opening the Clips all at once, I guess it’s a lot happier.

Have you noticed sound problems with other games, or is no one else stupid enough to try using Clips in the same way I was doing?

Excellent! I can sleep at nights again now. ;D
Thanks for your patience with all of the testing.

I’ve put a few more lines into the full-screen code, but I’m not confident they’ll change anything. If the window appears over the taskbar, then I guess that FSEM is triggering. But if the window is grey then it sounds like the BufferStrategy on the Frame isn’t working for some reason. Hmm. Please give the full-screen mode one last try, and if it doesn’t work I may have to conclude that it’s a Windows-only feature, at least until I have some new ideas.

Thanks,
Simon

THE FULL-SCREEN MODE IS NOT A WINDOWS-ONLY FEATURE!!!

The full-screen mode works fine in my own game under Windows, Mac AND Linux and I don’t use setFullScreenWindow(Window w) because it works fine only with Java 1.6 and the benefit under Linux is null because our window managers are clever enough to decide alone to put a window into exclusive full screen mode (under KDE as far as I know) if it occupied all the screen. I advised you to look at my source code that works under several operating systems in order to accelerate your search. On my view, detect the operating system in your code; if it is not Windows, apply only the fake method (an undecorated frame as tall as the screen), otherwise apply your current method. Java is cross platform. If you don’t succeed in getting the same correct behavior on all operating systems, it is a serious problem. Don’t conclude that the full-screen mode doesn’t work under Linux in Java whereas it doesn’t work especially in your game.

N.B : the sound works still fine but it is still grey. The method isFullScreenSupported() often returns true in Java under Linux whereas it is not required to use setFullScreenWindow.