Applet questions

Not that it would be used by an entry, but is there an easy way to write an application that can be launched both by Web Start and as an imbedded applet?

Are there any performance issues in using applets? Does the browser set the threads to ultra low priority or something?

Do applets respond to events as effectively as web start applications? Why do you have to click on an applet to gain the keyboard focus? Anyone experience dropped keyboard events on some browsers? On a related issue, did anyone notice that if you setup a KeyListener, sometimes you do not get the key released event (this has nothing to do with applets)? I know that no one uses KeyListeners for this competition, but I am not sure at what point in the chain keyboard events get dropped and why.

All you need to do is make it like an Applet and include a main method, then you can easily pop it in Webstart as usual.

Possibly because applets are intended to be usable in pages in which they aren’t the be all and end all, so having them always grab focus would be a major frustration.

[quote]Anyone experience dropped keyboard events on some browsers?
[/quote]
Not per se, although some of the example code you see wandering about (on this site included) has the potential to drop events.

In theory. In practice this is buggy, and you need to make your applet resize its parent window.

While that’s true… Webstart’s JNLP format actually supports applets out-of-the-box. You simply use the tag instead of

From the documentation:

Whatever happened to those volatile buffers for speeding up graphics? Aren’t we supposed to write to a buffer and swap it to make it visible or something? Does that work with applets?

If you add this.requestFocus(); you don’t have to. However, this adds precious bytes. :stuck_out_tongue:

What happens if we avoid this technique:

Which platforms will have performance problems?

Ah, I didn’t know that. Very good to know. :slight_smile: You can save yourself a few bytes with this.

In Java 4k, don’t worry about it. It’s very unlikely that you’re going to have a problem with software rendering - it’ll suffice.

[quote]In Java 4k, don’t worry about it. It’s very unlikely that you’re going to have a problem with software rendering - it’ll suffice.
[/quote]
Any idea when it would be a problem? Will it only affect people not set to 24-bit color or if we attempt to load bitmaps less than 24-bit color?

It’ll be a problem when you’re drawing either a decent amount of shapes or images to a window, regardless of your color rate or whatever. Obviously smaller images will be cheaper and fewer of them is also cheaper. But to learn when this is a problem, basically imagine how many things you could draw in OpenGL (or with hardware acceleration) and divide that by 10.

I made a stress test app before, and here are the results I got:

There was very little optimization with either Java2D or OpenGL, I just threw crap in and drew it. Obviously, Java2D chokes pretty quickly.

How do you force it to use OpenGL?

I’m not sure in an Applet. I know you can do it from the command line when executing a jar, or you can just use something like the Slick library or jME.

Wow. The Slick Library looks really impressive if you want to make 2D games. I’ll have to mess around with it. (BTW, Thanks Kev) Does Slick only work under Windows?

Did you mention that Java can be as fast as OpenGL just by configuration?

Slick2D works on windows, mac, linux and solaris. From a performance point of view it totally destroys Java 2d.

Now, I am getting really excited about Slick. I think I’d rather spend my time messing around with it rather than focusing on a 4K game. Anyone available to answer some coding questions about it?

I’d actually like to see a competition like Java4k that uses Slick. We have a pretty long off season, could there be a Java4k+Slick competition in the summer? Or perhaps even a Java16k?

We tried a larger size limited compo, and it’s no fun.

Minecraft4k is currently less than 2kb. If I had 16kb to work with, I could do pretty much anything with enough effort. It’s just no fun.
With 4kb only, there’s a very real limit on how much stuff you can fit in there.

However, I wouldn’t mind an 4kb compo where you can use JOGL or LWJGL. =D

Java 6 is actually quite fast. Not as fast as Slick, but it’s sufficiently fast for most 2D games. I don’t believe you’ll be able to do cooler games in Slick having a 4KB limit, after all, Slick is meant to simulate Java2D API in a way.
If you’re looking for faster framerates, then next year I believe Java 6 will be the target JRE.

Besides, there is a huge overhead and learning curve with additional libraries, which will result in a subset of programmers participating, e.g. there are fewer Java programmers interested in Slick, Lwjgl, Jogl, etc. If you’re doing Java game programming, you know Java2D, but not all the other libraries. Slick, Lwjgl, Jogl, etc. are all subsets really. Java2D is more mainstream oriented.

There are two new things already this year that should make the contest VERY exciting for 4K nerds.
Those are 1) pack200 that allows you to squeeze in 20-30% more game code 2) Applet only.

Ditto what Markus said on size limits.

[quote]Java 6 is actually quite fast. Not as fast as Slick, but it’s sufficiently fast for most 2D games.
[/quote]
I am actually really impressed with how fast 2D graphics are in Java 6 including things like scaling and sprite rotation, but if I don’t restrict myself to 4K (obviously for games outside this competition) does it make sense to stick with just the standard graphics library? Is Slick the best direction to go in? It looks like the kind of layer I would be forced to build on top of LWJGL anyway; it looks like the Slick developers saved me a lot of work.

As for the 4K limit, as pointed out on the Java 4K wiki:

[quote]This may explain why spinoff contests targeting 8K, 16K, or a specific API like LWJGL have never taken off. In fact, the contestants seem to believe that 4K is the “sweet spot” that balances what an individual can do. Because of the tricks developed for the 4K contest, it’s believed that adding even a single kilobyte would open the doors to far more complex games that are beyond the ability of a single developer.
[/quote]
I think that is very true. 4K gives you just enough to work with such that it is an excellent and fun challenge. Though, I have often though that it is unfair that we aren’t all using the same build tool. I think we should only be concerned about the code. I’m also surprized that people don’t readily share their source or why the submission isn’t just the source itself that is built against a common compression tool.

A 4K competition against a specific graphics library could work. Things like that have taken off in the demo scene.

Half the fun is hacking the code just right together and compress it in a specific manner! :slight_smile:

Although, I might enable programmers to optionally attach the source-code to their submitted games, and then allow normal users to see the source code behind each game. (I’d have to have a checkbox so programmers can make the source-code invisible until the contest is over). But this is very simple to do.