Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2011
    Posts
    62
    Rep Power
    0

    Default Threading in games

    Should a game be built like a standard GUI application according to this description: Lesson: Concurrency in Swing (The Java™ Tutorials > Creating a GUI With JFC/Swing)

    However, I have never seen that in any game programming tutorial. What would be the best practice here?

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,786
    Rep Power
    5

    Default Re: Threading in games

    IMHO, it doesn't matter what the application is doing, if it involves multiple threads and Swing then you need to follow the guidelines cited.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Join Date
    Aug 2011
    Posts
    62
    Rep Power
    0

    Default Re: Threading in games

    Thank you. Do I need a further thread for playing audio? The audio playback functions seem to have their own built-in threads, at least that is what my thread testing function says:
    Created GUI on EDT? true
    Threads: 6
    Name: main
    Priority: 5
    Name: AWT-Shutdown
    Priority: 5
    Name: AWT-Windows
    Priority: 6
    Name: AWT-EventQueue-0
    Priority: 6
    Name: Java Sound Event Dispatcher
    Priority: 5
    Name: Direct Clip
    Priority: 6

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,786
    Rep Power
    5

    Default Re: Threading in games

    Unfortunately, I don't have any experience with Audio in Java. However, I would assume that the audio threads are similar in function to the EDT for events.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,993
    Rep Power
    9

    Default Re: Threading in games

    Quote Originally Posted by noodle_variation_187-X View Post
    Thank you. Do I need a further thread for playing audio? The audio playback functions seem to have their own built-in threads, at least that is what my thread testing function says:
    It's going to depend on a lot of your context.

    I'd recommend starting small- get a basic game (pong, pacman, tetris, etc) working using a Swing Timer. Use that as a base to build upon, and you can add threading, sounds, whatever.

    It's a little hard to talk about "best practices" when you haven't shown us any code or mentioned any framework or library.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Voxel Based Games
    By TANKDS in forum New To Java
    Replies: 9
    Last Post: 09-01-2013, 07:32 AM
  2. LG 840 games are cut off at the bottom....
    By jrod102507 in forum Forum Lobby
    Replies: 1
    Last Post: 01-10-2013, 10:39 AM
  3. how to put score in my snake games
    By palie in forum New To Java
    Replies: 1
    Last Post: 04-13-2012, 09:49 PM
  4. Help! Anagram Games
    By geeky123 in forum New To Java
    Replies: 6
    Last Post: 10-13-2008, 05:16 PM
  5. problem for games
    By Gunther in forum Java 2D
    Replies: 4
    Last Post: 12-25-2007, 09:42 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •