code review (movement)

This is a discussion on code review (movement) within the Game Programming forums, part of the General Programming Boards category; Im working on my first game (pong :d), and i was wondering if this code for movement of my paddle ...

  1. #1
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,109

    code review (movement)

    Im working on my first game (pong :d), and i was wondering if this code for movement of my paddle is written good.
    The movement works great in the game but i'm using alot of non-standard functions like kbhit etc, is there a way to make it more portable?
    Code:
    int control;
    
    do{
       draw_paddle(px,py,20);
       control=getch();
    
       while(px>73 && control == '4' ){
         draw_paddle(px,py,20);
         wait_for_retrace();
         draw_paddle(px,py,0);
         px--;
    
         if(kbhit () ){
    
           control = getch();
    
           while(px<247 && control =='6' && !kbhit() ){
               draw_paddle(px,py,20);
               wait_for_retrace();
               draw_paddle(px,py,0);
               px++;
               }
           }
    
       }
    
       while(px<247 && control =='6'){
         draw_paddle(px,py,20);
         wait_for_retrace();
         draw_paddle(px,py,0);
         px++;
    
         if(kbhit () ){
    
            control = getch();
    
            while(px>73 && control == '4' && !kbhit() ){
                 draw_paddle(px,py,20);
                 wait_for_retrace();
                 draw_paddle(px,py,0);
                 px--;
                 }
         }
       }
    
    
    }
    while( control != '7' );
    I hope indentations are well, becaus i just changed all my tabs to spaces to post here (since tabs turn out very long on this board :s).
    note: borders of gae are for x=60 and x=260, but as the draw_paddle function takes the middle of the paddle and starts drawing from there you have to do 160-(length_of_paddle)=247, same counts for the x=60 (just that you know ).

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    What graphics library are you using?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,109
    13h mode so no actual graphix library.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code Review for upcoming contest
    By Darryl in forum Contests Board
    Replies: 2
    Last Post: 02-28-2006, 01:39 PM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. Problem : Threads WILL NOT DIE!!
    By hanhao in forum C++ Programming
    Replies: 2
    Last Post: 04-16-2004, 01:37 PM
  4. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 03:28 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM

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