Sign in to follow this  

[java] SDK 1.5?

This topic is 4598 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What version of Java is everyone using now for game development? I am still learning and using 1.4.2 because thats that version that the book I was learning from used, but I'm wondering if I should move on to 1.5? I also read that the worst thing about java sofar(mind you this was before 1.5) is that it doesn't have very accurate timers. I also read that this was supposed to be fixed in version 1.5, was it? thanks for any help. -Jake

Share this post


Link to post
Share on other sites
1.5 does include a *much* more accurate timer than 1.4 does, which is pretty handy given that the default 1.4 timer is far too low resolution on windows.

However! 1.5 introduces lots of cruft and features which are not universally liked. Perhaps more importantly it's unlikely that your players will actually have 1.5 installed, whereas 1.4 is much more common.

You'll probably find the majority of people are using 1.4 and some other method for timing, if you're using LWJGL (highly recommended!) then that has a cross-platform high-res timer you can use. Or you can use the GAGE timer which just provides a more accurate timer.

Also, see here.

Share this post


Link to post
Share on other sites
Hey, thanks for the reply. I will stick with 1.4 for now. I am actually just learning the java2d api right now, as I am relatively new and want to make 2d games. I will however experiment with 3d programming oneday to see how it is done. So is the LWJGL api better than the regular JOGL api? I have just finished a basic book on java(not for games) and I'm trying to now apply that knowlege to games. Right now I'm trying to make a gif image move and I just installed eclipse today(used command line until now) and after trying to make a project and then wanting to move it, I deleted the project, but along with it it deleted every java program I have written since I have started(probably 40 small programs and an unfinsihed java cal. that I started on recently). That sucks but oh well, I guess I can do with out those.

-Jake

Share this post


Link to post
Share on other sites
Quote:
Original post by jake2431
So is the LWJGL api better than the regular JOGL api?

-Jake


The JOGL API is purely a binding to OGL for java. LWJGL includes a whole pile more, including input and sound and what have you. Its the DirectX of the java world if you like, whereas JOGL is only the direct 3D bit. Theres a couple of differences between the bindings aswell , LWJGL doesn't have any AWT dependencies for example, and is single threaded. JOGL tries a lot harder to be more general and more adherent to the Java spec IE support for multiple monitors (which I don't think LWJGL has), (flaky) support for swing etc etc. If you're just interested in game programming then LWJGL is probably the one to check out.

D.

Share this post


Link to post
Share on other sites
Just want to point out, if you are *new* to Java and only want to make 2d games, perhaps you should use the simplest one first, GTGE for warming up.
It is aim for 2d game development, and it can use all mentioned above, the JOGL and LWJGL, and also GAGE timer, and by default of course it use only Java2D API.

Share this post


Link to post
Share on other sites
Thanks guys. I will look into all of this. Until I learn the launguage better though I am just going to use the standard api and I guess sleep() is the best it's got. I was wandering though if you guys could help me with another question to get my sprite moving. Okay I have the image displayed and the window rendered and the key listener implemented, but what do I attach the event listener to, the window? Thats what I have now. And then should I have a method that creates a thread and tells it to sleep and also calls repaint. Also I am creating applications not applets, so is the main method the only method that gets automatically called. I know that init and start get called in an applet. Most information i can find is for java game programming deals with apllets. Are all of you also using applets or applications?

-Jake

Share this post


Link to post
Share on other sites
Quote:

Thanks guys. I will look into all of this. Until I learn the launguage better though I am just going to use the standard api and I guess sleep() is the best it's got.

Yes it's the best you've got.

Quote:

I was wandering though if you guys could help me with another question to get my sprite moving. Okay I have the image displayed and the window rendered and the key listener implemented, but what do I attach the event listener to, the window? Thats what I have now.


That should be just fine. You might also want to create a boolean or int-array to store the key states - which are updated when you get events. Then you just use this array to check the input. This prevents your input getting laggy.

Quote:
And then should I have a method that creates a thread and tells it to sleep and also calls repaint.

You don't need extra thread for that and you shouldn't use repainting at all.
What you want is BufferStrategy: Full-screen exclusive tutorial

Quote:

Also I am creating applications not applets, so is the main method the only method that gets automatically called. I know that init and start get called in an applet. Most information i can find is for java game programming deals with apllets. Are all of you also using applets or applications?

Yes main() is the only method called in applications. There shouldn't be any difference between applets and applications when using Java2D.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by amannis
Quote:

sleep() is the best it's got.

Yes it's the best you've got.



Actually, it's not good enough - unless you don't mind writing games that only run on linux and OS X.

You'll need to get GAGETimer - http://javagamesfactory.com/tech-page-GAGETimer.html - which is what nearly everyone else uses to fix the problems on windows.

It's small, it Just Works.

Share this post


Link to post
Share on other sites
Quote:
Original post by amannis

That should be just fine. You might also want to create a boolean or int-array to store the key states - which are updated when you get events. Then you just use this array to check the input. This prevents your input getting laggy.


Not sure if I know exactly how to do this. Do you have a code snippet that I can look at as example? Sorry for my lack of knowledge.

-Jake

P.S. Also, thanks for that link Anonymous Poster. That looks like it will work great. I didn't know that the sleep() method was so off that I couldn't even use it for windows games.

Share this post


Link to post
Share on other sites
Well I've never felt a need to try GAGE as I've settled nicely with lwjgl and it's timer. Capping just to 60hz has always been very smooth on my win xp. But after reading your (jake's) posts more carefully I noticed that you're gonna stick with 1.4 and standard api so I guess GAGE would be the ideal choice.

Quote:

Not sure if I know exactly how to do this. Do you have a code snippet that I can look at as example?


Something like:

class Game implements KeyListener {
boolean[] keys = new boolean[256];

public void keyPressed(KeyEvent e) {
keys[e.getKeyCode()] = true;
}

public void keyReleased(KeyEvent e) {
keys[e.getKeyCode()] = false;
}

// Called constantly in your main loop
public void input() {
if(keys[KeyEvent.VK_UP]) {
y -= dy;
}
}
}

Share this post


Link to post
Share on other sites

This topic is 4598 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this