Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (525)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (594)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Screen flickering/flashing randomly  (Read 3603 times)
0 Members and 1 Guest are viewing this topic.
Offline Xardov

Senior Newbie





« Posted 2012-03-31 12:54:33 »

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?

Offline ReBirth
« Reply #1 - Posted 2012-03-31 13:00:54 »

I simply blame for multiple threadings.

Offline Xardov

Senior Newbie





« Reply #2 - Posted 2012-03-31 14:47:22 »

Tried reducing it to one thread, still flickers. Sad
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline sproingie

JGO Kernel


Medals: 202



« Reply #3 - Posted 2012-03-31 15:25:50 »

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

JGO Kernel


Medals: 355
Projects: 3
Exp: 5 years


I'm the King!


« Reply #4 - Posted 2012-03-31 16:00:42 »

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...

Offline sproingie

JGO Kernel


Medals: 202



« Reply #5 - Posted 2012-03-31 17:36:42 »

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


Online ra4king

JGO Kernel


Medals: 355
Projects: 3
Exp: 5 years


I'm the King!


« Reply #6 - Posted 2012-03-31 18:00:26 »

Threads are likely exacerbating it -- among its other sins, it's calling paint() directly from the threads.
No it's calling repaint() Grin

Offline ReBirth
« Reply #7 - Posted 2012-04-01 03:32:50 »

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

Offline Xardov

Senior Newbie





« Reply #8 - Posted 2012-04-01 13:46:18 »

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

JGO Kernel


Medals: 355
Projects: 3
Exp: 5 years


I'm the King!


« Reply #9 - Posted 2012-04-01 17:06:37 »

Stupid n00bs who think its good XD

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ReBirth
« Reply #10 - Posted 2012-04-02 00:30:37 »

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

Offline ReBirth
« Reply #11 - Posted 2012-04-02 01:37:09 »

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? Huh

Offline ReBirth
« Reply #12 - Posted 2012-04-02 02:45:42 »

Oh. LoL Grin

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (71 views)
2014-11-26 15:22:04

toopeicgaming1999 (60 views)
2014-11-26 15:20:36

toopeicgaming1999 (14 views)
2014-11-26 15:20:08

SHC (27 views)
2014-11-25 12:00:59

SHC (25 views)
2014-11-25 11:53:45

Norakomi (31 views)
2014-11-25 11:26:43

Gibbo3771 (25 views)
2014-11-24 19:59:16

trollwarrior1 (38 views)
2014-11-22 12:13:56

xFryIx (77 views)
2014-11-13 12:34:49

digdugdiggy (55 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!