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
Snake game on LCD using Flowcode 7
- 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
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Snake game on LCD using Flowcode 7
Make sure to update this thread if you manage to figure this out, Masaladosa. I'd love to try your Snake game if possible.
Just make use of these fat burners asap.