Snake game challenge in UNIX

Hey Guys,

I have made this basic snake game but it a little bit different from conventional snake game. Learned some basics of Unix. Hope you enjoy playing it.
Please download and run on your machine and suggest any changes i can make. and let me know if someone could score 1000 points :wink:

Thanks,
Amit

Hi amit14august...
You must be using a bash version 4.x.x as it cannot be used on anything previous.
On OSX 10.12.4, DEFAULT bash terminal below occurs...

Last login: Sun Apr 23 09:13:49 on ttys000
AMIGA:amiga~> bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)
Copyright (C) 2007 Free Software Foundation, Inc.
AMIGA:amiga~> cd Desktop/Code/Shell
AMIGA:amiga~/Desktop/Code/Shell> ./snakegame.sh






Your green snake must stay away from pink ones

control : I = UP  J = LEFT  K = DOWN  L = RIGHT

 Game will start in 3 seconds


your score is : 1      top score is 1000
./snakegame.sh: line 283: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
                                             
                                             
                                             
                                             
                                             
                                             
@@@@@                                        
                                             
                                             
                        ***                  
                                             
                                             
                                             
                                             
                                             
./snakegame.sh: line 221: init_snake: bad array subscript
./snakegame.sh: line 222: init_snake: bad array subscript
./snakegame.sh: line 167: read: .025: invalid timeout specification
./snakegame.sh: line 88: [: -eq: unary operator expected
./snakegame.sh: line 95: init_helper_one: bad array subscript
./snakegame.sh: line 96: init_helper_one: bad array subscript
./snakegame.sh: line 100: 1 -  : syntax error: operand expected (error token is " ")
AMIGA:amiga~/Desktop/Code/Shell> _

So it is not backwards compatible.
To find your bash version:-

Last login: Mon Apr 24 07:15:34 on console
AMIGA:amiga~> bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)
Copyright (C) 2007 Free Software Foundation, Inc.
AMIGA:amiga~> _

It is not easy to include users who do not have versions of languages that you write for and possibly unable to upgrade to. So be aware when you write your code to state which version of language you are using as that helps the user to decide whether or not to run your code.
We all learn the hard way.
Good luck and keep up with the programming learning curve.
We look forwards to seeing more from you...

Bazza.

1 Like

Heh, I wrote an incomplete snake clone a few years ago on my SparcStation LX running Gentoo. I'll post a link to a video of it once I get a chance who knows I might even dig up the source and see about finishing it. It's just plain ncurses... and uses a pretty inefficient implementation so the longer your "Wooly Bear" as I called it gets the slower it runs! Here is a link to a video of my LX running and me dorking around with it SparcStation LX booting Gentoo Linux - YouTube