• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Graphics Lag on Certain Computers

 
Greenhorn
Posts: 5
Notepad Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Justin Vasquez
Greenhorn
Posts: 5
Notepad Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.



 
reply
    Bookmark Topic Watch Topic
  • New Topic