Thread: Simple Snake Program Purely On "C"

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    5

    Cool Simple Snake Program Purely On "C"

    I would just want to ask questions on how to partly program snake using my current knowledge of "if-else, for, switch, while, printf/scanf, counters and using only int, float and char as variables... and also what to #include like <stdio.h> and what more...??? If you think I can with my knowledge of such...how should i start?? I mean it's my first time prgramming a GAME in C so i'm not yet familiar... with how to use other functions needed such as time.h and gotoxy...can u give me some tips or help probably?

    a sample program i programmed.. we are mostly mathematical based so GAMES are not familiar to me in programming:

    /*Asks the user to input a binary number then converts it into decimal*/
    Code:
    #include<stdio.h>
    main()
    {     int nBin, nDec, nMult, nDigit;
          printf("Enter Binary Number:");
          scanf("&#37;d", &nBin);
          
          nDec=0;
          nMult=1;
          
          while(nBin!=0)
          {nDigit=nBin%10;
          nDec+=nDigit*nMult;
          nMult*=2;
          nBin/=10;
          }
          printf("Decimal: %d", nDec);
          getchar();
          getchar();
    }
    note: BTW.., i'm just a freshman in college so don't be so harsh in programming terms.. i mean show tips on very basic c like the program i made... if you would like... thanks =D
    Last edited by jumbo2410; 07-29-2008 at 09:05 AM. Reason: MacGyver told me...

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Figure out how to use code tags. This is the 2nd time. Put them around the code only, not your entire post, because it messes up the format and makes my eyes grow weaker trying to read it.

    And that's not what you want, right? Of course you don't want me going blind.

    Example:

    Example question goes here.

    [code]#include <stdio.h>

    int main(void)
    {
    return 0;
    }[/code]

    More example stuff here.

  3. #3
    Registered User Maz's Avatar
    Join Date
    Nov 2005
    Location
    Finland
    Posts
    194
    With plain printf it will be hard. You do want to use some non standard C library for mowing your worm. I guess you could read some reference manual for ncurses library, and accomplish what you want with it

  4. #4
    Registered User gavra's Avatar
    Join Date
    Jun 2008
    Posts
    265
    Do you care about C standarts?
    gavra.

  5. #5
    Registered User
    Join Date
    Jun 2008
    Posts
    5
    yes I do...

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Then you will struggle - the C standard library has no options for moving the cursor around on the screen.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Jul 2008
    Posts
    7
    i think you can use some libraries such as conio.h, time.h, stdlib.h, and graphics.h...
    DJ!

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by jaypeebee18 View Post
    i think you can use some libraries such as conio.h, time.h, stdlib.h, and graphics.h...
    DJ!
    Yes, but conio.h is not part of the C standard - which is why I said what I said earlier. time.h and stdlib.h [if it follows the actual C standard, that is] does not contain any functions to move the cursor on a console screen.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  2. [Help] Simple Array/Pointer Program
    By sandwater in forum C Programming
    Replies: 3
    Last Post: 03-30-2007, 02:42 PM
  3. simple silly program
    By verbity in forum C Programming
    Replies: 5
    Last Post: 12-19-2006, 06:06 PM
  4. Idiot Trying To Write A Simple Program
    By verd in forum C Programming
    Replies: 4
    Last Post: 02-05-2005, 07:06 AM
  5. Simple simple program
    By Ryback in forum C++ Programming
    Replies: 10
    Last Post: 09-09-2004, 05:48 AM

Tags for this Thread