Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2
1  Games Center / 4K Game Competition - 2014 / Re: Bianc4Kastafiore on: 2013-12-16 15:30:52
I want to build a game with sound input

Unfortunately, unsigned applets don't have permission to record audio.  This is by design, as it would allow for eavesdropping on the user.  Described on the bottom of this page.
2  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-12-02 16:06:04
I once considered to join the 4k contest, but had to realize that it requires very specific skills and methods to produce such compact code which still does something sensible, and I don't have those - and I wasn't willing to sacrifice my coding habits just to squeeze some function into 4k bytecode.

So for me it already was a pretty closed contest for those who are like the old assembly wizards from the demo scene who made other people just "wow - I had no idea that this can even be done".

That issue gets raised a lot, but a while back Groboclown put together a good set of ANT scripts that you can use (quoted post below.)  I don't know how much it has changed in the past two years, but when I used it it all I had to do was put in the paths to some tools I downloaded like proguard and kzip, and then I just used Eclipse to run the script.  Doesn't get much easier than 1-click compression!

If you look at the source for many of the games on java4k.com, the fully commented well-laid out code is what was fed in to the ANT scripts, and they spit out an obfuscated, maximum compression 4k jar at the other end. Smiley  My two games had a main game loop, but separate methods for drawing the splash screen, handling menu actions, drawing sprites, and loading and playing music.  There's a bit of trade-off between OO design and minimized byte code, for example my use of a method to draw sprites instead of delegating that to a separate Sprite object that decides how to draw itself.  Along with that decision, I used 2d int arrays to keep track of my sprites and their attributes, rather than introduce another object definition.  But you can do things like define as many constants as you want (to avoid remembering the purpose of a magic number), since proguard will replace them with the values in your code.

Groboclown put together a great set of ANT scripts two years ago.  It's what I used for the 2012 competition.  It does proguard, packing, gzip, etc, even with different block sizes.  I think I had to get proguard and a 7zip separately and configure the script with their locations, but having that toolkit does lower the entry bar significantly.
Thanks for the reference.  I'm now maintaining this over in my sourceforge project: http://sourceforge.net/p/groboutils/java4k/ci/default/tree/
3  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-11-28 17:51:32
Grobo and Apo have both offered to help merge the work I've done with the project on pikacode; thank you to both of you.  For now I've simply zipped the source from my old project and put it in my public dropbox.  Grobo's got a lot of good security set up in his project that would be great to keep, as well as user-friendly error messages and things like that.  I've spent some time this lunch-hour cleaning up some bugs in my old project before posting the zip, and as far as I've tested the code I've posted correctly plays all apps from last year's competition (uncompressed, pack200 and pack200+gzip.)  I haven't pushed any further changes to the pikacode project since my changes are only partly complete, and also for some reasons listed below.

The problems I ran into when trying to put some of my work into what Groboclown has already done:
  • The use of launcher.dir in the policy file caused me some grief initially, and specifying the jar in the codebase means it can't be run directly from the Run menu in Eclipse (you have to build the jar first.)  Maybe we can just grant the higher permissions to all code on the classpath instead?
  • I can't actually see the running applets when running the code I pulled from pikacode - I get messages stating the applet started fine, but nothing is visible.  I've run in debug, and it looks like the applet is added, then pack and validate are called.  I don't know what's going wrong, unless there's a missing call to setVisible somewhere?
  • My code takes 5 or 6 seconds to download and start a game, and I expect Grobo's does as well (similar loading strategy), so if we stick with this strategy then a progress bar or message should be added.  An alternative is to pull all jars down right away on startup, but then we'd have to be careful of conflicts, e.g. two games with the same jar name.  (I'm sure A.jar is probably quite popular!) Renaming the jars when downloading would probably solve that.
  • In my code I'm using the system property java.io.tmpdir for temp files, I recommend we do that instead of storing them anywhere else (such as the launcher's directory.)  However when I changed the code in Grobo's PrivilegedActions.createTempJarFile(), the app gave me permission denied errors.  No idea why Sad
  • My code to get the list of games and the game details is quite a bit simpler than what's currently in the pikacode repository.  Groboclown may have made changes in the meantime, but if not might I suggest plugging in my code or something that reads a feed (if appel can get one set up.)  The code that's in the pikacode repository is certainly more robust than what I wrote, since it fully parses the HTML and then navigates the elements, so I understand if you decide to stick with it.  It just seemed a lot harder to understand than what I did with a few regex (though that might be because I wrote it - easier for an author to understand his own code?)
  • It looks like Groboclown's code runs the applets in a separate thread.  Is that necessary?  Is it for some security concerns, or something else?
  • My code in Java4KLauncher.java includes event handlers to stop, start and unload the current applet on minimizing, restoring and closing the application.  I didn't see anything similar in the pikacode, though I may have missed it (sorry if I did.) I see it now, it's in GamePanel.

