News:

Function Finder  Find all the functions within source code files

Main Menu

Amazing mind reading dice trick

Started by geecee, March 07, 2009, 09:35:20 PM

Previous topic - Next topic

geecee

Another short programme ...... Amazing mind reading dice trick

Here you will need three dice.

PlayBASIC Code: [Select]
remstart
=======================================================

AMAZING MIND READING DICE TRICK
***********************

Author: geecee
Written for Play Basic - March 2009

***********************

=======================================================
remend


` Start of programme
start:

` Tell PB to include the input support library
#include "Input"

` This command will hide the mouse pointer
mouse off

` Declare array/s
dim message$(4)

` Set down coordinate
down=30

` Set new ink colour
ink rgb(255,217,128)

` Define title
title$="AMAZING MIND READING DICE TRICK"

` Set text style and size
loadfont "arial bold",1,30,0

`Write title to screen
centertext 400,down,title$

` A short wait before proceeding
sync
wait 3000

` Set text style and size
loadfont "arial bold",1,20,0

` Determine height of text
height=gettextheight("arial bold")

` Define message/s
message$="Here you will need three dice ...... Press any key when ready."

` Write message/s to screen
centertext 400,down+height*4,message$

` Wait for a keypress
sync
waitkey
waitnokey

` Define message/s
message$="Roll the dice and put them in a row ...... Press any key when ready."

` Write message/s to screen
centertext 400,down+height*6,message$

sync
waitkey
waitnokey

` Define message/s
message$(1)="Write down the three values shown on the dice to make a 3-digit number ..."
message$(2)="... Press any key when ready."

` Write message/s to screen
centertext 400,down+height*8,message$(1)
centertext 400,down+height*8+height,message$(2)

sync
waitkey
waitnokey

` Define message/s
message$="Turn the dice over ...... Press any key when ready."

` Write message/s to screen
centertext 400,down+height*11,message$

sync
waitkey
waitnokey

` Define message/s
message$(3)="Append to the number you have already written the values shown, in the same order,"
message$(4)="to make a 6-digit number ...... Press any key when ready."

` Write message/s to screen
centertext 400,down+height*13,message$(3)
centertext 400,down+height*13+height,message$(4)

sync
waitkey
waitnokey

` Define message/s
message$="Divide this number by 111 ...... Press any key when ready."

` Write message/s to screen
centertext 400,down+height*16,message$

sync
waitkey
waitnokey

` Set cursor position and enter answer
setcursor 400-gettextwidth("Subtract 7 and key in your answer > ")/2,down+height*18
answer$=staticinput("Subtract 7 and key in your answer > ")

sync
waitkey
waitnokey

` Determine dice rolled
dice_rolled$=str$(val(answer$)/9)
first$=mid$(dice_rolled$,1,1):second$=mid$(dice_rolled$,2,1):third$=mid$(dice_rolled$,3,1)

` Define message/s
message$="You rolled ...... "+first$+" "+second$+" "+third$

` Write message/s to screen
centertext 400,down+height*20,message$

` A short wait before proceeding
sync
wait 3000

` Define message/s
message$="Correct? ...... Thank you"

` Determine width of message
tw=gettextwidth(message$)

` Where to write message to screen
text 400-tw/2,down+height*22,message$

sync
wait 1000
Login required to view complete source code


Again, any comments, constructive or otherwise appreciated.

:)
Enjoy
geecee
LANG MEY YER LUM REEK

A smile costs less than electricity and gives more light :)

micky4fun

Hi greecee

QuoteHere you will need three dice.
and a calculator , lol , for me anyway

nice program , seems you know quite a few of these trick maths in work programs ,
there are very good and amazed my girlfriend , she loves stuff like this to

more more more we want more

mick :)

geecee

Thanks for your reply micky4fun.

Your comments are appreciated ...... I have a few more  puzzles left.

;)
geecee

LANG MEY YER LUM REEK

A smile costs less than electricity and gives more light :)