Bash Script for "simple" racing game.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash Script for "simple" racing game.
# 1  
Old 06-04-2010
Bash Script for "simple" racing game.

Hello All,
I was wondering if it would be possible to create a "racing" game in script. The game play would be as follows. Script will read the following input:

Start
|b| | | | |
|r| | | | |


First player (b) will roll a die to see how many spaces to move. This is will continue until the player reaches the end.
Roll a 2
| | |b| | |
|r| | | | |

I thought I could read user input, to tell "b" or "r" how much to move. This can be done using "read." I originally wanted to use the awk command to first grab the string and then move it to the next column. To do this, I would have to delete what is in column one, and then write to column three. I figured I could then append/write this to an output file and then use cat to display results.

Any suggestions?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

Explaining behaviour of sudo bash "$0" "$@";

I've found this script part on the stackoverflow: if ; then sudo bash "$0" "$@"; exit "$?"; fi I realized that sudo bash "$0" "$@"; is the only needed for me. But the strange thing happens when I move this line outside the IF statement: sudo bash "$0" "$@"; stops the... (9 Replies)
Discussion started by: boqsc
9 Replies

3. Shell Programming and Scripting

Can someone please show me a very simple "expect" script to change password in Solaris please?

Ladies & Gents, Can one of you gurus please show me a very simple "expect" script to change the password in Solaris in a script, please? Nothing fancy, no error checking, no nothing. Just to change the password of a new user, it's all. Many thanks in advance. U guys have honestly earned my... (1 Reply)
Discussion started by: Hiroshi
1 Replies

4. UNIX for Dummies Questions & Answers

"Help with bash script" - "License Server and Patch Updates"

Hi All, I'm completely new to bash scripting and still learning my way through albeit vey slowly. I need to know where to insert my server names', my ip address numbers through out the script alas to no avail. I'm also searching on how to save .sh (bash shell) script properly.... (25 Replies)
Discussion started by: profileuser
25 Replies

5. Shell Programming and Scripting

"Unexpected end of file" on a very simple script!!!

Well, this is a very crazy issue, and I'm scratching my head to find a solution. This is a simple code to tranfer a file, in my main script I need to add a conditional statement (IF/THEN) like the below example: #!/bin/bash if ; then ftp -inv "192.168.1.10" << EOFTP user... (8 Replies)
Discussion started by: Lord Spectre
8 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

Simplify Bash Script Using "sed" Or "awk"

Input file: 2 aux003.net3.com error12 6 awn0117.net1.com error13 84 aux008 error14 29 aux001.ha.ux.isd.com error12 209 aux002.vm.ux.isd.com error34 21 alx0027.vm.net2.com error12 227 dux001.net5.com error123 22 us008.dot.net2.com error121 13 us009.net2.com error129Expected Output: 2... (4 Replies)
Discussion started by: sQew
4 Replies

8. Shell Programming and Scripting

Why generate "ash and bash" different output for same bash script?

Hi, For my bash script, terminal with bash is generate an OK output and program works right. already, terminal with ash have "line 48: syntax error: Bad substitution" output and program don't work. :confused: (0 Replies)
Discussion started by: s. murat
0 Replies

9. Shell Programming and Scripting

simple script to find the number of "tab"s...but,...

------------------------------ $x=" hi"; $tabspace=0; while ($x =~ /\t/g ) { $tabspace++; } print $tabspace; --------------------------------- 1.)when i tried it without "g" ($x = ~/\t/ )... when i run the script it utilizes around 95% cpu and system hangs and i did "End process"... (0 Replies)
Discussion started by: sekar sundaram
0 Replies
Login or Register to Ask a Question
Module::Build::SDL(3pm) 				User Contributed Perl Documentation				   Module::Build::SDL(3pm)

NAME
Module::Build::SDL - Module::Build subclass for building SDL apps/games [not stable yet] SYNOPSIS
When creating a new SDL application/game you can create Build.PL like this: use Module::Build::SDL; my $builder = Module::Build::SDL->new( module_name => 'Games::Demo', dist_version => '1.00', dist_abstract => 'Demo game based on Module::Build::SDL', dist_author => 'coder@cpan.org', license => 'perl', requires => { 'SDL' => 0, }, #+ others Module::Build options )->create_build_script(); Once you have created a SDL application/game via Module::Build::SDL as described above you can use some extra build targets/actions: o you can create a PAR distribution like: $ perl ./Build.PL $ ./Build $ ./Build par There are some extra parameters related to 'par' action you can pass to Module::Build::SDL->new(): parinput => 'bin/scriptname.pl' paroutput => 'filename.par.exe', parlibs => [ qw/SDL SDL_main SDL_gfx/ ], #external libraries (.so/.dll) to be included into PAR parmods => [ qw/Module::A Module::B/ ], #extra modules to be included into PAR o to run the game from distribution directory you can use: $ perl ./Build.PL $ ./Build $ ./Build run o TODO: maybe some additional actions: parexe, parmsi, deb, rpm DESCRIPTION
Module::Build::SDL is a subclass of Module::Build created to make easy some tasks specific to SDL applications - e.g. packaging SDL application/game into PAR archive. APPLICATION
/GAME LAYOUT Module::Build::SDL expects the following layout in project directory: #example: game with the main *.pl script + data files + modules (*.pm) Build.PL lib/ Games/ Demo.pm bin/ game-script.pl data/ whatever_data_files_you_need.jpg the most simple game should look like: #example: simple one-script apllication/game Build.PL bin/ game-script.pl In short - there are 3 expected subdirectories: o bin - one or more perl scripts (*.pl) to start the actual application/game o lib - application/game specific modules (*.pm) organized in dir structure in "usual perl manners" o data - directory for storing application data (pictures, sounds etc.). This subdirectory is handled as a "ShareDir" (see File::ShareDir for more details) o As the project is (or could be) composed as a standard perl distribution it also support standard subdirectory 't' (with tests). RULES TO FOLLOW
When creating a SDL application/game based on Module::Build::SDL it is recommended to follow these rules: o Use the name for your game from Games::* namespace; it will make the later release to CPAN much easier. o Put all data files into data subdirectory and access the data subdir only via File::ShareDir (namely by calling distdir() function) o TODO: maybe add more perl v5.14.2 2012-05-28 Module::Build::SDL(3pm)