File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Game Development and the fly likes Graphics Lag on Certain Computers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "Graphics Lag on Certain Computers" Watch "Graphics Lag on Certain Computers" New topic

Graphics Lag on Certain Computers

Justin Vasquez

Joined: Jul 05, 2011
Posts: 5

Hi, I've been learning how to program in Java for a while now, and made a small game to see what I could implement (Here's the compiled version: Burger)
I'm obviously doing something wrong with the screen refreshing, and I need a more efficient method. I made a separate thread that repaints the screen, and it sleeps for 3 miliseconds. If I make it sleep more, the game is very slow (the guy moves one pixel at a time, by the way).
On certain computers, the game runs fine (you can get 40 + points). On others, you can barely get a piece of food before dying. Can anyone help me with this? I've heard of buffered images (I just use images) , but I have no idea how to use them.
Also, I wouldn't mind receiving some feedback on the game and what I should add
Stephan van Hulst

Joined: Sep 20, 2010
Posts: 4635

I have to say, I really like the concept of your game.

It runs smoothly for me, maybe you can post your code and we can see where you can make some improvements.

The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Justin Vasquez

Joined: Jul 05, 2011
Posts: 5

Here is the main part of the code (although I cut a lot)

I also have a class called Stick, which is basically the character. This class loads the images and handles which one to use (I cut some stuff here too)

And this is the Mover class. It's the Action Listener for the game. I have a boolean array that represents the arrow keys. If one is pressed, it becomes true and all the others become false.
Again, it's incomplete.

I also have a Meal class, which handles the food that appears on-screen. Since I'm having problems with the graphics, I didn't post that.
I hope this is enough to find a solution.

I agree. Here's the link:
subject: Graphics Lag on Certain Computers
It's not a secret anymore!