MorePong

Thats good. Just have to find a way to determine whether the OS is Linux…
Just a moment…

String os = System.getProperty("os.name").toLowerCase();

Using this, but the Strings for all the OSs…
What are yours?

sweet i got 12 points

Should work:


public enum OS {
      Windows, Mac, Unix, Solaris;
}

public OS detectOS() {
      String os = System.getProperty("os.name").toLowerCase();

      if(os.indexOf("win") >= 0) return OS.Windows;
      if(os.indexOf("mac") >= 0) return OS.Mac;
      if(os.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 ) return OS.Unix;
      if(os.indexOf("sunos") >= 0) return OS.Solaris;
}

Adapted from http://www.mkyong.com/java/how-to-detect-os-in-java-systemgetpropertyosname/

Ok, changed the determination to this method.
Does it work?

Tried download again, nope still doesn’t work.

Is there any error log?

@Drenius, you should add some print statements or something to Project.loadNatives() so that people can see if their os was even detected.

Well, it should print “Unable to load native libraries: Operating System not supportet or not recognized” if not…
Uploading another new version printing which OS was detected.

Does it run now or what does it print in?

In Linux Mint 14 VM:

$ java -jar MorePong.jar
Detecting Linux OS
Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1856)
        at java.lang.Runtime.loadLibrary0(Runtime.java:845)
        at java.lang.System.loadLibrary(System.java:1084)
        at org.lwjgl.Sys$1.run(Sys.java:73)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
        at org.lwjgl.Sys.loadLibrary(Sys.java:95)
        at org.lwjgl.Sys.<clinit>(Sys.java:112)
        at org.lwjgl.openal.AL.<clinit>(AL.java:59)
        at projectmanager.audio.Audio.create(Audio.java:27)
        at projectmanager.Project.load(Project.java:246)
        at morepong.Main.<init>(Main.java:24)
        at morepong.Main.main(Main.java:16)

You’ll find plenty on StackOverflow if you google “no lwjgl in java.library.path”

I see that you silently catch some exceptions, perhaps some of these would be helpful.

Well it seems like it does not extract the natives correctly or it does not change the library path… Will have to look at this some more.
I’m sorry for this, this is the first published game made with my little lib/framework/engine/… so there are of course still some bugs…
@Danny02: Really need to improve error checking and add doc and all that… Just got it to the point it should have worked.

Update:
Should now finally work on Linux too! Simply making sure folder paths end with path seperators did the trick…
Also changed the look of the 3 and 4 player mode score bar and reorganized some internal stuff.

yep works now^^

Thats good, thanks for testing!
Does anybody have any suggestions?

Sometimes balls moves very fast or slow. When a ball come with speed of lightning it is impossible to catch when paddle is so slow. Is this feature intentional? If my memory serves me right, in the original Pong the ball speed was constant.

The game area could be a little larger, imho. May improve the gameplay.

You are supposed not to be able to get every ball but have to choose wisly where you move instead. They are also supposed to have different velocities, but with a limit.
Those fast balls are a bug. Will try to fix that now…

You could just check each ball every frame (or only during collisions) and cap the velocity, no? It’s kind of a hack, but if you can’t figure it out or simply can’t make the physics accurate enough, it should be fine.

Every ball has a vec2f for velocity and another one for position. I use a little function that adds either the directional velocity for x/y, or, if one is higher than LIMIT, LIMIT instead of it (GLSL min()…);
Now it checks each velocity of each ball every frame and it seems to do what it is supposed to.

Writing this I realised that I should use LIMIT for x+y velocity instead of seperating them…