I have no idea at all, nothing, on how to make a full, running and working snake game.

I tried starting off using character symbols in ASCII to draw its head and body, but from there on I have no clue on how to make it move with out having to redraw the screen and rewrite its position after every key press handler/event or detection.

I have no idea on how to do this. And I mean do it with out extended graphics, only C++'s native things, and it's possible because others have done it and I really could use some small tips on how to get movement, collision and such. And please be descriptive and explain well, if so. Thanks.

Here's my useless code so far.....

#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
 int k = WM_KEYDOWN;
 int gridpositions[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30};
snakehead = snakeposition;
char snakehead = '@';
int snakeposition[0];
snakeposition + snakehead = gridpositions;
switch(k)
{
case VK_DOWN:
snakeposition =-1[snakeposition[-1]]; break;
} 
}

Please help me I'm absolutely clueless and I REALLY want to make a snake game today.

I will feel SO much better about myself if I actually got some working and useful help on this VERY appreciated.

I have no idea at all, nothing, on how to make a full, running and working snake game.

Then you should probably do something you at least have an idea how to do. Do this project later when you're not so clueless.

... And I mean do it with out extended graphics, only C++'s native things, and it's possible

Actually, using native C++, this task is actually impossible. Native C++ has no way to control where to put stuff on the screen nor can it accept input asynchronously which is required for this project.

As I said, you may want to choose another project that you can do that uses native C++, something that you don't quite know how to do but you aren't completely clueless about.

Then you should probably do something you at least have an idea how to do. Do this project later when you're not so clueless.


Actually, using native C++, this task is actually impossible. Native C++ has no way to control where to put stuff on the screen nor can it accept input asynchronously which is required for this project.

As I said, you may want to choose another project that you can do that uses native C++, something that you don't quite know how to do but you aren't completely clueless about.

It's not impossible. By C++ native I mean other headers it comes with when you download an IDE and NOT just the input and output stream. Don't tell me it's impossible and lie to me; it's not.

And I have not a clue on what I can do that's lesser than a snake game, but larger than any one input output program. Plus, how could I work my way up to a snake game if I don't even know where to start?

I'm not exactly following a road here.....

It's not impossible. By C++ native I mean other headers it comes with when you download an IDE and NOT just the input and output stream. Don't tell me it's impossible and lie to me; it's not.

OK. You obviously know more than I do. I've only been programming for 30 years and must not know enough yet. And since I'm wrong, tell me how you can do it...

And I have not a clue on what I can do that's lesser than a snake game, but larger than any one input output program. Plus, how could I work my way up to a snake game if I don't even know where to start?

I'm not exactly following a road here.....

Then buy or download a book or follow a tutorial. You can't just do neurosurgery without learning how to use a scalpel first.

If you intend to display ASCII char on the screen, before trying to code snake game, try this.
Move a single char (can be a #, $, @ or anything else) using Arrow Keys.
Then randomly place char (like *) as a food on the screen, now as you move your previous char the food char should disappear whenever the 2 char's coordinates equals.
From here i guess you can move onto building your game, piece by piece.
And using a class would be a good idea.
Vinayak

Snake game! That's funny, that was (almost) the first program I ever wrote, it was on my TI-83 calculator (the first programmable thing I ever put my hands on), I was about 13 years old and I did it in a few days' worth of spare time. It was a nice game to play during those boring math lectures.

When WaltP said that it is impossible in native C++, he meant "native C++" as in the standard C++ libraries and STL (i.e. everything that is documented on www.cplusplus.com/reference ... oh, that's right, you're banned from that one). And he is right (of course!). Native C++ libraries don't handle screen display or async keystroke inputs, because that would put too much restrictions on OS designers.

For a minimalistic option, you can use systems like "curses.h" (for Unix-like systems) or "conio.h" (for windows command prompt) or "graphics.h" (for windows GDI, i.e. legacy Windows 3.1 stuff). But, more realistically, you should use something like win32 API or SDL.

Snake game! That's funny, that was (almost) the first program I ever wrote, it was on my TI-83 calculator (the first programmable thing I ever put my hands on), I was about 13 years old and I did it in a few days' worth of spare time. It was a nice game to play during those boring math lectures.

When WaltP said that it is impossible in native C++, he meant "native C++" as in the standard C++ libraries and STL (i.e. everything that is documented on www.cplusplus.com/reference ... oh, that's right, you're banned from that one). And he is right (of course!). Native C++ libraries don't handle screen display or async keystroke inputs, because that would put too much restrictions on OS designers.

For a minimalistic option, you can use systems like "curses.h" (for Unix-like systems) or "conio.h" (for windows command prompt) or "graphics.h" (for windows GDI, i.e. legacy Windows 3.1 stuff). But, more realistically, you should use something like win32 API or SDL.

Um....Conio.h comes by default with my C++ IDE, so I consider that "native" to C++.
That's what I meant. And it is possible.

If you intend to display ASCII char on the screen, before trying to code snake game, try this.
Move a single char (can be a #, $, @ or anything else) using Arrow Keys.
Then randomly place char (like *) as a food on the screen, now as you move your previous char the food char should disappear whenever the 2 char's coordinates equals.
From here i guess you can move onto building your game, piece by piece.
And using a class would be a good idea.
Vinayak

Wow, you were very unhelpful. :(

I KNEW ALL OF THAT. What I want to know is how to ACTUALLY begin doing this and some tips for the whole procedure.

ok i will try to be a little helpful.
1. use a 2d char array, of your desired size.
2. maintain x&y offsets(or coordinates) for your player and food items.
3. with each keystroke, first check for equality of offsets, update food items
4. then update offsets of player
5. print 2d array to screen

now MR KNOW-IT-ALL might be knowing all this, but i am sure i was helpful.

commented: You were helpful, don't listen to her +6

I had written it two weeks ago. maybe you want to look at.but I have used the language of c. Sneak

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.