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

Recommended Answers

All 4 Replies

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.

include conio.h and use getch();

some header files do not work on this compiler, such as #include<conio.h>

He has no conio.h

ups.. :rolleyes:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.