my group has made two versions of the game pong for c++
the first version uses a two dimensional character array to represent the playing field and the second uses 966 individual characters to represent the 14x69 playing field
both versions work fine, but the array style one's source code is much shorter
THE PROBLEM we are having is getting user input without the user having to press enter
currently, everytime the user wants to move the paddle he/she must press enter after typing the input and the ball moves one unit
if you could help us with this problem it would be greatly appreciated
speed in helping us with this problem would also be appreciated as the project is due Friday morning
we are using telnet, and the name of the compiler is Red Hat Linux release 7.3 (Valhalla) (i think)
some header files do not work on this compiler, such as #include<conio.h>
if you try to fix any of the versions, try to fix the array version
which is below , it uses the 'a' and 'q' buttons to move the paddle up and down
Array version PONG (source code): http://www.koolpages.com/m3ller/pang2.c

the other version uses the 'w' and 'q' buttons to move the paddle: http://www.koolpages.com/m3ller/pang.c

from the cprogramming.com FAQ......

vvv's mygetch

#include <stdio.h> 
#include <termios.h> 
#include <unistd.h> 

int mygetch(void) 
{
  struct termios oldt,
                 newt;
  int            ch;
  
  tcgetattr( STDIN_FILENO, &oldt );
  newt = oldt;
  newt.c_lflag &= ~( ICANON | ECHO );
  tcsetattr( STDIN_FILENO, TCSANOW, &newt );
  ch = getchar();
  tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
  
  return ch;
}

I have no idea if it works, im a windows guy.

This article has been dead for over six months. Start a new discussion instead.