in reply to Re: setup of a small perl game
in thread setup of a small perl game
What do I need to do?
while (1) { ########### # Heart of the game- Choose and scramble a word ########### my $word = $words[rand @words]; my @scramble = split(//, $word); @scramble = sort { (-1,1)[rand 2] } @scramble; print "\n\nGuess the scrambled word: "; foreach (@scramble) {print $_}; print "\n\n"; my $attempts = 0; while ($attempts++ < $max_attempts) { ##### # Take their guess ##### my $guess = <STDIN>; chomp($guess); if ($guess ne "$word") { print "$guess is incorrect.\n"; $attempts++; } else { print "Congratulations! The scrambled word was $word.\n\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: setup of a small perl game
by tlm (Prior) on Apr 12, 2005 at 03:53 UTC | |
by Anonymous Monk on Apr 12, 2005 at 04:10 UTC | |
by tlm (Prior) on Apr 12, 2005 at 04:17 UTC | |
by sulfericacid (Deacon) on Apr 12, 2005 at 05:46 UTC | |
by tlm (Prior) on Apr 12, 2005 at 09:42 UTC |