C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 07-29-2008, 08:46 AM   #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("%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...
jumbo2410 is offline   Reply With Quote
Old 07-29-2008, 08:53 AM   #2
Deathray Engineer
 
MacGyver's Avatar
 
Join Date: Mar 2007
Posts: 3,211
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:

Quote:
Example question goes here.

[code]#include <stdio.h>

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

More example stuff here.
__________________
MacGyver is offline   Reply With Quote
Old 07-29-2008, 02:16 PM   #3
Maz
Registered User
 
Join Date: Nov 2005
Posts: 146
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
Maz is offline   Reply With Quote
Old 07-30-2008, 12:42 AM   #4
Registered User
 
gavra's Avatar
 
Join Date: Jun 2008
Posts: 208
Do you care about C standarts?
__________________
gavra.
gavra is offline   Reply With Quote
Old 07-30-2008, 06:25 AM   #5
Registered User
 
Join Date: Jun 2008
Posts: 5
yes I do...
jumbo2410 is offline   Reply With Quote
Old 07-30-2008, 06:35 AM   #6
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
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.
matsp is offline   Reply With Quote
Old 07-30-2008, 06:49 AM   #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!
jaypeebee18 is offline   Reply With Quote
Old 07-30-2008, 07:16 AM   #8
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
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.
matsp is offline   Reply With Quote
Reply

Tags
basic variables, c program, game, programming, snake program

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 12:28 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

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