Snake game on LCD using Flowcode 7

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
mnf
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Snake game on LCD using Flowcode 7

Post by mnf »

Hi,

You need some way to store the positions of each 'segment' of the snake. So you could use an array or a circular buffer. To move you draw the new 'head' of the snake and erase the last section - the contents of your storage need to reflect this (ie the new 'head' gets added to the front and the last element is deleted - if you are using a circular buffer you can amend the pointers to the front and back element of the snake and with an array - shift the contents of the array).
Your array or buffer needs to be large enough to store the longest possible snake.
Depending on the size of your display you can store each position as a byte (if the screen has <= 255 possible positions) or a word (possibly with x/y as high/low byte)

Martin

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Snake game on LCD using Flowcode 7

Post by Benj »

Hello,

Have you seen this forum topic?
viewtopic.php?f=63&t=18360&p=78619#p78619

Leshawn
Posts: 1
Joined: Mon Dec 17, 2018 10:26 am
Contact:

Re: Snake game on LCD using Flowcode 7

Post by Leshawn »

Make sure to update this thread if you manage to figure this out, Masaladosa. I'd love to try your Snake game if possible.

mnf
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Snake game on LCD using Flowcode 7

Post by mnf »


Post Reply