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 9234053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:41:57+00:00 2026-06-18T06:41:57+00:00

I have been trying to create pong game using ncurses library on a terminal

  • 0

I have been trying to create pong game using ncurses library on a terminal. I have successfully created the two bars for both the players. The problem is that when both the players press their corresponding keys, only one of them was moving.

So, I searched the net and found that we can use windows, where we can have logical curser to each window and hence execute the commands from the players parallely. The code-snippet of my program looks as follows:

pthread_t player_1, player_2;
pthread_create(&player_1, NULL, (void*)&player_1_move, (void*)pl_window);
pthread_create(&player_2, NULL, (void*)&player_2_move, (void*)p2_window);

while(1)
{
    char c=getch();
    if(key is from p1)
         //signal player_1 thread to refresh the bar position

    if(key is from p2)
         //refresh it for player_2 by signaling 2nd thread..

}
//here player_1_move and player_2_move are the functions for changing the bar position         for each of the players..I have created two windows in which i draw these bars, which i haven't shown in my code..

The problem is that though I use the pthreads, i still can’t see both moving simultaneously, when both players press at-a-time.

Any suggestions plz…

  • 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-06-18T06:41:58+00:00Added an answer on June 18, 2026 at 6:41 am

    As Craig said… a terminal doesn’t handle when 2 keys are pressed at the same time. It will choose any one of them.. That was the exact problem. and can’t be resolved even if we use pthreads.

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

Sidebar

Related Questions

I have been trying to create an XML using the simplexml library (v2.6.2) http://simple.sourceforge.net/home.php
I'm new to both android and game development and have been trying to create
I have been trying to create a ListView which I can sort using drag
I have been trying to create an observable tweeter feed using tweetsharp with the
I have been trying to create a hyperlink using a variable defined earlier in
I have been trying to create rotating object using jQuery and without any other
I have been trying to create a 2D array of vector for a game.
I have been trying to create an array of a class containing two values,
I have been trying to create a decorator that can be used with both
I have been trying to create a user control library which simply has styled

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.