Newbie tutorial.....  Use or Abuse

3 x Blah was asking for tutorials in another thread. This is one I wrote a while back. I did a quick Composer job on the text so the html isn’t so great and of course IE messes with the fixed width tags so the source looks screwy on IE.

Its all AWT and applets. It assumes the user already knows some java. It was intended as a starting point to java gamedev. It includes source and an example applet.

Its way out of date now, both with java and my own skills. So feel free to critique it and make suggestions.

Click here.

Seems pretty good actually. Apart from some omissions - like explaining why you overrode update(): the para looks self-contradicting without the explanation. Also some errors (stuff which I suspect you probably understand better now if you were rewriting this).

Would you (or someone else who’s been doing applet coding recently) consider updating this a bit, making a few corrections, and then I’ll put it on JGF.

Which makes me realise: if I’m going to post articles on JGF, I need a pool of volunteer article-reviewers, who can quickly read through them before they get published, and check for places where things are incorrectly described, or something is done wrong.

E.g. in a swing tutorial, if I saw any use of

paint( Graphics G )

I know it’s wrong (unless there’s a para explaining why the author is breaking Swing deliberately - for Swing, you’re always supposed to use paintComponent( Graphics g ) where in AWT you would have used paint(…)).

I can do this kind of review myself for a considerable number of the libraries, but there are big areas where I wouldn’t recognize such mistakes (especially with any of the techs I don’t use, like ODE).

Reviewing articles is a LOT less work than writing them (by a factor of about 10-20) but is equally helpful in getting articles on the web for other peopl to use. So, if you have the skills but not the time for writing articles, please could you help with this? Email me or message me, saying what areas (e.g. “swing, JOGL, OpenGL”) you feel capable of reviewing articles for.

I thought about converting the tutorial and example code to a JApplet using a canvas + bufferstrategy. No problem there. But what stopped me was the loading images bit; to preserve transparency I use the image loader class from the wiki and I didn’t want to ‘steal’ the code and put it in the tutorial.

The article covers:

Applets+Event driven programming
Double buffering
Loading graphics
Threads + game loop
Timing
Managing the gc
Input with KeyListener

All these topics would carry straight over to j2d. Timing is still problematic, especially for an applet, until 1.5 becomes widely used.

I thought about adding a bit about jars and loading images from jars.

I can update it to j2d at some point, I don’t know when though. Maybe after this contest. If you want to post it as is pm me the other errors you caught and I can update it.

[quote]I thought about converting the tutorial and example code to a JApplet using a canvas + bufferstrategy.
[/quote]
Have you done much with JApplets? Last time I did anything graphics intensive, I found 1.4.x was brkoen (probably 1.4.1) and couldn’t handle JApplet’s properly on any platform, and I don’t recall if the bug has been fixed yet (it was semi-repeatable: a race conditoin would cause JApplet’s sometimes to initialise with an invalid Graphics. The whole applet would run fine, but without any graphics, and there was no way of getting the graphics to come to life wihtout restarting appletviewer / plugin).

I was messing around with your program and i ran into a problem. how do you keep the transparencies on the sprites?

and what program do you use to draw sprites?

To Blah^3, japplets seem to work fine on jre 1.4.2.

To get transparency you have to save the transparent color with the image like in a gif.

I use Microsoft Paint that comes with windows. The version of paint I have on this computer won’t save a transparent gif or png, so I draw with ms paint and then i use the the free program irfranview to load the image save it with a trans color.

You could use any image program though, like gimp, photoshop, paintshop pro etc…