Page 1 of 2

Snake

Posted: Fri Mar 01, 2019 7:50 am
by vicist
A Worm/Snake game I made as a proof of concept (to me) programming exercise.
snake.png
snake.zip
(1.99 KiB) Downloaded 293 times

Re: Snake

Posted: Tue Mar 05, 2019 9:33 am
by vicist
Added joystick/fire control for those who like that sort of thing. :)

Link updated.

Re: Snake

Posted: Tue Mar 05, 2019 2:25 pm
by joshuadenmark
Thanks :D will give this a good try.

Re: Snake

Posted: Sun Mar 10, 2019 3:05 pm
by Witzo
Nice that the game gives me some time to think about where I'm going.
Image
Here things start to get crowded!

Re: Snake

Posted: Sun Mar 10, 2019 4:29 pm
by OmegaMax
Image

Re: Snake

Posted: Mon Mar 11, 2019 4:58 am
by Witzo
OmegaMax wrote:Image
Whoa.

Re: Snake

Posted: Tue Mar 12, 2019 5:53 pm
by siccoyote
I got to 138, but usually when I finally die it doesn't feel like it's really my fault.

I realise it's just a programming exercise but if I had a comment for it I would say the controls are not responsive enough. I will be going straight down the screen then I'll press 'right' then 'up' but the right doesn't respond so it eats itself and dies.

Image

Re: Snake

Posted: Wed Mar 13, 2019 1:34 pm
by vicist
It's written in BASIC and there is quite a bit going on in-between key-presses so it's never going to be super responsive.

However, I have looked at the way the key-presses / joystick detection works and tried a different approach.
See if this is any better.
snake.zip
(1.99 KiB) Downloaded 230 times
EDIT: This is the same file now as the original post.

Re: Snake

Posted: Wed Mar 13, 2019 2:10 pm
by siccoyote
Yeah definitely feels better now far less sluggish.

Still get the occasional moments of it but as you said it is a basic program.

Re: Snake

Posted: Sun Mar 17, 2019 6:39 am
by vicist
As snake_b works a bit better, I've replaced the original post with this one plus a fix to the slightly glitchy score display. :)

Enjoy.

Re: Snake

Posted: Sun Mar 17, 2019 3:46 pm
by Witzo
Hm, my new attempts are worse that my previous, either with joystick or, more controlled, with keys.
I held a direction too long and ran into a wall while winding around to get the long tail out of the way :lol:

Re: Snake

Posted: Sun Mar 17, 2019 11:20 pm
by OmegaMax
Will try the updated version later today,thanks.

Re: Snake

Posted: Sun Dec 29, 2019 6:23 am
by wimoos
snakewb.zip
(1.6 KiB) Downloaded 134 times
This was a good candidate to build a WimBasic version of....It is now suitable for all (regular) memory configurations and uses a lot of the WimBasic features.
I brought it down to a little over 2k bytes.

Regards,

Wim.

Re: Snake

Posted: Sun Dec 29, 2019 11:49 am
by vicist
Works well :D

Re: Snake

Posted: Wed Jan 15, 2020 12:35 pm
by wimoos
snake.zip
(1.48 KiB) Downloaded 99 times
Brought it down to 1967 bytes in WimBasic, 42 lines. The WimBasic features sped it up, but a big winner was the use of defined functions.
I applied these to calculate the next memory location for PEEK and POKE.
This can also be done in vanilla Basic and saves processing programlines and searching for variables.

Code: Select all

DEFFNP(X)=X+300*(X=1020)-157*(X=767)
DEFFNQ(X)=X+251*(X=924)-108*(X=720)
Then call them with PF=FNP(PF+1) etcetera.

Another one is the line where variable B is compared to the body or the tail of the snake or the border. These three comparisons can be changed to one, namely: B<99 . This also saves a lot of processing.

Regards,

Wim.