[quote]I’m still quite annoyed by the fact, that sun took so long for including such a fundamental thing as a usable timer. It took somewhat like 4-5 years from the RFE until it was finally included. So writing a RFE seems to be totally useless especially for things wich are less basic. Look at that structs RFE it will take 3years to NEVER.
[/quote]
Without an RFE, we would still not have any usable timer in the JRE today, although I agree it took ridiculously long.
As for structs, I won’t hold my breath either… :-/
So now my expectations are quite low, it can only turn out better than expected ;D
Sun seems to set very low standards for enhancement request processing. Which they fail to live up to.
Cas
kevglass,
Thanks so much for your tutorials. I have been going through your first one and am looking forward to moving on to your second. You do a great job at explaining what is going on and why, thanks so much!!!
On a side note, does anyone know of a good tutorial for the following:
-One that explains how how to incorporate images with multiple frames? for example, making an image walk accross the screen and rotate through a series of frames while he does it so he looks like he is walking?
- Creating a background map (ie scenery) and loading it to the page?
I am interested in both of these things but most of what I can find that does them is very complicated.
Thanks!
Just tried the tutorial. Starts off very smooth @480fps. But as you shoot more aliens it becomes progressively jerkier, until it is unplayable with about 10 aliens on the screen. At that point the FPS meter reads @1000!
I’m using JRE 1.4.2 on WinXP/P3 1GHz/512MB/GeFTi4200 with 45.23 drivers.
20thCB
Interesting, did you have a version number in the title bar, or did it just say “Space Invaders 102” with the fps counter…
I uploaded a version using the GAGE hires timer for space invaders 102 yesterday so if you’re playing that I have absolutely no idea where your jerkyness is coming from
Kev
EDIT: PS. 1000 FPS on a 9800 is no surprise
The title bar says Space Invaders 102 with the FPS counter. I noticed WebStart downloaded the GageTimer jar. I’ve rebooted but the same thing happens. I notice the jerkiness after about half the aliens are shot. Does this not happen on your machine?
20thCB
Nope, not on the 4 windows machines I have access to. I have just updated the 102 jnlp to fix the FPS to 100, if thats not happening, something else is screwed…
Let me know if fixing the frame rate has fixed owt?
Kev
this one is running a bit smoother than the java2d version, winxp ti4600 512mbr
Hope the tutorial will be up soon too bad u didnt use lwjgl tho
Funny you should say that, the next tutorial is on Timing, Native Libraries and adding Animation. The following one will be about Refactoring and OpenGL (and will suggest the reader implements a LWJGL version as a followup exercise).
Anyway, here’s the second tutorial… just for review at the moment, and of course subject to change as these issues people have been seeing resolve themselfs.
http://www.cokeandcode.com/info/tut2d-2.html
I’m going to write up the third tutorial but not publish it until the timing issues raised have been sorted out.
Kev
[quote]Hope the tutorial will be up soon too bad u didnt use lwjgl tho
[/quote]
Bah! If he used LWJGL I couldn’t run it on the Mac via Web Start. LWJGL still has issues interacting with AWT on the Mac.
Kev, yes the FPS fix seems to have sorted it. Must have been some loopy timing issue.
For me, timing is the most critical thing to get right in action games. Nothing ruins the gaming experience more than dodgy timing, not even crappy graphics. It has to be rock-solid. As a relatively new games programmer I find the whole issue terribly confusing. There seem to be so many completely different ways to do timing! Already I’ve heard about GageTimer, LWJGL timer, Java3D timer, JRE 1.5 nano-timer, Currentmillis timer, enough already! :o
Surely there must be TOTTS (The One True Timer Style) ?
I’d love to see a tutorial devoted solely to timing in Java. It should give a runnable example of each method, and describe the pros and cons of each. Any takers? ;D
20thCB
No class def found error looking for “com/dnsalias/java/timer/AdvancedTimer” or somethjing like that
WTF did Sun make the JWS error pane not copy/pastable? >:(
Fixed, sorry about that, resources problem.
Kev
I’ve just uploaded 103. I’m not really 100% happy with it but to be honest I want to get back to my current project… for better or worse, its here:
http://www.cokeandcode.com/info/tut2d-3.html
Kev
FPS moves from 100 to 99 and back again alot.
The enemies seem to flicker less - however, I’ve noticed they also “flash” extra-bright every 2-3 seconds; the effect is as if you painted an image with 80% opacity normally, and then occasionally painted it with 100% opacity. My best guess is that this is a frame being displayed for slightly longer - and hence showing brighter on the LCD screen, which is much more sensitive in some ways than an LCD (no ramp-down time, for instance) - due to some momentary periodic hiccup in the frame-times?
The ship still is a little jerky, although it seems to be significantly better.
[quote]I’ve just uploaded 103. I’m not really 100% happy with it but to be honest I want to get back to my current project… for better or worse, its here:
Kev
[/quote]
Added to JGF. With corrections :).
Um…cry for help: any professional XSLT developers out there? The XSL template that should make all the links work in every one of Kev’s articles is for some reason only executing against the first, although the XSL and XML are near-identical :(. So only the first article has working links >:(
This error ends up affecting nothing in the game since it only happens when I close the window but here it is anyways. I do have to say that this appears every single time I exit the the program.
net.java.games.jogl.GLException: Error swapping buffers
at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.swapBuffers(WindowsOnscreenGLContext.java:140)
at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:241)
at net.java.games.jogl.GLCanvas.displayImpl(GLCanvas.java:186)
at net.java.games.jogl.GLCanvas.display(GLCanvas.java:74)
at net.java.games.jogl.Animator$1.run(Animator.java:104)
at java.lang.Thread.run(Unknown Source)
Also, how would I draw images with transparency over another image? As it is, it looks like it draws a black rectangle as a background. If I’m unclear, here’s an image that illustrates exactly what I mean.
net.java.games.jogl.GLException: Error swapping buffers
at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.swapBuffers(Wi ndowsOnscreenGLContext.java:140)
at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:241)
at net.java.games.jogl.GLCanvas.displayImpl(GLCanvas.java:186)
at net.java.games.jogl.GLCanvas.display(GLCanvas.java:74)
at net.java.games.jogl.Animator$1.run(Animator.java:104)
at java.lang.Thread.run(Unknown Source)
This is cause by the abrupt way the tutorial exits the game. It calls System.exit(0) at a time when we could be rendering. To prevent it, instead of calling System.exit(0) set a flag and use it to call exit() inside the rendering loop. The problem is that the rendering thread continues even through the window has been destroyed at exit. Have to say its one of things I don’t tend to worry about since in a deployed game the user won’t see it and as you say it has no effect on running.
As to transparemcy, you need to go into blending, its mentioned in this thread: (don’t worry thats its LWJGL, same thing applies)
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=LWJGL;action=display;num=1083425041;start=15#15
Orangy Tang writes:
Kev
Thanks for the help. It worked like a charm! ;D
On my OS X laptop:
93 - 100 fps (openGL)
30 - 32 fps (Java2D)
Nice and smooth, no probs except the minimised starting window (looks like pack() is called and OS X tries to make the window as small as possible.
ribot.