Again, thanks for any and all help.
4  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-11-27 14:11:31
Launcher looks neat. I'd like to try it out.

I could provide for a JSON service to retrieve list of games and any information to make it easier to display and run games.
Thanks appel, that would help make it more robust.  Right now I'm doing a simple regex parse of the HTML from the contest listing, but getting the values from a service or even an RSS feed would future-proof against changes to the HTML.  Here's the method, you can see how it relies on the page structure and CSS classes, so any significant changes to those would break it:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
   public static List<AppletConfig> getContestAppletConfigs(URL contestUrl) throws IOException {
      String regexGameUrl = "<tr>\\s*<td>\\s*<a\\s+href=\"(.*?gid=(\\d+))";
      String regexScreenshotUtl = "
<img src=\"(.*?)\"";
      String regexGameTitle = "
<td class=\"gametitle\"><a.*?>(.*?)</a>";
      String regexGameAuthor = "
<td class=\"gameauthor\"><a.*?>(.*?)</a>";
      String regexGameDownloads = "
<td class=\"gamedownloads\">(.*?)</td>";
      //String regexGameSubmitted = "
<td class=\"gamedownloads\">(.*?)</td>";
      String regexGameDescription = "
<td class=\"gamedescription\">(.*?)</td>";
     
      ArrayList<AppletConfig> applets = new ArrayList<>();
     
      String html = getHTML(contestUrl);
     
      if (html != null) {
         Matcher matcher = Pattern.compile(regexGameUrl + "
.*?" + regexScreenshotUtl + ".*?" + regexGameTitle + ".*?" + regexGameAuthor + ".*?" + regexGameDownloads + ".*?" + regexGameDescription).matcher(html);
         while (matcher.find()) {
            AppletConfig config = new AppletConfig();
            config.setGameUrl(JAVA4K_URL + "
/" + matcher.group(1));
            config.setJarPath(JAVA4K_URL + "
/applet.php?gid=" + matcher.group(2));
            config.setScreenshotUrl(JAVA4K_URL + "
/" + matcher.group(3));
            config.setName(matcher.group(4));
            config.setAuthor(matcher.group(5));
            config.setDownloads(Integer.parseInt(matcher.group(6)));
            config.setDescription(matcher.group(7));
            applets.add(config);
         }
      }
     
      return applets;
   }


A Service for the game-list informaion yould be great.
especially the information about the main class and target screen dimensions, as was defined in the applet definition:

<applet code="A.class" archive="applet.php?gid=431" width="600" height="600">
That would definitely help, as right now I need to hit the game page to get the name of the Main class, the width and the height.  It costs an extra few seconds, on top of pulling and loading the jar.

I'm having a few issues merging what I had already done with Groboclown's project, so it will be a bit until I can commit it there.  For the time being, you're welcome to run a bleeding edge build from my dropbox.  Once we get grobo's to the same point, I'll start committing a built jar to that project for anyone to download.
5  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-11-26 21:42:40
Another screenshot below, at another size, with a game running.

Also, it takes ages to load all the game screenshots into ImageIcon objects, even if I do them all in parallel.  I'm thinking of just showing the title, putting the description in a tooltip, and showing a progress bar as the icons load (popping them up in the list as the Futures return.)  Any other ideas for the icons?

6  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-11-26 17:35:59
Well, the launcher is more like infrastructure, it's not part of the contest.  It's like a helper for the java4k.com website (which is PHP by the way), not a 4K entry.  And it doesn't supply any extra libraries or anything like that to the contest entries.  Think of it like a custom web browser, that only points to the Java4K.com games.  So you can turn off applets in your browsers, but if you want to browse and run the Java4K games, you still can.

The challenge is to code to an existing infrastructure.  A loader really is pointless for the following reason: Anyone can prove that they wrote a 4K entry by generating a pack200 jar no bigger than 4096 bytes.  Once that proof is submitted, you can run it directly from an uncompressed jar.  No loader is needed to play the game.  

If we move to a deployment model where the player launches the game from the command-line, then we probably have to drop pack200 unless someone discovers a way through existing options to get it to run.
Well, the problems loader solves are:
  • People disabling applets in browsers.
  • Unsigned applets not running in web browsers due to upcoming security updates.
  • A simple method of discovering and playing the games.
I'm not 100% clear on what you're suggesting regarding compressed and uncompressed jars, and running from the command line.  If you're suggesting that people playing the games should download an uncompressed version of the jar and run it from the command line, I think you'll find that is too cumbersome for most people.

I might be misinterpreting your post, in which case please clarify, but it seemed like you thought the launcher is a command line tool to run games individually, or some sort of wrapper around each game?  It isn't - instead, it's a listing of all the games (pulled real-time from the java4k.com website), and selecting a game from the list pulls the jar (in uncompressed, Pack200, gz, or pack200+gz), and loads the game into the frame.  I'm trying a few different UI styles, here's what I was looking at Sunday night (I haven't pulled the game icons yet, so I've set the JList to render the title and description.)  Selecting a game loads it into the right side of the split pane.
7  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-11-26 16:10:14
I'm all for downloading a binary and running it locally, but it must be executable through some command-line option.
At this point, the launcher is a self-contained jar.  So a single file that you download, which on Windows systems will run automatically if you double-click it (assuming you have Java installed. Wink)  On *nix I guess you need to still do "java -jar launcher.jar", not sure about Macs.  By keeping it pure Java it should work on all OSs that have full standard JVMs.  (Probably not on Blackberry or Andriod systems, due to differences in the JVMs and libraries.)

Any extra component that does not come with an out of the box JRE breaks the spirit of the Java 4K Contest.
Well, the launcher is more like infrastructure, it's not part of the contest.  It's like a helper for the java4k.com website (which is PHP by the way), not a 4K entry.  And it doesn't supply any extra libraries or anything like that to the contest entries.  Think of it like a custom web browser, that only points to the Java4K.com games.  So you can turn off applets in your browsers, but if you want to browse and run the Java4K games, you still can.
8  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-11-24 18:16:37
One week to go, and I'm clueless as to what to do about this years contest.

One option is to just go ahead with it as-is, and just see what happens.  We're only speculating on what the impact will be on the 2014 contest, it could turn out OK in the end.  It seems a shame to cancel a long-running contest just because there may a lower turnout this year.

I had a reply to SimonH's post ready, rehashing the problems the launcher addresses and the ones that it doesn't, but the points are moot if there's no contest.
9  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-11-23 17:37:41
Must the launcher also be 4k?
Please god, let that be sarcasm!  Grin
10  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-11-23 17:36:48
Note: You cannot unload a single class. You have to unload the classloader along with it.

Yes, that's why my code posted at the start of this thread creates one classloader per applet.  Once a classloader has loaded the meta data for a class, it isn't possible to "flush" that definition.  So for example, you can't load a new version of a jar with the same classloader.  I really wouldn't suggest writing your own classloader, if that's what you're thinking (based on your comment "System classloader is not suitable for this task.")  You're a lot more likely to introduce security holes implementing your own loader.  If you look at groboclown's policy file, you'll see that the default permissions he granted to all code are only those available to applets.  So if we correctly configure the security policy so that we only grant classloader privileges to the launcher and not to all code, that should close the hole you described.  Further, if we restrict the launcher as I described a couple of posts above your comment, even code that loads its own classes won't be able to do much besides get stuff from the tempdir or from java4k.com.  It won't be able to execute code locally, or load its own security manager, or start a daemon thread, even do stuff like access the clipboard.

Back on classloaders, I wrote a plugin architecture for a web portal about 10 years ago, and the four take-aways were:
  • the plugins should be in separate jars, outside the classpath of the main app
  • they shouldn't be loaded with the default classloader (because then you have to restart the application to load changes to the plugins).  Instead use either one classloader per plugin, which can be replaced on the fly when a plugin needs to be updated; or use one classloader for all plugins, which means reloading all plugins when any of them needs updating.
  • depending on how you configure log4j, it may hold back-references to a classloader, preventing it from being gc'd, so be careful
  • if you don't release classloader references, you can quickly run out of permgen space, because that's where class metadata is stored
These days tools like jvisualvm and Eclipse's MAT plugin make it much easier to watch for problems like the ones I ran into back then.
11  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-11-23 01:47:21
Well I've hacked together a pack.gz loader, but it does require a temporary file to put the unpacked jar in. Any better ideas?

I wrote some similar code earlier this week to load gzip, pack200 and gizp+pack200 files.  I didn't find an in memory way to handle unpacking, I did it the same as you.  A few differences though: the files should be put in java.io.tempdir, no hard-coded paths; needs to handle files that are only pack200, or only gzipped.  The files need to be cleaned up after unloading.  And as with my previous code and groboclown's, you definitely need a separate classloader per applet, since otherwise there might be namespace conflicts (eg: two applets both with a Main-class named "A" in the default package.)  I'll have a look tomorrow at how groboclown handled it in his code, I expect he (or she Wink; half my team are women) has already covered most of this.

Security is also a pain, as unless I load all the games in before setting the SecurityManager, I lose access to the files.  Might have to allow network access.

Yes.  Proper security managers are quite the pain.  The only way I could explicitly get it to work was to load a policy file, where the executing class is in the list of allowable classes, and explicitly limit everything else (https://pikacode.com/groboclown/java4k-launcher/file/default/launcher.policy).  I also limited my applet class loader to prevent the loading of any of these special classes, to prevent a backdoor.

Put this in your policy file to grant access to only the system defined temp directory.  
1  
permission java.io.FilePermission "${java.io.tmpdir}/*", "read, write, delete";

Note that I excluded execute, which prevents running anything outside the app's sandbox; and also readlink, in case someone's dumb enough to put a link from the tempdir to somewhere else on the file system.  So if malicious code gains access to the app's permissions (say because we goofed with the codebase path), the only bad stuff it can do is access or delete existing files in the tempdir (and, I suppose it could fill the harddrive with junk data?)

I'm looking at tightening the permissions for the launcher.  So far this seems sufficient:
1  
2  
3  
4  
5  
6  
7  
8  
9  
  permission java.lang.RuntimePermission "createClassLoader";
  permission java.lang.RuntimePermission "closeClassLoader";
  permission java.net.SocketPermission "java4k.com", "connect, resolve";

  permission java.io.FilePermission "${java.io.tmpdir}/*", "read, write, delete";

  permission java.util.PropertyPermission "com.sun.java.util.jar.pack.*", "read";

  permission java.io.FilePermission "${java.home}/lib/*", "read";


Also of use to anyone working with policy files, I recommend including them in the jar and loading them in the first few steps.  Otherwise, you're relying on the calling process to pass the policy file as a command line parameter - if they don't supply it, the app loads with the default which seems to be AllPermissions.  To load from a jar resource:
1  
2  
3  
      // Load a security policy to restrict access.
     System.setProperty("java.security.policy", Java4KLauncher.class.getResource("resources/java4k.policy").toString());
      System.setSecurityManager(new SecurityManager());
12  Game Development / Newbie & Debugging Questions / Re: Playing already stored Clip File on: 2013-11-22 14:10:47
okay thanks.
But I can play these sounds only once.
How do I reset the AudioInputStream from a Clip?
Since they're all loaded into my LinkedList after clip.open(ais), I have no Idea how I make them reusable
The usual way to play a clip again is to stop it, set the position back to the beginning, and start it again.
1  
2  
3  
clip.stop();
clip.setFramePosition(0);
clip.start();

However I usually do this with a Clip opened on a byte array, I haven't tried it with a Clip opened on an AudioInputStream.  Please give it a try, and if it doesn't work then we can try something more complicated.
13  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-11-21 14:35:32
I looked around, and I'm trying out pikacode:

https://pikacode.com/groboclown/java4k-launcher/

Let me know if this looks alright, and we can start the project there, or let me know if you have a better location.

Looks OK to me.  I haven't used git or mercurial, but they have Eclipse plugins, so I'm sure I can learn.
14  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-11-21 00:20:34
The launcher isn't that far from being usable, if others think it's worthwhile then I'm willing to put in a few hours to get it to that state.

+1, definitely worthwhile!

Ok, I'll get it to a "good enough" state this weekend, and put it up for code review.  If you read this @Groboclown, do want to keep hosting the code?  If so I can just send you a patch.  If not, I'll put the code up somewhere like sourceforge (though we don't want to have users download the final build from there, what with the new install wrapper they're now adding!  WTF are you thinking Sourceforge!?!?)

I do wonder how Oracle will implement the security enhancements in 7.51.
Will they simply move the default value of the Java Control Panel security slider from its current value of 'High' to 'Very High'?
If that's what they do, we could simply stick a message on the website header explaining how to lower the slider.  Grin
15  Game Development / Newbie & Debugging Questions / Re: Playing already stored Clip File on: 2013-11-20 21:13:57
Is this okay? I want to put a lot of sounds into my LinkedList and I'm afraid, that this will eat a lot of RAM...

I think so.  If I recall correctly, the sound library will read from the input stream in chunks, just a little bit ahead of what's currently playing.  Then it will discard those chunks after the current position moves past that point.  So by creating the clip and opening the stream, it doesn't really cache the music, rather you're just passing a reference to the data which will be read in small chunks when you play it.
16  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-11-20 21:10:00
But regarding the launcher, no, I'm not working on anything. What is mentioned here sounds like a big project to me, dozens of hours of work at least, research and lots of testing. The end-result of it is also dubious to me, will people use a launcher?
Java isn't exactly the easiest platform to work with, not when it comes to security, certificates, etc.

I can take care of the website and manage the contest, but developing all of this is beyond my interest and time. To me this no longer sounds like a one man job. I got my plate pretty full with job, and don't have many nights to burn on hobby projects anymore.

The launcher isn't that far from being usable, if others think it's worthwhile then I'm willing to put in a few hours to get it to that state.  It basically becomes a Steam client for java4k.com; see and run the games, which will no longer run in a browser if Oracle really does role out the proposed security changes.  It already works, and I've got the security changes figured out, the big question for me relates to the one you asked at the start of this thread: will it be enough to keep non-developers playing the Java4K games?
If the answer is "No", then this becomes a developer only contest, and we could just do something like tell everyone to not install the future update that disallows unsigned jars.

I work with more than a hundred other developers writing hospital software in Java.  The project I'm assigned to these days has 7K+ java source files.  So a little thing like an applet launcher is practically a walk in the park. Wink
17  Game Development / Newbie & Debugging Questions / Re: Playing already stored Clip File on: 2013-11-20 20:54:18
I read an audio file, and store it in a linkedList
1  
2  
3  
4  
5  
            AudioInputStream ais = AudioSystem.getAudioInputStream(getClass().getResourceAsStream(
                    "/Resources/Audio/Samples/" + st.nextToken()));
            Clip clip = (Clip) AudioSystem.getLine(new DataLine.Info(Clip.class,
                    ais.getFormat()));
            sounds.get(soundName).add(clip);


when passing the Clip to my new Player-Class, it doesn't play with "clip.start()".

You still need to open the clip before you can play it.  Think of it this way - there's nothing in your code snippet that actually tells the Clip about the AIS you opened in the line above.  Try something like this, where you tell that clip to open the input stream:
1  
2  
3  
4  
5  
6  
            AudioInputStream ais = AudioSystem.getAudioInputStream(getClass().getResourceAsStream(
                    "/Resources/Audio/Samples/" + st.nextToken()));
            Clip clip = (Clip) AudioSystem.getLine(new DataLine.Info(Clip.class,
                    ais.getFormat()));
            clip.open(ais);
            sounds.get(soundName).add(clip);
18  Game Development / Newbie & Debugging Questions / Re: Playing already stored Clip File on: 2013-11-20 19:55:38
Hey there!
I want to put sounds into my Game.

I already stored some Clip Objects and I want to play them with an external Class.

AudioInputStream wants to have an InputStream, but my Clips are already in the memory, how do I play them then?  Clueless

When you say you "already stored some Clip objects", have you already opened the source music with those clips using one of the two open() methods?  That's the only place I can recall where you would need to worry about the AudioInputStream.  You seem to imply that you've already opened the music; if so, you no longer need to worry about the AudioInputStream.

To play your Clip just once, use the start() method.
1  
myClip.start();


To play it several times, use the loop method.  Either loop continuously:
1  
myClip.loop(Clip.LOOP_CONTINUOUSLY);

or loop a specific number of times (eg 5):
1  
myClip.loop(5);


You can stop the clip with stop(), and restart at the beginning with setFramePosition(0).  (You could also use setFramePosition() with other values, for example to jump to the middle of a clip.)
19  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-11-19 15:52:23
4K makes it almost impossible to include sound, which should be part of any game, since games are multimedia entertainment.

While I understand your point, and it relates to the rule disallowing MIDI, it's important to point out that there have been a number of 4K games that included sound of various sorts.  Procedurally generated sound can be created and played in only 4 or 5 lines of Java code.  For more complex music, there are definitely options.  I wrote a Java4K game a couple of years ago (Mazer 4K)that plays the full score of Music Box Dancer as the background music (though only 8-bit quality.)  I also posted the code for the player and the encoder, including documentation, on this thread of java-gaming.org.  It's not minimized, but I guarantee that the source code posted with Mazer4K is the exact source code that was compressed and submitted.  You can see that the music decoding and playing component takes up only about 15% of the code.  The score for Music Box Dancer only takes up about 60 bytes after compression.

Last year I was working on generating nicer tones by simulating piano sound waves, I may continue it for this year's competition.  If I do I'll post the source for others to use.

On the main topic: Regarding the launcher, appel's comment sounded like he was going to work on something on his own.  If not, then I can set aside a couple of hours this weekend to work on it.  What I see as the next steps:
  • start from groboclown's code
  • double-check the security policy - if we can restrict the launcher itself so that even it doesn't have full permissions, any applet that breaks out of our sandbox therefore wouldn't have full permissions.  I'd also like to restrict the network permissions to just the java4k site.  I've got a policy file worked out for that, but that needs to be merged with what groboclown has created.
  • put the security policy in the jar.  It's only a single line of code to load a policy as a resource from the jar, and that way we don't need to use a separate script to supply the policy as a command-line argument.  So no risk of users running the app without a loaded security policy.
  • put the downloaded jars in the system temp directory instead of having an installation directory
  • load the list of this year's games from java4k.com.  For now I would say it can just be screen-scraped, using last year's game list for testing.  Groboclown's code already looks for the applet tag when supplied a url, so we could just use a list of urls pulled directly from the page listing the games.
  • I had an issue with loading gzip + pack200 jars using groboclown's code.  If so, that would need fixing.
  • UI work - Probably the easiest would be to follow the standard web paradigm, of a left menu of options affecting content to the right.  So we load the list of games in a collapsible pane on the left, and selecting one would load it into a pane on the right.
  • In theory this launcher app doesn't need to be signed, but in practice it would be a good idea.  Otherwise nefarious parties could put out their own modified version that does bad things.  A second advantage would be that the jars could be served over https, stopping any man-in-the-middle attacks (redirecting the user to a bad jar instead of the java4k one).  We may be overly concerned, it's a lot of work for someone to do bad stuff like this, but I figured I'd bring it up.

And a last item: the java4k website was having issues earlier this year, and I suggested appel move it to a different host.  Unfortunately the free host I suggested is flakey, and we saw intermittent downtime.  I'm willing to contribute towards a year of hosting on a more reliable site like host gator, if that would help (it's about the same price as a high-end game.)  Some paid hosts even offer a shared SSL certificate.  Just putting it out there for discussion.
20  Games Center / 4K Game Competition - 2013 / Re: random seed sequences as a form of data compression on: 2013-10-25 12:22:28
Quote
If you are able to take a set of data and reliably figure out a seed that generates that data, your PRNG is severly broken.
The ability to deduce the seed make no statement about a PRNG's statistical quality.  All the "excellent" PRNGs you can deduce the seed.  Also none of them are suited for use as a cryptographic hashing function.
Short of a brute-force attack on a PRNG with a small output-space, I'm not sure how you would deduce the seed for a PRNG.  Deducing the seed of a PRNG is equivalent to deducing the next bit in the sequence with a probability of success greater than 50%.  The ability to do that within a reasonable amount of calculations mean your PRNG isn't very good.  To put it another way, good PRNGs are implemented using one or more one-way functions.  If you are able to take the output of a PRNG and deduce the seed, you have successfully broken that combination of one-way functions.
21  Games Center / 4K Game Competition - 2013 / Re: random seed sequences as a form of data compression on: 2013-10-24 17:38:40
I agree with Jeremy and Riven, it's only practical to go from a seed to data, not the other way.

PRNGs are a classic example of the usefulness of one-way functions, where it's easy to generate a sequence of evenly distributed numbers, but it's very hard to determine the seed that lead to that sequence.  If you are able to take a set of data and reliably figure out a seed that generates that data, your PRNG is severly broken.  For example, if JGO were using a broken PRNG I could:

  • take the login token JGO generated for me when I logged in here
  • determine the seed
  • use that seed to figure out the next 50 or 500 or 5000 tokens
  • keep swapping in tokens and impersonating everyone who logged in after me

There are ways to mitigate the risk of such an attack, and I expect banking sites do that, but you get my point.  PRNGs use one-way functions that are designed to be hard to reverse, so you're probably wasting time if you make that effort.
22  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-09-20 14:57:47
Funny, I wrote a code very similar, which can load a Java4k jar (in pack.gz format) locally
and run it.

the Stub method:

public boolean isActive() {
         return true;
      }
is important, as some games wait for it to become true.

What are you using for handling gzipped jars?  Could you post that code, or a suggested change?  Or I could put this up on SourceForge or whatever, and you and whoever else could contribute directly.

Some technical points:
  • I'm not keen on screen-scraping, so if we go with a locally run app it might be worthwhile to think about what information should be shown in the listing and find a way to supply that in an easy to consume format.
  • Needs to handle gzipped jars.  The URLClassloader I'm using just accepts urls, but I'm guessing Damocles loaded his jar through an unzipping input stream.  As long as the final class is loaded with a new class loader, it should work fine.  We can't use the default class loader or reuse a class loader, because games with the same class name would result in the first class with that name being loaded for all of them.
  • I don't think any of our applets use the other Stub methods besides isActive(), as those other methods mostly do things that are outside the Java4K rules (like load images from remote locations.)  Can anyone think of a reason we would need to implement any of them?
  • What kind of UI should be provided for browsing the games?  We could duplicate what's on Java4K.com, but that seems like a lot of work to me.
23  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-09-20 13:56:18
You'd download like a very small  launcher file,  (be it .jar, .exe, or however you want to bundle it)

Then, will it be able to at some point, have a listing of all of the games available,  and then dynamically load the applets into the 'launcher',  e.g. mini steam launcher/ingame browser/app player? )

Yep, that's the idea.  Since applets are panels, we can embed an applet directly in a java application, removing the need for running the applet from a browser.  Ideally the listing of all games would come directly from the java4k website, so that any new games would be listed without requiring the user to download a new client or an update.

The code I posted can be run as a stand-alone java app (just package it in a jar with the manifest indicating that class is the Main class), so it's portable to any system that runs Java.  It's currently hard-coded to pull the jar for ApoShift4K down from the java4k website, just to prove that would work.
24  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-09-19 16:23:19
So I had a couple of hours free, and I wrote an app that can load applets from the web.  Obviously this is only a proof of concept, it's just hard-coded to use the first app that came up when I visited Java4K (with the number of games apo submitted, it was about 50% chance to be one of his Smiley .)  The next step would be to either screen-scrape all the games for a given year, or else set up a web service or rss feed to supply the info we need (jar url, class name, width, size.)  Then a panel could be added to this app showing all the games along with a button to load that game in the panel.  Probably would be good to have a menu bar as well, with the title of the current applet and a back button.  Also to be determined is whether it can handle gzipped jars.

The code is fairly simple, so I haven't commented it.  Details available on request.  Also, please let me know if you get any network warnings - I half expected one when my app wanted to pull the jar from the web, but I didn't get any warnings at all.  Would be good to know if that's just my firewall settings (I do client/server programming), or if a locally running Java app gets permissions for network access by default.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
package com.java4k.launcher;

import java.applet.Applet;
import java.applet.AppletContext;
import java.applet.AppletStub;
import java.awt.AWTEvent;
import java.awt.Dimension;
import java.awt.event.WindowEvent;
import java.net.URL;
import java.net.URLClassLoader;

import javax.swing.JFrame;

public class Java4KLauncher extends JFrame {

   private Applet applet = null;
   private URLClassLoader classLoader = null;

   /**
    * @param args
    */

   public static void main(String[] args) {

      Java4KLauncher frame = new Java4KLauncher("Java 4K Launcher");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setPreferredSize(new Dimension(810, 640));

      frame.setApplet("Y", "http://java4k.com/applet.php?gid=427");

   }

   public Java4KLauncher(String s) {
      super(s);
   }

   public void setApplet(String className, String jarPath) {
      try {
         URL[] paths = {new URL(jarPath)};
         classLoader = new URLClassLoader(paths);
         @SuppressWarnings("unchecked")
         Class<Applet> c = (Class<Applet>) Class.forName(className, true, classLoader);
         applet = c.newInstance();
      } catch (Exception e) {
         System.err.println("Could load class: '" + className + "' from path: '" + jarPath + "'");
         e.printStackTrace();
         return;
      }
      applet.setPreferredSize(new Dimension(800, 600));
      this.add(applet, java.awt.BorderLayout.CENTER);
      // frame.setResizable(false);
     this.setVisible(true);
      applet.init();
      applet.setStub(new Stub());
      applet.start();
      applet.setVisible(true);
      this.pack();
      this.validate();
   }

   @Override
   public void processEvent(AWTEvent e) {
      switch (e.getID()) {
      case WindowEvent.WINDOW_ICONIFIED:
         applet.stop();
         break;
      case WindowEvent.WINDOW_DEICONIFIED:
         applet.start();
         break;
      // If window closes, exit the app
     case WindowEvent.WINDOW_CLOSING:
         applet.destroy();
         System.exit(0);
         break;
      // Other events can be handled here
     }

   }

   private static class Stub implements AppletStub {
      @Override
      public boolean isActive() {
         return true;
      }

      @Override
      public URL getDocumentBase() {
         // TODO Auto-generated method stub
        return null;
      }

      @Override
      public URL getCodeBase() {
         // TODO Auto-generated method stub
        return null;
      }

      @Override
      public String getParameter(String name) {
         // TODO Auto-generated method stub
        return null;
      }

      @Override
      public AppletContext getAppletContext() {
         // TODO Auto-generated method stub
        return null;
      }

      @Override
      public void appletResize(int width, int height) {
         // TODO Auto-generated method stub
     }
   }
}
25  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-09-18 19:11:57
However, the 4K game contest in its present form is often more about designing a good compression chain than about creative game design. This makes it less newbie-friendly. Without a good compression chain (which can be pretty hard to do) there is no way to meaningfully compete in the contest.

Groboclown put together a great set of ANT scripts two years ago.  It's what I used for the 2012 competition.  It does proguard, packing, gzip, etc, even with different block sizes.  I think I had to get proguard and a 7zip separately and configure the script with their locations, but having that toolkit does lower the entry bar significantly.
26  Games Center / 4K Game Competition - 2013 / Re: java4k.com website is down on: 2013-08-06 19:37:55
Yea, pretty crappy "free" service. I even moved a site of static pages that barely gets any visits, and within a day or two it also reached the "cpu limit", whatever that is defined at.

I think they're just using it for advertising, randomly blocking sites, trying to sucker people to upgrade to a $$ "premium" plan. I can understand that, but why on earth they didn't warn about this practice before I moved everything over to there.

Sorry appel, I had no idea that host would be that bad.  Sad  Do you have a general idea of the storage and bandwidth requirements?  If we can get hosting that meets the requirements for about $50 CAD (or less  Wink ), I'm willing to cover the cost for a few years.  If I were still in town with a fibre connection I would volunteer to host on one of my home servers, but I'm out in the country now with a fairly slow ADSL connection.
27  Games Center / 4K Game Competition - 2013 / Re: java4k.com website is down on: 2013-05-22 19:09:49
I like to play the game of elimination before I spend $$ on new stuff.

Is the site just PHP backed by MySQL or something like that?  If so, you could switch to a free host.  There are a number of hosts like www.000webhost.com that provide PHP, MySQL and a decent amount of space and bandwidth/data transfer for free.  Not that bandwidth is much of a problem I suppose, with the jars being only 4KB!  Wink
28  Games Center / 4K Game Competition - 2013 / Re: java4k.com website is down on: 2013-05-22 18:45:46
Just FYI @appel - the site has been down for the past 7 hours.
29  Games Center / 4K Game Competition - 2013 / Re: java4k.com website is down on: 2013-05-01 17:07:46
It was misbehaving some time ago, and I almost gave up on it, then it became stable. Now in recent days it's been bad. I've replaced hardware in the server to pinpoint the hardware error. Hopefully this time around it's going to behave. If not I'll fix it by getting another box, because the current one is obviously flawed.

Sorry about it, it's a bit tricky to pinpoint which hardware module is flawed, and I like to play the game of elimination before I spend $$ on new stuff. You have to wait and see.

No worries, it performed well for the contest period, that's the most important part of the year.  Smiley  I just wanted to make sure someone knew.

PS: Thanks for hosting the site, I just assumed we were using a free webhost somewhere.
30  Games Center / 4K Game Competition - 2013 / Re: java4k.com website is down on: 2013-04-29 16:55:01
If I understand this graph correctly (link to current Netcraft graph, the site has been down for the past 24 hours.
Pages: [1] 2
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (21 views)
2014-09-21 02:42:18

BurntPizza (15 views)
2014-09-21 01:30:30

moogie (15 views)
2014-09-21 00:26:15

UprightPath (25 views)
2014-09-20 20:14:06

BurntPizza (27 views)
2014-09-19 03:14:18

Dwinin (42 views)
2014-09-12 09:08:26

Norakomi (73 views)
2014-09-10 13:57:51

TehJavaDev (97 views)
2014-09-10 06:39:09

Tekkerue (49 views)
2014-09-09 02:24:56

mitcheeb (70 views)
2014-09-08 06:06:29
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!