Find the answer to your Linux question:
Results 1 to 6 of 6
Hello everyone, I just started learning C, and to test and refine my skills, I started writing a Pong clone. So far, everything's going rather well, however, I have three ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Engineer Javasnob's Avatar
    Join Date
    Jul 2005
    Location
    Wisconsin
    Posts
    942

    Wrting Pong in C


    Hello everyone, I just started learning C, and to test and refine my skills, I started writing a Pong clone. So far, everything's going rather well, however, I have three minor questions. If anyone could provide any insight into these, I would be very appreciative.

    1: I don't know any graphics in C! What's a good graphics library for C that's simple?
    2: I know about time.h, but how can I access time on the millisecond level (this is for physics engine updates)
    3: Finally, as far as user input goes, how do I get a character of input without blocking the current thread?

    Thanks in advance!

  2. #2
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035

    Re: Wrting Pong in C

    Quote Originally Posted by Javasnob
    Hello everyone, I just started learning C, and to test and refine my skills, I started writing a Pong clone. So far, everything's going rather well, however, I have three minor questions. If anyone could provide any insight into these, I would be very appreciative.

    1: I don't know any graphics in C! What's a good graphics library for C that's simple?
    2: I know about time.h, but how can I access time on the millisecond level (this is for physics engine updates)
    3: Finally, as far as user input goes, how do I get a character of input without blocking the current thread?

    Thanks in advance!
    1. For basic text-mode graphics ncurses is common. For more advanced, there's always good old OpenGL

  3. #3
    Linux User benjamin20's Avatar
    Join Date
    Oct 2004
    Location
    jacksonville beach FL
    Posts
    317
    actualy, i too wonder a bit abnout graphics. is there a standard library that you can use (in c or c++) that wil let you write to the same line? like when i update my system in gwntoo there is this spining thingy thats made out of /-\|. it stays in the same space and makes a spinning motion. so, is there a way of writing over a previously written spot. if i cant do it in a way thats compleatly cross compatible with all operations sytems than itn not what im talking about (like how stdio is).
    nVidia G-Force 6600GT (bfg) pci-e: amd 64 2000+ (939): 1024 corsair ram: 2X 80gb seagate harddisk SATA: plextor cd/dvd-read/write cdrom SATA

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Oct 2005
    Posts
    31

    Game Programming

    In order to handle keyboard/joystick events and graphics you should probably consider SDL. Its the simple direct media layer library(linux answer to directx).

  6. #5
    Just Joined!
    Join Date
    Oct 2005
    Location
    Australia
    Posts
    1
    SDL (simple direct media layer) sounds perfect for this.

    Also about the backspace its simply just a \b for example


    char progress[] = {'|', '\', '-', '/'};
    int count_progress;

    for(count_progress = 0; count_progress < 1000; count_progress++)
    printf("%c\b", progress[count_progress]");


    thats just a quick example which wont work, and if it does then it will be really fast.. anwyays \b takes the curser back one chacter

  7. #6
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    Quote Originally Posted by tamrix
    SDL (simple direct media layer) sounds perfect for this.

    Also about the backspace its simply just a \b for example


    char progress[] = {'|', '\', '-', '/'};
    int count_progress;

    for(count_progress = 0; count_progress < 1000; count_progress++)
    printf("%c\b", progress[count_progress]");


    thats just a quick example which wont work, and if it does then it will be really fast.. anwyays \b takes the curser back one chacter
    You'd want to do:
    Code:
    printf&#40;"%c\b", progress&#91;count_progress % 4&#93;&#41;;
    instead, so that you keep printing progress[0] through progress[3]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •