Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6896609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:03:54+00:00 2026-05-27T07:03:54+00:00

After yesterdays poorly chosen question I’m trying again. I have a tic tac toe

  • 0

After yesterdays poorly chosen question I’m trying again.

I have a tic tac toe program in the works purely for the purpose of learning network play.

My understanding of twisted was that I should have a server class run the reactor and then have each player connect to it as a client (the server being a separate entity). Given the comments in my last question I suspect that I’m going about this in completely the wrong way.

What should I be looking to do and which tutorials or documentation should I be focusing on?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:03:55+00:00Added an answer on May 27, 2026 at 7:03 am

    The difficulty of combining pygame with twisted is the issue of who controls the mainloop. This usually comes up with wanting to combine any sort of UI (GTK, Tkinter, etc) mainloop with Twisted, and PyGame is no different.

    What I would suggest, is that since network latency is important and since twisted has a very good scheduling framework, is that you let the twisted reactor run and take control of the mainloop, and then use a LoopingCall to allow you to process events from pygame.

    At the very basic:

    from twisted.internet.task import LoopingCall
    
    DESIRED_FPS = 30.0 # 30 frames per second
    
    def game_tick():
       events = pygame.events.get()
       for event in events:
          # Process input events
       redraw()
    
    # Set up a looping call every 1/30th of a second to run your game tick
    tick = LoopingCall(game_tick)
    tick.start(1.0 / DESIRED_FPS)
    
    # Set up anything else twisted here, like listening sockets
    
    reactor.run() # Omit this if this is a tap/tac file
    

    While this seems simple at first, it comes with dangers. If you spend a lot of time doing processing in your game tick, then you run the risk of starving the twisted reactor, making it unable to process events. If you need to have timed events, don’t block, but instead make use of twisted tools like reactor.callLater. The more you can avoid blocking, the more responsive your application will be. This is far too many things to describe in a few paragraphs, as programming for twisted is a mindset that really takes some getting used to if you’ve never done programming for asynchronous or non-blocking libraries.

    For a more complete example, check out “gam3” for a game library for interfacing with twisted (including a world clock for simulation events) and a sample game made by one of the twisted developers to show how to integrate twisted and pygame.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Yesterday I asked the question on how I should save my files. After some
Seems like just yesterday I had this same problem with Play! v1. After trying
After some time researching and trying different things I still cannot get my @ExceptionHandler
After I click update in the grid view, the code works successfully. But when
I asked a similar question like this yesterday but after waiting for ever I
I'm trying since yesterday how to close external dialog after click on button this
I'm trying to request any records from a table that appear on or after
After the big news yesterday, I've been trying to find a solid article about
After posting a question yesterday I thought I had this cleared up but I'm
Apologies for asking a related question yesterday, but after some sleep I've simplified my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.