Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Applet questions  (Read 4333 times)
0 Members and 1 Guest are viewing this topic.
Offline zeroone
« Posted 2009-12-07 16:07:54 »

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.
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #1 - Posted 2009-12-07 17:06:46 »

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.

See my work:
OTC Software
Offline pjt33
« Reply #2 - Posted 2009-12-07 17:38:20 »

Why do you have to click on an applet to gain the keyboard focus?
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?
Not per se, although some of the example code you see wandering about (on this site included) has the potential to drop events.

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.
In theory. In practice this is buggy, and you need to make your applet resize its parent window.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline woogley
« Reply #3 - Posted 2009-12-07 18:20:20 »

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.

While that's true.. Webstart's JNLP format actually supports applets out-of-the-box. You simply use the <applet-desc> tag instead of <application-desc>

From the documentation:
Quote
applet-desc Element

Java Web Start has support for launching Java applets. This support provides easy migration of existing code to Java Web Start.

An applet is launched using the applet-desc element instead of the application-desc element. For example:

  <applet-desc
      documentBase="http://..."
      name="TimePilot"
      main-class="TimePilot.TimePilotApp"
      width="527"
      height="428">
    <param name="key1" value="value1"/>
    <param name="key2" value="value2"/>
  </applet-desc>
Offline zeroone
« Reply #4 - Posted 2009-12-07 20:28:32 »

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?
Offline Ranger
« Reply #5 - Posted 2009-12-07 22:04:34 »

Why do you have to click on an applet to gain the keyboard focus?

If you add this.requestFocus(); you don't have to.  However, this adds precious bytes.  Tongue
Offline zeroone
« Reply #6 - Posted 2009-12-07 22:25:15 »

What happens if we avoid this technique:

http://stackoverflow.com/questions/196890/java2d-performance-issues

Which platforms will have performance problems?
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #7 - Posted 2009-12-09 17:02:49 »

While that's true.. Webstart's JNLP format actually supports applets out-of-the-box. You simply use the <applet-desc> tag instead of <application-desc>

From the documentation:
Ah, I didn't know that. Very good to know. Smiley You can save yourself a few bytes with this.

What happens if we avoid this technique:

http://stackoverflow.com/questions/196890/java2d-performance-issues

Which platforms will have performance problems?
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.

See my work:
OTC Software
Offline zeroone
« Reply #8 - Posted 2009-12-09 17:12:52 »

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.

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?
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #9 - Posted 2009-12-09 17:33:24 »

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:

Quote
Java2D Results:
- In a window of size 300 x 300 with 20 entities flying around, 50 fps.
- In a window of size 1024 x 768 with 20 entities flying around, 20 fps.
- In a window of size 300 x 300 with 100 entities flying around, 10 fps.

OpenGL Results:
- In a window of size 1024 x 768 with 20 entities flying around, 60 fps (at least, I was limiting it at 60).
- In a window of size 1024 x 768 with 1000 entities flying around, 60 fps.
- In a window of size 1024 x 768 with 5000 entities flying around, 20 fps.

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

See my work:
OTC Software
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline zeroone
« Reply #10 - Posted 2009-12-09 18:21:13 »

How do you force it to use OpenGL?
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #11 - Posted 2009-12-09 18:51:29 »

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.

See my work:
OTC Software
Offline zeroone
« Reply #12 - Posted 2009-12-09 19:29:41 »

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? 
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 75
Projects: 15


★★★★★


« Reply #13 - Posted 2009-12-09 19:34:31 »

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?

Slick2D works on windows, mac, linux and solaris. From a performance point of view it totally destroys Java 2d.
Offline zeroone
« Reply #14 - Posted 2009-12-09 20:19:00 »

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?
Offline SquashMonster

Senior Member


Medals: 1
Projects: 2



« Reply #15 - Posted 2009-12-10 04:49:13 »

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?
Offline Markus_Persson

JGO Wizard


Medals: 14
Projects: 19


Mojang Specifications


« Reply #16 - Posted 2009-12-10 10:22:11 »

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

Play Minecraft!
Offline appel

JGO Wizard


Medals: 50
Projects: 4


I always win!


