Shine's Lowser Snake Game

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Shine's Lowser Snake Game

Post by Art »

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.
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

I figure this:

Code: Select all

	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.
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Looks like a linked list of cells (note the cell = cell.next)
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

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.
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

If not actually, then potentially.
Post Reply