View previous topic :: View next topic |
Author |
Message |
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Sat Jan 30, 2010 2:04 pm Post subject: Shine's Lowser Snake Game |
|
|
Hi Guys,
I'm trying to understand, and recode the way Shine's Snake game works.
I have a rough idea how to follow it, but have some questions.
How is it determined where the last segment of the snake is (the tail segment that is removed)?
Also, pretty much the same question, since the answer to any could probably answer both... how is the length of the snake kept track of?
Cheers, Art. _________________ If not actually, then potentially. |
|
Back to top |
|
|
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Sat Jan 30, 2010 10:25 pm Post subject: |
|
|
I figure this:
Code: |
cell = cellTail
while cell ~= cellHead do
if cell.x == lastX and cell.y == lastY then
gameOver = true
break
end
cell = cell.next
end
|
code checking for an end game condition is like a next...for loop.
So the game must be keeping an array of coordinates of old snake heads. _________________ If not actually, then potentially. |
|
Back to top |
|
|
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Sun Jan 31, 2010 1:56 am Post subject: |
|
|
Looks like a linked list of cells (note the cell = cell.next) |
|
Back to top |
|
|
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Sun Jan 31, 2010 8:37 am Post subject: |
|
|
I'm looking to code it for a microcontroller, so I don't get to use linked lists.
I guess this means I use an array of x,y coords for segment positions. _________________ If not actually, then potentially. |
|
Back to top |
|
|
Art
Joined: 09 Nov 2005 Posts: 647
|
|
Back to top |
|
|
|