Snake

Discussion, Reviews & High-scores

Moderator: Moderators

User avatar
vicist
Vic 20 Afficionado
Posts: 352
Joined: Tue Oct 09, 2012 5:26 am
Location: Sheffield, UK

Snake

Post 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 278 times
Last edited by vicist on Sun Mar 17, 2019 6:43 am, edited 2 times in total.
User avatar
vicist
Vic 20 Afficionado
Posts: 352
Joined: Tue Oct 09, 2012 5:26 am
Location: Sheffield, UK

Re: Snake

Post by vicist »

Added joystick/fire control for those who like that sort of thing. :)

Link updated.
User avatar
joshuadenmark
Big Mover
Posts: 1218
Joined: Sat Oct 23, 2010 11:32 am
Location: Fr-Havn, Denmark
Occupation: Service engineer

Re: Snake

Post by joshuadenmark »

Thanks :D will give this a good try.
Kind regards, Peter.
____________________________________________________
In need of a wiki logon - PM me
User avatar
Witzo
Vic 20 Afficionado
Posts: 381
Joined: Thu Dec 01, 2011 9:14 am
Location: The Hague

Re: Snake

Post by Witzo »

Nice that the game gives me some time to think about where I'm going.
Image
Here things start to get crowded!
User avatar
OmegaMax
Vic 20 Newbie
Posts: 12
Joined: Fri Mar 08, 2019 9:59 pm
Location: Canada

Re: Snake

Post by OmegaMax »

Image
User avatar
Witzo
Vic 20 Afficionado
Posts: 381
Joined: Thu Dec 01, 2011 9:14 am
Location: The Hague

Re: Snake

Post by Witzo »

OmegaMax wrote:Image
Whoa.
siccoyote
Vic 20 Dabbler
Posts: 91
Joined: Sun Nov 26, 2017 6:27 pm
Location: UK

Re: Snake

Post 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
User avatar
vicist
Vic 20 Afficionado
Posts: 352
Joined: Tue Oct 09, 2012 5:26 am
Location: Sheffield, UK

Re: Snake

Post 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 217 times
EDIT: This is the same file now as the original post.
Last edited by vicist on Sun Mar 17, 2019 6:47 am, edited 1 time in total.
siccoyote
Vic 20 Dabbler
Posts: 91
Joined: Sun Nov 26, 2017 6:27 pm
Location: UK

Re: Snake

Post 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.
User avatar
vicist
Vic 20 Afficionado
Posts: 352
Joined: Tue Oct 09, 2012 5:26 am
Location: Sheffield, UK

Re: Snake

Post 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.
User avatar
Witzo
Vic 20 Afficionado
Posts: 381
Joined: Thu Dec 01, 2011 9:14 am
Location: The Hague

Re: Snake

Post 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:
User avatar
OmegaMax
Vic 20 Newbie
Posts: 12
Joined: Fri Mar 08, 2019 9:59 pm
Location: Canada

Re: Snake

Post by OmegaMax »

Will try the updated version later today,thanks.
wimoos
Vic 20 Afficionado
Posts: 346
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Re: Snake

Post by wimoos »

snakewb.zip
(1.6 KiB) Downloaded 121 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.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
User avatar
vicist
Vic 20 Afficionado
Posts: 352
Joined: Tue Oct 09, 2012 5:26 am
Location: Sheffield, UK

Re: Snake

Post by vicist »

Works well :D
wimoos
Vic 20 Afficionado
Posts: 346
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Re: Snake

Post by wimoos »

snake.zip
(1.48 KiB) Downloaded 83 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.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
Post Reply