Thread: Pong!

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    14

    Pong!

    i'm using Turbo C++ 3, rather old compiler. the old EGVGA.BGI Driver. just using basic graphics here. fillellipse and such. i have a pretty basic question..most of you could probably help.

    I've done the menu, and drawn the pong table, and i have the paddle working. I need to know how to make it so the ball is able to move at the same time as you are able to control the paddle, and for the computer controlled paddle to be running at the same time. this paddle will just be moving according to the movements of the ball. any hints will be appreciated.
    yo

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Code:
    void MainGameLoop(void)
    {
      UpdateBall();
      DoKeyboardInput();
    
      DrawBoard();
      DrawBall();
      DrawPaddles();
    }
    
    void DoKeyboardInput(void)
    {
      if (!kbhit())
      {
        int ch=getch();
        
        if (ch==PADDLE_DOWN_CODE) MovePaddle(DOWN);
        if (ch==PADDLE_UP_CODE) MovePaddle(UP);
      }
    }
    
    ...
    ...

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    14
    Is there any way possible for 2 player mode, or is it impossible to hit more than one key at one time? For the controls of both players.
    yo

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    I'd suggest a test program calling kbhit() and getch(), and you pressing several keys at once to see what happens
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Space Pong (Debug) Release
    By Jeremy G in forum Game Programming
    Replies: 6
    Last Post: 10-02-2005, 07:14 PM
  2. The Story Of Pong (my game cookie)
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 05-16-2005, 11:14 PM
  3. pong
    By lambs4 in forum Game Programming
    Replies: 2
    Last Post: 06-02-2003, 04:00 PM
  4. Battle Pong
    By DOlson in forum Game Programming
    Replies: 13
    Last Post: 01-08-2003, 11:32 PM
  5. God pong -update
    By gamegod3001 in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 09-03-2001, 09:16 PM