LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Blogs > TheOuterLinux
User Name
Password

Notices


Rate this Entry

TheOuterLinux Mμse - An interesting way to make a text-based game using catimg and play

Posted 06-22-2020 at 05:30 PM by TheOuterLinux

Cross-posted from: https://theouterlinux.gitlab.io/Publ...CatimgGame.txt
RSS for website version: https://theouterlinux.gitlab.io/Publ...ticleFeed.atom

The following is a BASH script that with the help of 'catimg' and the 'play' command, you can create a classic text-adventure game but have an image shown just above the text. See notes inside of the script.

Code:
#Discussion URL: https://www.reddit.com/r/TheOuterLinux/comments/esgvmf/catimg_and_play_to_for_textbased_games/.compact

#Grab catimg from https://github.com/posva/catimg
#Catimg also supports animated gifs which could be used for fight animations.
#Catimg will also automatically adjust the image size, so you might want
#to set it to a maximum column width instead (-w #).

clear #Clear the terminal screen
catimg -w 100 -l 0 "/path/to/intro/image.ext"
#Below at the end, the ">&- 2>&-" part hides the player and the final "&" tells it to play this file while also do the next line 
play "/path/to/intro/music.wav" >&- 2>&- &
read -p "What is thy name traveler?: " name
clear #Clear screen and then redraw the same image as before
catimg -w 100 -l 0 "/path/to/intro/image.ext"
echo -n "Welcome $name to this wonderful game!"
#You could also add espeak after 'echos' to have narration.
Posted in Uncategorized
Views 40 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 07:15 PM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration