LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Random Color Guessing Game (https://www.linuxquestions.org/questions/linux-newbie-8/random-color-guessing-game-4175581404/)

Seattlesweet 06-03-2016 08:00 PM

Random Color Guessing Game
 
Thanks!

keefaz 06-05-2016 12:10 PM

You mean display colors in the terminal?
There are some escaped code sequences
http://wiki.bash-hackers.org/scripting/terminalcodes
Code:

space="    "
for i in 1 2 3 4 5; do
  echo -e "\033[4${i}m${space}\033[0m"
done


dab1414 06-05-2016 12:32 PM

look at this

or even
Code:

shuf -n 1 filename
just have a seperate file with one color per line

jpollard 06-07-2016 06:58 AM

Check the tput (how to use info) and terminfo man pages (how to set colors, and the options for using colors).

grail 06-07-2016 10:15 AM

hmmm ... I see where everyone else is going, but my first thought was, pick a colour from a set like red, blue, green or yellow (ie. like the set of numbers in original problem).

So if above was what you were looking for I would place the colours in an array so you can use your number randomizer as the index and then have the user enter a colour.

Now the gotcha would be to remember that text matching is case sensitive, so blue and Blue are not the same, so it would be up to you on how you would either overcome this issue or just tell
the user he/she is wrong if not spelt the same :)

jpollard 06-07-2016 10:29 AM

Welll, the shell includes operations for converting to lowercase...

grail 06-07-2016 12:13 PM

Quote:

Originally Posted by jpollard (Post 5557270)
Welll, the shell includes operations for converting to lowercase...

Yes ... I was kind of leaving that for the user to work out :)

Seattlesweet 06-07-2016 04:46 PM

Thank You
 
I have figured it out! Thanks for the input everyone :)

grail 06-07-2016 05:38 PM

Please remember to share your findings so someone else may learn from your new found knowledge.

Also, please remember to mark the question as SOLVED


All times are GMT -5. The time now is 12:28 PM.