Thread: Snake

  1. #1
    C++ Newbie
    Join Date
    Aug 2005
    Posts
    55

    Snake

    Well, I'm well into a snake game, but I'm having issues with storing the snake "pieces". At first I was planning on using vectors, but people suggested to me using a ring queue. I'm wondering what you guys think. What would be the most common way that snake is made?

    So far, I've got a Snake class, and a SnakePiece class. SnakePiece is just x,y, and Snake class is kind of messed up now because It's gone through many different experiments, lol.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > I'm wondering what you guys think.
    I think you should try both, then you'll have more understanding of the problems and advantages of each solution, and be able to make better choices in your future programming assignments.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User OnionKnight's Avatar
    Join Date
    Jan 2005
    Posts
    555
    When I wrote my own Snake clone I used both. A 2D array of the field that served the purpose of giving O(1) checks for collision and the use of a circular doubly linked list removed the need of shifting an array every time a move is made.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A snake game - Memory problem
    By gavra in forum C Programming
    Replies: 29
    Last Post: 11-23-2008, 12:58 PM
  2. Need help with a snake game (ncurses)
    By Adam4444 in forum C Programming
    Replies: 11
    Last Post: 01-17-2007, 03:41 PM
  3. Contest - Snake Numbers
    By pianorain in forum Contests Board
    Replies: 46
    Last Post: 06-15-2006, 07:52 AM
  4. Snake Attack! my game
    By SmashBro in forum Game Programming
    Replies: 8
    Last Post: 12-01-2002, 05:55 PM
  5. game (snake)
    By nps in forum C Programming
    Replies: 1
    Last Post: 10-09-2001, 10:37 PM