Snake code in need of improvement
Re: Snake code in need of improvement
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
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.
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
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
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
there is no way in hell i am modifying that. now, if it was a machine code program, maybe i would be able to.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.
Re: Snake code in need of improvement
I did one a while ago, uses attributes:
It's not too easy to follow the code, mind.
It's not too easy to follow the code, mind.
Re: Snake code in need of improvement
You can use I attr to 'eat' the end of the tail following a direction - then when eating apples - skip the tail eating once.