Page 1 of 1

Snake code in need of improvement

Posted: Thu May 31, 2018 12:41 am
by MrPixel
Image

all i ask is that this code be put to good use. i saw the entry for the crap games competition, and i got an idea, why not make the game for the +3 instead. could be fun. i already mapped out the INKEY$ input (WASD but also want to do arrow keys). i'm thinking of a summer theme).

Re: Snake code in need of improvement

Posted: Thu May 31, 2018 12:47 am
by djnzx48
I've got a Snake game in BASIC that I made a few years ago as a prototype for a scrapped machine code version, so you could have a look at that. I can't post it right now but I'll do it when I get home.

Re: Snake code in need of improvement

Posted: Thu May 31, 2018 6:37 am
by djnzx48
So here's a basic prototype. It uses QAOP but could easily be modified to use WASD. One thing to note is that it uses a string array rather than a number array to store the position of the snake segments; this is to save memory as a number uses 5 bytes but a letter only uses a single byte. It also starts the array off small and expands it as you grow, but it would have been easier and better to keep the array at a constant maximum size, as this would eliminate the slowdown whenever you eat food.

If you want to try something simpler, you could do a game where the snake constantly leaves a trail behind and the aim is to stay alive for as long as possible without hitting anything, like Track Trap for example. If you go this route you don't need to bother about arrays or needing to erase the tail.

Re: Snake code in need of improvement

Posted: Thu May 31, 2018 11:32 am
by hikoki
Could it Track Trap be converted into a Miami Vice Boat Race?
Walls would form a river circuit instead, there would be more than two boats..
maybe the circuit lane would be formed by two immortal boats which run in parallel

or maybe do both at once, a race of tron-snakes.. a few snakes which grow when eating apples, there would be a number of numbered apples, apples get eatable as they are eaten in ascending order, snakes are slowed down instead of dying when crashing into each other, apple number 1 gets eatable again whenever the last number has been eaten to start a new lap

Re: Snake code in need of improvement

Posted: Fri Jun 08, 2018 6:24 pm
by MrPixel
djnzx48 wrote: Thu May 31, 2018 6:37 am So here's a basic prototype. It uses QAOP but could easily be modified to use WASD. One thing to note is that it uses a string array rather than a number array to store the position of the snake segments; this is to save memory as a number uses 5 bytes but a letter only uses a single byte. It also starts the array off small and expands it as you grow, but it would have been easier and better to keep the array at a constant maximum size, as this would eliminate the slowdown whenever you eat food.

If you want to try something simpler, you could do a game where the snake constantly leaves a trail behind and the aim is to stay alive for as long as possible without hitting anything, like Track Trap for example. If you go this route you don't need to bother about arrays or needing to erase the tail.
there is no way in hell i am modifying that. now, if it was a machine code program, maybe i would be able to.

Re: Snake code in need of improvement

Posted: Fri Jun 08, 2018 6:56 pm
by ZXDunny
I did one a while ago, uses attributes:

Image

It's not too easy to follow the code, mind.

Re: Snake code in need of improvement

Posted: Fri Jun 08, 2018 7:21 pm
by hikoki
MrPixel, you can open those tap/tzx files provided by djnzx48 with BasinC to edit their Basic listings

Re: Snake code in need of improvement

Posted: Mon Oct 01, 2018 9:01 pm
by Dr beep

Re: Snake code in need of improvement

Posted: Sun Jan 13, 2019 1:27 pm
by Gazzapper
You can use I attr to 'eat' the end of the tail following a direction - then when eating apples - skip the tail eating once.
:)