|
| ICANSEEYOU7687 (6) | |
| For my class I have to make the game snake. And I have the snake drawing with linked lists correctly and it all works pretty well except it draws everything way too fast.... By the way this is in C, not C++ So I need some sort of wait function... I found void wait ( int seconds ){ clock_t endwait; endwait = clock () + seconds * CLOCKS_PER_SEC ; while (clock() < endwait) {} } on the site, but could not get it to work.And I included stdlib and time.h. But im not that great of a programmer, so if someone could help me with this function I think I got the rest of the homework down. thanks! | |
| demosthenes2k8 (128) | |
| If it's for windows you could try Sleep(); inside windows.h but if you're sane, then you'll want to make sure that CLOCKS_PER_SEC is valid (should be 1000 IIRC) Post your errors? | |
| ICANSEEYOU7687 (6) | |
| I tried including windows.h #include <windows.h> and it says it cant find it.... maybe its cause we are using eclipse and not visual studios? | |
Last edited on | |
| helios (4790) | ||
ICANSEEYOU7687: You are using Windows, right? Not Linux? Because that header, as its name suggests, only exists for Windows. Other than that, I don't know what could be failing. Every compiler for Windows except Cygwin comes with windows.h. Maybe you need to set your compiler search paths manually with Eclipse? | ||
Last edited on | ||
| demosthenes2k8 (128) | |
| A screwed up implementation Again, error messages would be helpful. | |
| ICANSEEYOU7687 (6) | |
| yes im using windows, haha windows 7 actually. But if I cannot get this to work, I may just make a count function, and make an if statement that says something like... If(count % 3 == 0){ drawsnake() } etc.... so only every 3 cycles it would draw the snake. | |
| Mythios (753) | |||
Make a new program - see if something like this works. It could possibly be you're calling something in the wrong spot.
| |||
Last edited on | |||
| Duoas (2964) | |
| The problem with that delay function is that it spends clock cycles. Unless you have good reason not to, use the OS forms to delay: http://www.cplusplus.com/forum/unices/10491/page1.html#msg49054 And, FWIW, "wait" is a really bad name for a function, because it might already be used elsewhere. Hope this helps. | |
| demosthenes2k8 (128) | |
| Erm...couldn't you just get rid of foo and use the value i from the for loop? | |
Registered users can post in this forum.
