Im new to programming and java and these forums so please bare with me, below is the code i am currently working on (following a textbook) but ive checked over the code and as far as i can see everything is correct but when i run the applet i just get a black and white flashing screen. I am assuming that it is something to do with the buffer or painting but i just cant figure out what. If anyone could point me in the right direction that would be great (the applet is a VERY simple version of asteroids which i will improve upon but need to get this portion working first)
If you have any ideas awesome shove me in the right direction if not thanks for looking anyway
the idea is to let the game thread do all the updating: the updating of the objects AND
the updating of your BufferedImage. So it is the run() method where all the updating should
take place; not in the update(Graphics g) method.
And when that is done, you issue a repaint(), which, IIRC, issues first
the update(g) method, and then the paint(g) method.
So, do all the updating of both the objects and the BufferedImage in the run() method,
then issue repaint(), and all that you have to do then is:
And you could try to experiment with Thread.sleep(..); Java is fast enough to let you do more than 50
redraws per second. I remember from the old CRTs that a refresh rate of 50 caused a lot
of flickering. Well, that should be far less with the current LCD's of course.
I hate signatures!
I'm gonna teach you a lesson! Start by looking at this tiny ad: