Screen flickering/flashing randomly

So i’m following Ian Cinnamon’s book “Video Game Programming for the Evil Genius” and currently i’m on the racing game section. I’ve copy-pasted his code into my program just to check if it works, and it doesn’t. The game starts flashing and flickering randomly, i’m guessing it has something to do with the repaint() functions in the Move1 and Move2 threads. But I have no idea how to fix it, and he doesn’t acknowledge the error in his book. Here is the code. http://pastebin.com/rzq1JNx0

Also, my friend told me to double-buffer it, but i have no idea how to go about implementing that. Any ideas?

I simply blame for multiple threadings.

Tried reducing it to one thread, still flickers. :frowning:

My goodness that’s dreadful code. Use that book to fix a wobbly table or to put your coffee on.

My eyes T____T

I agree with sproingie, that is absolutely terrible code. However the problem is not the multi-threading, it’s because you are not double buffering.

However, don’t even bother learning anything more with that book…

Threads are likely exacerbating it – among its other sins, it’s calling paint() directly from the threads.

No it’s calling repaint() ;D

Take a look to JGO basic game. It’s better, extendable and readable.

Ok, thanks for your help. Can’t believe that book has such high ratings on Amazon.

Stupid n00bs who think its good XD

N00bs copy paste the code and it works, and they change sprites and they make a game.

A language, book, or library will get high rating easily and quickly when it can embrace lot of n00bs because it makes everything easy for them.

whose code Notch copied? ???

Oh. LoL ;D