Click here to Skip to main content
15,920,438 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
c code for snake game for visual studio 2012 ultimate.
i found some for turbo but unable to make them work on visual studio 2012.
OriginalGriff 16-Feb-13 3:27am    
What have you tried? Where are you stuck?
We don't just provide you with a complete app - we help you to solve problems.
moni5592 16-Feb-13 3:52am    
yup but that is my problem. Since I am new to visual I am unable to build the same programs which I run successfully on turbo.
OriginalGriff 16-Feb-13 4:08am    
Yes - that is kind of the idea :laugh:

It's a different way of doing things - the more so depending on what version of which "turbo" you were talking about (it goes back to Turbo-C for Dos) so the whole way programs work and are designed has changed, not to mention the operating systems!

If you want to write programs on VS2012 (or even VS2008!) I wouldn't start with C, not any more. There are much, much easier ways to get started and working - C is very, very outdated in the PC / mobile world these days.

What are you trying to do? (Not "write a snake program", but why do you want to write a snake program?)

Take a look at this one:[^]

Implementing Snake

Games like Snake where objects are moving over a 2D field can represent the game objects either in a 2D grid or as a single dimension array of objects. Object here meaning any game object not an object as used in object oriented programming.

View the Snake Source Code ()[^]
Download the Snake Executable plus files (zip) ()[^]
Share this answer
merano 17-Feb-13 16:34pm    
This Solution does only support a-s-d-w keys no arrow keys, why ?

Here a solution for that:

keypressed = event.key.keysym.sym;

// ##########################
// support arrow keys
keypressed = LEFTKEY; // alternate SDLK_a
keypressed = RIGHTKEY; // alternate SDLK_d
case SDLK_UP:
keypressed = UPKEY; // alternate SDLK_w
keypressed = DOWNKEY; // alternate SDLK_s
// ##########################
Leo Chapiro 18-Feb-13 1:01am    
@merano: Good point, thank you for this advice even if the code is not mine :) I also see no reason why the arrow keys are not supported by the author - that makes no sence ...
You find an object oriented solution based on class CSnake here:

Snake Game in a Win32 Console[^]
Share this answer
Leo Chapiro 18-Feb-13 0:55am    
I saw this one, seems not to be a good solution, see the comments to this article like e.g.: "Im a student and that source would make me think "Wow what a noob", the problem is I think you know that this is bad code and put it up for beginner students to understand (as there familiar with poor structure)" :(
Here is a Discussion about snake (in german)[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900