Pong!

This is a discussion on Pong! within the C++ Programming forums, part of the General Programming Boards category; i'm using Turbo C++ 3, rather old compiler. the old EGVGA.BGI Driver. just using basic graphics here. fillellipse and such. ...

  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.

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    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.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,672
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 10: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21