Questions about Snake (game) in C or C++

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2008
Posts: 36
Reputation: esy928 is an unknown quantity at this point 
Solved Threads: 0
esy928 esy928 is offline Offline
Light Poster

Questions about Snake (game) in C or C++

 
0
  #1
Aug 8th, 2009
Hello Guys! it's been a while.

Lately, I've been wanting to study & explore C/C++ more. Because of this, I've done a lot of exercises that was given to us at school and some more around the net, but sadly the one that I'm really looking forward to the the most (snake game) wasn't given to us.

I'm really interested in how the snake game works and I really want to code it myself. I've looked around and googled it but I can't seem to find a guide, all I saw was source codes. I just want to have and idea on how the game works and what are the necessary "things" that I need in order to do that (do I need to know about: structures? array? etc.)

can someone give me an overview or just a slight guide?

Thanks a lot! Peace
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Questions about Snake (game) in C or C++

 
0
  #2
Aug 8th, 2009
Why don't you try your own solution?
Rather than looking at someone else's code, and trying to do basically the same thing over again.

Snake:
- snake moves every 'tick' (ticks get quicker as the game progresses)
- snake hits wall - dead
- snake hits snake - dead
- player presses key - snake changes direction
- snake hits food - snake gets longer

That's pretty much all there is to it.

> do I need to know about: structures? array? etc.
Yes.
Or rather, your life will be a lot easier with careful use of these things.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 36
Reputation: esy928 is an unknown quantity at this point 
Solved Threads: 0
esy928 esy928 is offline Offline
Light Poster

Re: Questions about Snake (game) in C or C++

 
0
  #3
Aug 9th, 2009
Thanks Salem!

I'm actually trying to do it by myself, I don't really understand the codes that I saw & I have no intentions of learning the program using those codes. I just have a couple of questions here: How do I bind the up/down/left/right keys? and the whole game is just loop right? with every movement it goes through an iteration.

Thanks in advance!
Last edited by esy928; Aug 9th, 2009 at 10:40 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Questions about Snake (game) in C or C++

 
0
  #4
Aug 9th, 2009
> How do I bind the up/down/left/right keys?
That depends on your OS/Compiler/Kind of program.
A Linux Console program has a different answer to a windows GUI program.

Yeah, it's just a loop with some inputs.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 36
Reputation: esy928 is an unknown quantity at this point 
Solved Threads: 0
esy928 esy928 is offline Offline
Light Poster

Re: Questions about Snake (game) in C or C++

 
0
  #5
Aug 9th, 2009
I'm using Dev C++ on Windows Vista, is it the same on C & C++ (The Key bind function) ?
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Questions about Snake (game) in C or C++

 
1
  #6
Aug 10th, 2009
If you're creating a win32 console game, try
http://www.adrianxw.dk/SoftwareSite/...Consoles5.html
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC