Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (120)
games submitted by our members
Games in WIP (577)
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  
  Should I just use one thread - the main thread?  (Read 1843 times)
0 Members and 1 Guest are viewing this topic.
Offline AvivC

Junior Duke


Projects: 1



« Posted 2014-03-15 15:19:58 »

When designing a game, apart from resource loading and very time-consuming tasks, does it make sense to just run the entire game on the main thread?
Offline SHC
« Reply #1 - Posted 2014-03-15 15:24:32 »

No. Game Logic is a very expensive task with Collision Detection included. If you are on EDT, it hangs your game after a bit of playing.

PS: You seem to be too much interested in Java2D and Swing. I won't recommend them due to the cost of performance. But however, you can checkout my engine I've made years back (almost 4 years now) which uses Swing. It's located here at https://code.google.com/p/game-engine-for-java/

Offline AvivC

Junior Duke


Projects: 1



« Reply #2 - Posted 2014-03-15 15:37:39 »

I'm talking about having the entire game run on a non-EDT thread, not on the EDT.

Some people here recommend this approach, to only use one thread.

"As some other people said, keep it simple, single-threaded, don't use invokeLater..."
"When developing Java2D, always use one thread".

Do you disagree?

(And I will start using a library when I'll get a bit more experienced Smiley LWJGL seems very common and therefore reliable).
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline SHC
« Reply #3 - Posted 2014-03-15 16:06:02 »

Yeah, it works, but not for bigger games. Your game will start lagging soon enough it becomes somewhat sophisticated. Also, knowledge on Java2D won't help much in LWJGL, because it uses OpenGL. Java2D and OpenGL are two different APIs. So if you are thinking of learning LWJGL, I suggest my own tutorial series. Heres a link to the Contents page.

LWJGL Tutorial Series - Contents

Offline Phibedy

Senior Duke


Medals: 9



« Reply #4 - Posted 2014-03-15 16:16:27 »

Don't care about performance if you don't have issues.
Have you ever created a game?
No offence, just a little thought I have, a lot of people spend to much time on theorie and never get something done.

I think all of the games you see on jgo are perfectly fine with one thread. Using multithreading efficiently is quite hard and you might get a lot of troubles Smiley
Offline Drenius
« Reply #5 - Posted 2014-03-15 16:18:36 »

And java2D helps learning making games with lwjgl. You can learn how to render your game without having to setup all the screen related stuff in lwjgl.
Offline princec

JGO Kernel


Medals: 404
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #6 - Posted 2014-03-15 16:50:19 »

And java2D helps learning making games with lwjgl. You can learn how to render your game without having to setup all the screen related stuff in lwjgl.
But that's the easy bit with LWJGL....

Cas Smiley

Offline AvivC

Junior Duke


Projects: 1



« Reply #7 - Posted 2014-03-15 17:54:02 »

Yes, I have made games Smiley But not complex ones yet.
Offline StumpyStrust
« Reply #8 - Posted 2014-03-16 02:40:34 »

Until things get slow do NOT worry about this.

Fact is, unless you are actually making a 'real' game (not tinkering or some small project) you will never need to worry about multithreading your game.

Offline princec

JGO Kernel


Medals: 404
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #9 - Posted 2014-03-16 10:43:20 »

Anecdotal evidence:

I've only just started to use threads in games after 12 years for our latest magnum opus, Battledroid, and only because we're now dealing with entity counts in the thousands and sprite counts in the hundreds of thousands. All the games we made before it - even Revenge of the Titans with its hundreds of buildings and enemies and flying bullets - use a single thread. RoTT being the most complex, it used maybe a few thousand sprites in a typical frame. All our games run at a smooth 60Hz.

Cas Smiley

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.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (43 views)
2014-10-16 15:22:06

Norakomi (33 views)
2014-10-16 15:20:20

lcass (37 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (66 views)
2014-10-14 00:35:47

TehJavaDev (59 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (85 views)
2014-10-11 22:30:10
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!