diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..35b39b3 --- /dev/null +++ b/install.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +if [ "$1" == '' ]; then + target="/usr/local/" +elif [ -d "$1" ]; then + target=$1 +else + echo "Error: if an argument is present, it must be a directory" >&2 + exit 1 +fi + +if [ "$2" == '' ]; then + final_target=$target +else + final_target=$2 +fi + +mkdir -p $target/bin $target/share/wormpy + +cp wormpy/*.py $target/share/wormpy +echo "#!/bin/bash" > $target/bin/wormpy +echo "python3 $final_target/share/wormpy/" >> $target/bin/wormpy +chmod +x $target/bin/wormpy diff --git a/worm.py b/wormpy/__main__.py similarity index 96% rename from worm.py rename to wormpy/__main__.py index 2e90c84..309ed1a 100755 --- a/worm.py +++ b/wormpy/__main__.py @@ -36,7 +36,7 @@ def draw_worm(): def draw_frame(): print(term.clear, end='') - print(do_move(0, 0) + term.on_red(' worm') + term.bright_cyan_on_red('.py ') + ' Press ' + term.bold_green('I') + ' for info, ' + term.bold_red('Ctrl-C')+ ' to quit', end='') + print(do_move(0, 0) + term.on_red(' Worm') + term.black_on_bright_cyan('.py ') + ' Press ' + term.bold_green('I') + ' for info, ' + term.bold_red('Ctrl-C')+ ' to quit', end='') if score > -1: print(do_move(0, width-12) + f'Score:{" "*(4-len(str(score)))}{term.bright_green(str(score))}', end='') print(do_move(1, 0) + term.white_on_red('┌' + ('─' * (width-3)) + '┐'), end='') @@ -166,7 +166,7 @@ def save_game(): term = Terminal() gamesave_path = os.path.join(os.getenv('HOME'), '.worm.py-gamesave') -parser = argparse.ArgumentParser() +parser = argparse.ArgumentParser(prog='wormpy') group = parser.add_mutually_exclusive_group() group.add_argument("--save-game", '-s', help="use 80x24 box and save game on ^C (default)", action='store_true', default=True) group.add_argument("--full-screen", '-f', help="use entire screen (disables game saving)", action='store_true') @@ -203,7 +203,7 @@ elif args.full_screen: else: print("An unhandleable error occurred.") print("The code was not expected to reach this state.") - print("Please create an issue at https://github.com/kj7rrv/worm.py/issues") + print("Please create an issue at https://github.com/kj7rrv/wormpy/issues") sys.exit(2) worm_y = height // 2 diff --git a/info.py b/wormpy/info.py similarity index 80% rename from info.py rename to wormpy/info.py index b4a2990..aac4cb7 100644 --- a/info.py +++ b/wormpy/info.py @@ -1,9 +1,9 @@ def get_infos(term, do_move, height, width, x_offset): - info_1 = term.clear() + do_move(0, 0) + term.on_red(' worm') \ - + term.bright_cyan_on_red('.py ') + f''' v1.0: bsdgames worm, ported \ + info_1 = term.clear() + do_move(0, 0) + term.on_red(' Worm') \ + + term.black_on_bright_cyan('.py ') + f''' v1.0: bsdgames worm, ported \ to Python and improved -See https://github.com/kj7rrv/worm.py for source code and installation +See https://github.com/kj7rrv/wormpy for source code and installation instructions. Thanks to the authors of the following libraries: @@ -19,11 +19,11 @@ Use the arrow keys or WASD to move. Try to get the green numbers, but don't let the worm run into itself or the red edge. To change the initial length of the worm, add the desired length of the worm -after `{term.bright_red('worm')}{term.bright_cyan('.py')}`, as in \ -`{term.bright_red('worm')}{term.bright_cyan('.py')} 20` for a twenty-character\ +after `{term.bright_red('worm')}{term.bright_cyan('py')}`, as in \ +`{term.bright_red('worm')}{term.bright_cyan('py')} 20` for a twenty-character\ -long worm. -{term.bright_red('worm')}{term.bright_cyan('.py')} is released under the MIT \ +{term.bright_red('Worm')}{term.bright_cyan('.py')} is released under the MIT \ license.'''\ + '{}Press {} to continue, {} to exit the game...'.format( do_move(height - 1, 0), @@ -31,8 +31,8 @@ license.'''\ term.bold_red('Ctrl-C') ) - info_2 = term.clear() + do_move(0, 0) + term.on_red(' worm') \ - + term.bright_cyan_on_red('.py ') + f''' Copyright and License Info + info_2 = term.clear() + do_move(0, 0) + term.on_red(' Worm') \ + + term.black_on_bright_cyan('.py ') + f''' Copyright and License Info Copyright (c) 2021 Samuel L. Sloniker diff --git a/stty.py b/wormpy/stty.py similarity index 100% rename from stty.py rename to wormpy/stty.py