954,496 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

help please, quick !!!! SC included

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
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

deadoh
Newbie Poster
1 post since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

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.

Stoned_coder
Junior Poster
164 posts since Jul 2005
Reputation Points: 19
Solved Threads: 5
 

include conio.h and use getch();

freemind
Junior Poster in Training
62 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 
some header files do not work on this compiler, such as #include


He has no conio.h

Stoned_coder
Junior Poster
164 posts since Jul 2005
Reputation Points: 19
Solved Threads: 5
 

ups.. :rolleyes:

freemind
Junior Poster in Training
62 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You