« Reply #17 - Posted 2009-12-10 11:36:58 »

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?

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.

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline zeroone
« Reply #18 - Posted 2009-12-10 16:16:50 »

Quote
Java 6 is actually quite fast. Not as fast as Slick, but it's sufficiently fast for most 2D games.


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.

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.
Offline appel

JGO Wizard


Medals: 50
Projects: 4


I always win!


« Reply #19 - Posted 2009-12-10 16:24:25 »

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.

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

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.

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline zeroone
« Reply #20 - Posted 2009-12-10 18:09:40 »

Quote
make the source-code invisible until the contest is over

Is there really anything worth hiding?  Does anyone really think they invented something so amazing that giving out the source would affect the contest results?  The submissions keep getting better, but the majority of graphics algorithms and coding techniques are highly documented out there.  The source does not reveal any secrets.  Besides, if someone did invent something really useful for this competition, let them share the knowledge.  Spur innovation.
Offline pjt33
« Reply #21 - Posted 2009-12-10 18:59:26 »

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.
Making everyone use the same build tool would be a major complication - to guarantee consistency you'd have to have a central compiler, which would make testing the effect of a tweak a very slow process.

Moreover, it would place extra constraints. Last year I couldn't have submitted Java code which a centralised build tool would fit into 4k: I ended up tweaking bytecode manually and assembling it with Jasmin to get the size down. I'm probably going to do the same this year.

As for sharing the source: we're not necessarily proud of all the hacks we use to reduce size...
Offline zeroone
« Reply #22 - Posted 2009-12-10 19:40:30 »

Quote
Moreover, it would place extra constraints. Last year I couldn't have submitted Java code which a centralised build tool would fit into 4k: I ended up tweaking bytecode manually and assembling it with Jasmin to get the size down. I'm probably going to do the same this year.

Holy crap!  I didn't know that people went that far.  How much did that save you?  What are you chopping out by doing that?

Quote
As for sharing the source: we're not necessarily proud of all the hacks we use to reduce size...

LOL!
Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #23 - Posted 2009-12-10 19:53:42 »

My source code tends to evolve as the competition continues, so it's it bit premature to post it.  I did open source my code back in 2005/6 (the last time I entered), when the competion closed and intend to do the same this time. Readability tends to be poor as almost everything gets stuffed in one method in a single class.

Time flies like a bird. Fruit flies like a banana.
Offline pjt33
« Reply #24 - Posted 2009-12-10 23:08:02 »

Holy crap!  I didn't know that people went that far.  How much did that save you?  What are you chopping out by doing that?
It's hard to say how much it saved me, because I had to go back to do some bug fixes. When I went to bytecode I needed to chop off 22 bytes to fit in budget. It was mainly peephole optimisations which Proguard inexplicably doesn't do. I've restructured the repository since then so it would be quite a lot of work to go back and get a diff of the changes I made to the bytecode.
Offline zeroone
« Reply #25 - Posted 2009-12-18 15:49:06 »

Quote
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?

Kev,

If you are around, any chance you can visit the Slick forums.  I have lots of technical questions that I need help on.  I'm so confused.  I promise I'll return the favor by posting sample Slick games with the source and I'll create some tutorials after I am more experienced with it.  Your API rocks.   Grin
Offline kevglass

JGO Kernel


Medals: 123
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #26 - Posted 2009-12-18 17:53:55 »

Out of touch at the moment. Will check in a day or so.

Kev

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

CogWheelz (12 views)
2014-08-01 22:53:16

CogWheelz (14 views)
2014-08-01 22:51:43

CopyableCougar4 (15 views)
2014-08-01 19:37:19

CogWheelz (19 views)
2014-07-30 21:08:39

Riven (27 views)
2014-07-29 18:09:19

Riven (16 views)
2014-07-29 18:08:52

Dwinin (14 views)
2014-07-29 10:59:34

E.R. Fleming (35 views)
2014-07-29 03:07:13

E.R. Fleming (13 views)
2014-07-29 03:06:25

pw (44 views)
2014-07-24 01:59:36
Resources for WIP games
by CogWheelz
2014-08-01 18:20:17

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

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

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

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

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22
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!