News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Domino Magic

Started by geecee, March 07, 2009, 11:20:04 PM

Previous topic - Next topic

geecee

Another short programme ...... Domino Magic

Here you will need a Double-Six set of 28 dominoes.

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

DOMINO MAGIC
***********************

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$="DOMINO MAGIC"

` 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$="From a Double-Six set of 28 dominoes, choose any one ...... 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$="Multiply one of the numbers on the domino by 5 ...... Press any key when ready."

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

sync
waitkey
waitnokey

` Define message/s
message$="Add 7 to the result ...... Press any key when ready."

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

sync
waitkey
waitnokey

` Define message/s
message$="Multiply the sum by 2 ...... Press any key when ready."

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

sync
waitkey
waitnokey

` Define message/s
message$="Add the other number on the domino ...... Press any key when ready."

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

sync
waitkey
waitnokey

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

sync
waitkey
waitnokey

` Determine chosen domino
chosen_domino$=str$(val(answer$)-14)
if val(chosen_domino$)<10 then chosen_domino$=chosen_domino$+"0"
first$=mid$(chosen_domino$,1,1):second$=mid$(chosen_domino$,2,1)

` Define message/s
message$="You chose the ...... "+first$+":"+second$+" domino"

` 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

` Padding message of blank characters
x$=" "

` Until the desired result is achieved
repeat

` Set ink colour and draw a box to hide previous text at location
ink rgb(0,0,0)
box 10,479,790,500,1

` Set new ink colour
ink rgb(255,217,128)
Login required to view complete source code


As always, any comments constructive or otherwise appreciated.

:)
Enjoy.
geecee


LANG MEY YER LUM REEK

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