You are viewing our Forum Archives. To view or take place in current topics click here.
Simple Dice Game [Tut] (Using MS Excel)
Posted:

Simple Dice Game [Tut] (Using MS Excel)Posted:

oCD
  • TTG Natural
Status: Offline
Joined: Dec 02, 201013Year Member
Posts: 986
Reputation Power: 47
Status: Offline
Joined: Dec 02, 201013Year Member
Posts: 986
Reputation Power: 47
This was originally written for appleworks on MAC I have adjusted it to format Excel For PC. Feel free to edit the formula.

[ Register or Signin to view external links. ]
Fig. A

Follow the directions below to create a pair of dice that actually work by holding down the Ctrl + Shift keys while hitting the = sign, (On Mac: Command + Shift), or F9 on Excel XP.


Open a new Spreadsheet document.
From the Format menu, select Document and limit the number of columns to 7 and the number of rows to 4
Select Row Height and Column Widths of 72pt
Highlight all cells and choose a font size of 36
In Cell A4 type the formula: RAND(6) In Excel XP use =INT(RAND()*6)+1 . This will generate the random numbers of the dice.
In Cell A1 type =IF(A4>1,"l","") letter L, not 1.
Cell C1 type =IF(A4>3,"l","")
Cell A2 type =IF(A4=6,"l","")
Cell B2 type =IF(OR(A4=1,A4=3,A4=5),"l","")
Cell C2 type =IF(A4=6,"l","")
Cell A3 type =IF(A4>3,"l","")
Cell C3 type =IF(A4>1,"l","")
Cell A4 type =INT(RAND()*6)+1
Select the range of 4x3 cells A1..C4 and select Copy from the Edit menu. Move the cursor to cell E1 and select Paste from the Edit menu.
Select the range of cells from A1 to G3 and change the font to Wingdings (In the Format menu select Font and Wingdings) This changes the letter "l" to dots.
Cell D4 type =A4+E4 This will display the total of the pair of dice.






You can experiment with the colours of the dice, and the font colour and size. Make sure you choose Center Alignment so the dots will be centered in the squares.
To hide the Random numbers in Cell A4 and E4 change the font colour to match the cell colour.

I added another feature. If you type the following in any of the blank cells, such as D2, it will display the caption "Lucky Seven" whenever the pair of dice adds up to seven.

=IF((D4=7),"Lucky Seven","")

Under Options choose Display and uncheck all the checkmarks. Select all cells and Lock them (under Options) to prevent accidentally changing them.





If you want to get fancy, try adding a border around the dice. Make sure you have a backup copy saved as well.

Save your file with a unique name such as tc_game1.xls (my_initials_game_1)

On the Macintosh, hold down the command and shift key, then press the = sign. The two dice will change values randomly. In Windows, hold down the CTRL and shift keys instead. (In Office XP try F9)




To finish off add a column to the left and a row at the top. Create a visual border around the game and shade it a distinctive colour. Change the text colour if necessary. You can also select and hide the unneeded rows and columns so that only the game area is displayed.
You may need to change some of the cell references once you insert a new row and column. Do these steps before handing in the project.
#2. Posted:
oCD
  • TTG Natural
Status: Offline
Joined: Dec 02, 201013Year Member
Posts: 986
Reputation Power: 47
Status: Offline
Joined: Dec 02, 201013Year Member
Posts: 986
Reputation Power: 47
Any feedback is appreciated
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.