Snake..

Hi. I'm new to this forum and I need some help. I just want to clear things out that I'm not asking for codes. I need to make a snake game. I was thinking on how to create the body and make it move? Maybe the body would just be a simple printf, I think? But my real problem is how I would make it move. I was doing research for the past few days and I'm having a hard time finding some codes to make an object move in C. Any advice would be much appreciated, thank you.
Obligatory link: http://cplusplus.com/articles/G13hAqkS/ - you'll save yourself a lot of pain.

Now, if you do insist on doing it the hard way, to make an object move you have to redraw it a bunch of times. For example:
1
2
3
4
5
6
7
8
int x = 0;
while(x < 80){
   puts("\n\n\n\n\n\n\n\n\n\n");//move down by 10 rows
   for(int i = 0; i < x; i++) putchar(' ');//move right by x columns
   putchar('#');//draw an object
   puts("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");//make sure to fill the screen
   x++;//change x for the next frame
}
(not tested. it should show a # moving right)
Though this could be improved using platform specific functions.
Thank you for replying. I would study and test these codes then would get back to you. Thanks again.
I'm sorry, I don't know what the link you gave is for. Could you explain what's it for?
The link was meant to tell you that there are ways to do this that are easier and look a lot better. Unless you have an actual assignment to make a snake in console..
Topic archived. No new replies allowed.