A downloadable game for Windows, macOS, Linux, and Android

beta versions

justmaxcz/bash-pac at beta (github.com)

stable versions

justmaxcz/bash-pac: bash-pac is an "clone of pacman" that is writen in bash (github.com)



Game Instructions


Player character: (C)

Avoid the ghost (G) while collecting food (.) to increase your score.

Controls:


A: Move Left 

S: Move Down

 D: Move Right

 O: main menu

------------------------------------------------------------------------------------------------

This Bash script defines a simple game resembling Pac-Man. Here's a breakdown of its components:

  1. Animation Function (display_animation): This function displays a brief animation of the characters "G" and "C" moving towards each other. It clears the screen and prints "G C", then pauses for a short duration before gradually moving the characters closer together until they merge into "GC".
  2. Game Logic Function (start_game): This function initializes the game variables, defines the game board layout, and implements the game logic. Key functionalities include:
    • Moving the player character ("C") using the "WASD" keys.
    • Moving the ghost character ("G") towards the player.
    • Collecting food (".") to increase the score.
    • Detecting collisions between the player and the ghost.
    • Detecting when all food items are collected to end the game with victory.
    • Offering options to restart or exit the game when the player loses.
  3. Helper Functions:
    • print_board: Prints the current game board.
    • is_valid_position: Checks if a given position is valid on the board.
    • spawn_ghosts and spawn_food: Randomly place ghosts and food on the board.
    • game_over_with_timer and game_over_with_victory: Display game over messages and handle player input.
    • reset_game: Resets the game state for a new playthrough.
    • display_help: Displays game instructions and controls.
  4. Main Menu Function (main_menu): This function displays the main menu with options to start the game, display help, or exit.
  5. Miscellaneous:
    • The script utilizes loops to continuously update the game state and respond to user input.
    • It clears the screen before printing each frame to create a smooth display.
Updated 5 days ago
Published 15 days ago
StatusReleased
PlatformsWindows, macOS, Linux, Android
Release date 19 days ago
Authorstuff by max
GenreAction
TagsArcade, Open Source, Retro, Text based
Code licenseGNU General Public License v2.0 (GPL)
Asset licenseCreative Commons Attribution v4.0 International
Average sessionA few minutes
LanguagesCzech, English
InputsKeyboard
AccessibilityColor-blind friendly
LinksSource code

Download

Download
bash-pac v1.2.0.sh 10 kB
Download
bash-pac v1.2.0 cz.sh 10 kB
Download
bash-pac v1.1.0.sh 7 kB
Download
bash-pac 1.1.0 cz.sh 7 kB
Download
README (1).md 4 kB

Install instructions

linux


Set execute permission on your script using the following command: chmod +x script-name-here.sh

To run your script, execute it directly: ./script-name-here.sh

Alternatively, you can use either of the following commands: sh script-name-here.sh or bash script-name-here.sh

for example

chmod +x script /home/zdislav/Desktop/bash-pac.sh

./home/zdislav/Desktop/bash-pac.sh

Windows


To run a .sh script in Git Bash, follow these steps:

  1. Add a “sh-bang” line: On the first line of your script (e.g., myScript.sh), include a “shebang” line specifying the interpreter. For example:
  2. #!/bin/bash 

Execute the script: Use ./ followed by the script name to run it. For instance:

./myScript.sh 

BSD


Install Bash:

By default, FreeBSD uses the tcsh shell and a POSIX-compatible sh shell. If you want to run Bash scripts, you can install Bash using the following commands: pkg add bash

or make -C /usr/ports/shells/bash install clean

After installation, you can execute your Bash script by invoking bash ./home/zdislav/Desktop/bash-pac.sh

Use a Universal Shebang:

Modify the shebang (the first line of your script) to use a more universally compatible shell location. Instead of #!/bin/bash, use #!/bin/sh. Then, within your script, you can check where Bash is installed (if it’s even installed) and adjust accordingly.

Andoid


Termux:

Termux is a popular terminal emulator available for Android. It provides a comprehensive collection of packages, including BASH and ZSH shells. If you have root access, you can manage files with tools like nnn and edit them using nano, vim, or emacs2.

Running Scripts:

You can run shell commands in Android using Termux. Create/download a BASH script (or any script) with a .sh extension. Use ./myscript.sh to execute the script directly. Alternatively, call BASH in a new shell and feed its commands from a text file using bash myscript.sh

for example ./home/zdislav/Desktop/bash-pac.sh

not recomended by me (i thing is harder)

Android’s Native Shell:

Android uses a shell located at /system/bin/sh, which is different from the typical /bin/sh found in most Unix-like systems. If you create a BASH script (with a .sh extension) and try to run it directly using #!/bin/bash, it won’t work because Android doesn’t have a full-fledged BASH interpreter. Instead, use #!/system/bin/sh in your script to make it compatible with Android’s shell. Keep in mind that Android is not a GNU/Linux distribution, so not all scripts that work on GNU/Linux will necessarily work on Android1.

mac os


Run the Script:

you can run your script by typing: ./myscript.sh

for example

./home/zdislav/Desktop/bash-pac.sh

The ./ prefix specifies that you want to execute the script in the current directory. Double-Click in Finder: Save your bash script with no file extension (e.g., bash_file instead of bash_file.sh). Alternatively, right-click the script file, choose “Get Info,” and set “Open with” to Terminal.app. Now you can double-click the script in Finder to execute it.

Using zsh (zshell): Note that the default shell on macOS used to be bash, but now it’s zsh (zshell). Both shells work, and you can choose based on your preferences. Familiarize yourself with common shell commands, such as cp for copying files or killall for stopping processes or apps 1234.

Development log

Leave a comment

Log in with itch.io to leave a comment.