Another fun programme from my Merlin's Wide and Wonderful World of Mystical Magic series
remstart
-------------------------------------------------------
Puzzle Number 3 from my Merlin's Wide and Wonderful
World of Mystical Magic series
***********************
Author: gearce - December 2006
***********************
This is Puzzle Number 3 from my Merlin's Wide and
Wonderful World of Mystical Magic series but without
all the bitmaps, images, special effects etc
-------------------------------------------------------
remend
` This command will hide the mouse pointer
hide mouse
` Messages
a$="Hello! I'm Merlin."
b$=""
c$="Allow me to show you some of"
d$="my Mystical Magic with Puzzle"
e$="Number 3 from my Wide and"
f$="Wonderful World of Mystical"
g$="Magic series, but without all the"
h$="bitmaps, images, special effects"
i$="etc"
` Determine text height. Determine text width
`(i.e width of longest message line). Determine
` where to write text to screen. Set ink colour
th=21
tw=text width(h$)
a=320-(tw/2):across=a:down=156
ink rgb(255,255,255),1
` Go to subroutine to get letters from the messages
message$=a$
gosub get_letters
message$=b$
across=a:inc down,(th*1)
gosub get_letters
message$=c$
across=a:inc down,(th*1)
gosub get_letters
message$=d$
across=a:inc down,(th*1)
gosub get_letters
message$=e$
across=a:inc down,(th*1)
gosub get_letters
message$=f$
across=a:inc down,(th*1)
gosub get_letters
message$=g$
across=a:inc down,(th*1)
gosub get_letters
message$=h$
across=a:inc down,(th*1)
gosub get_letters
message$=i$
across=a:inc down,(th*1)
gosub get_letters
` Wait for a time before proceeding
wait 3000
` Start of programme
start:
` Clear screen
cls
` Declare array/s
dim a$(84)
` Assure random is always different
randomize timer()
` Initialise counters
answer$=""
result$=""
result=0
age=0
` Wait for a time before proceeding
wait 1000
` ---------------------------------------------
` Select a number from 1 to 99
` ---------------------------------------------
` Messages
a$="Click mouse to select a number from 1 to 99"
b$=""
` Call normal text function. Determine text height.
` Determine text width `(i.e width of longest message
` line). Determine where to write text to screen.
font_21(a$)
th=text height("arial")
tw=text width(a$)
a=320-(tw/2):across=a:down=179
` Go to subroutine to get letters from the messages
message$=a$
gosub get_letters
message$=b$
across=a:inc down,(th*1)
gosub get_letters
` Set counters
across=320:inc down,(th*1)
` Until mouse is clicked
do
` Generate a random number from 1 to 99
number=rnd(98)+1
number$=str$(number)
` Where to write number to screen
center text across,down,number$
` Wait for a time before proceeding
wait 100
` If mouse is clicked a selection has been
` made so exit loop ...
if mouseclick()=1
exit
endif
` ... else go back to generate another number
` Go to subroutine to draw a box
gosub drawabox
` End the loop
loop
` Wait for a time before proceeding
wait 1000
` ---------------------------------------------
` Multiply the number by 2
` ---------------------------------------------
` Messages
a$="Multiply the number by 2, write down the"
b$="answer and click mouse"
tw=text width(a$)
a=320-(tw/2):across=a:inc down,(th*2)
` Go to subroutine to get letters from the messages
message$=a$
gosub get_letters
message$=b$
across=a:inc down,(th*1)
gosub get_letters
` Wait for mouse click
suspend for mouse
` Clear screen
cls
` Wait for a time before proceeding
wait 1000
` ---------------------------------------------
` Add 5 to answer
` ---------------------------------------------
` Messages
a$="Add 5 to the result, write down the answer"
b$="and click mouse"
tw=text width(a$)
a=320-(tw/2):across=a:down=230
` Go to subroutine to get letters from the messages
message$=a$
gosub get_letters
message$=b$
across=a:inc down,(th*1)
gosub get_letters
` Wait for mouse click
suspend for mouse
` Clear screen
cls
` Wait for a time before proceeding
wait 1000
` ---------------------------------------------
` Multiply answer by 50
` ---------------------------------------------
` Messages
a$="Multiply the result by 50, write down the"
b$="answer and click mouse"
tw=text width(a$)
a=320-(tw/2):across=a:down=230
` Go to subroutine to get letters from the messages
message$=a$
gosub get_letters
message$=b$
across=a:inc down,(th*1)
gosub get_letters
` Wait for mouse click
suspend for mouse
` Clear screen
cls
` Wait for a time before proceeding
wait 1000
` ---------------------------------------------
` Add age to answer
` ---------------------------------------------
` Messages
a$="Add your age to the result, write down the"
b$="answer and click mouse"
tw=text width(a$)
a=320-(tw/2):across=a:down=230
` Go to subroutine to get letters from the messages
message$=a$
gosub get_letters
message$=b$
across=a:inc down,(th*1)
gosub get_letters
` Wait for mouse click
suspend for mouse
` Clear screen
cls
` Wait for a time before proceeding
wait 1000
` ---------------------------------------------
` Tell answer
` ---------------------------------------------
` Messages
a$="Tell me the answer by clicking the"
b$="appropriate box numbers then End"
c$=""
tw=text width(b$)
a=320-(tw/2):across=a:down=177
` Go to subroutine to get letters from messages
message$=a$
gosub get_letters
message$=b$
across=a:down=down+(th*1)
gosub get_letters
message$=c$
across=a:down=down+(th*1)
gosub get_letters
` Go to subroutine to draw matrix
gosub drawmatrix
` Determine where to start and place
` numbers in matrix
across=92
for a=0 to 9
inc across,38
center text across,261,str$(a)
if a=10
exit
endif
next a
end$="End"
inc across,38
center text across,261,end$
` Until answer equals end
do
` When answer equals end
if answer$=end$
exit
endif
` If no selection is made come to here
no_selection:
` Wait for a time before proceeding
wait 50
` This command will show the mouse pointer
show mouse
` Go to subroutine to check selection
gosub check_selection
` Wait for a time before proceeding
wait 50
` End loop
loop
` Determine result
result=val(result$)
` Clear screen
cls
` Wait for a time before proceeding
wait 1000
` ---------------------------------------------
` Ask birthday question
` ---------------------------------------------
` Messages
a$="Have you had your birthday this year"
b$="Left click mouse for YES - right click mouse for NO"
tw=text width(b$)
a=320-(tw/2):across=a:down=230
` Go to subroutine to get letters from messages
message$=a$
gosub get_letters
message$=b$
across=a:down=down+(th*1)
gosub get_letters
` Until mouse is clicked
do
mouseclick=MouseClick()
if mouseclick=1
`goto yes
result=result-250
age=result-(number*100)
exit
endif
if mouseclick=2
` goto no
result=result-251
age=result+1-(number*100)
exit
endif
` End loop
Loop
` Clear screen
cls
` Wait for a time before proceeding
wait 1000
` -------------------------------------------
` Reveal mystical magic ...
` -------------------------------------------
` Messages
a$="Your age is"
b$=""
c$=str$(age)
tw=text width(a$)
a=320-(tw/2):across=a:down=81
` Go to subroutine to get letters from messages
message$=a$
gosub get_letters
message$=b$
across=a:inc down,(th*1)
gosub get_letters
` Wait for a time before proceeding
wait 1000
` Switch to large text
` Call large text function. Determine text height.
` Determine where to write text to screen.
font_120(a$)
th=text height("arial")
down=180
center text 320,down,c$
` Wait for a time before proceeding
wait 1000
` -------------------------------------------
` ... and ask play again
` -------------------------------------------
` Messages
a$="Correct? "
b$="Thank you"
c$="Play again Yes or No"
d$="Left click mouse for YES - right click mouse for NO"
` Return to normal text
` Call normal text function. Determine text height.
` Determine text width `(i.e width of longest message
` line). Determine where to write text to screen.
font_21(a$)
th=text height("arial")
tw=text width(a$+b$)
a=320-(tw/2):across=a:down=357
` Go to subroutine to get letters from messages
message$=a$
gosub get_letters
` Wait for a time before proceeding
wait 1000
` Go to subroutine to get letters from messages
message$=b$
tw=text width(a$)
across=a+tw:down=down
gosub get_letters
message$=c$
tw=text width(c$)
a=320-(tw/2):across=a:inc down,(th*1)
gosub get_letters
message$=d$
tw=text width(d$)
a=320-(tw/2):across=a:inc down,(th*1)
gosub get_letters
` Until mouse is clicked
do
mouseclick=MouseClick()
if mouseclick=1
goto start
exit
endif
if mouseclick=2
goto the_end
exit
endif
` End loop
Loop
` End of programme
the_end:
cls
end
` -------------------------------------------------------------
` Functions
` -------------------------------------------------------------
function font_21(a$)
set text font "arial"
set text size 21
set text to bold
endfunction
function font_120(a$)
set text font "arial"
set text size 120
set text to bold
endfunction
` -------------------------------------------------------------
` Subroutines
` -------------------------------------------------------------
` ---------------------------------------------
` Subroutine to get letters from messages and
` write one at a time to screen
` ---------------------------------------------
get_letters:
long=len(message$)
for z= 1 to long
text across,down,left$(message$,(long-(long-z)))
next z
delay=0
return
` ----------------------------------------------
` Subroutine for keypress Y or N
` ----------------------------------------------
yes_or_no:
repeat
a=scancode()
until a=21 or a=49
return
` ----------------------------------------------
` Subroutine to draw a box on screen
` ----------------------------------------------
drawabox:
` Set ink colour
ink rgb(0,0,0),1
` Where on screen to draw box
left=320-10
top=down
right=(left+19)
bottom=(top+19)
` Draw the box
box left,top,right,bottom
` Reset ink colour
ink rgb(255,255,255),1
return
` ----------------------------------------------
` Subroutine to draw matrix on screen
` ----------------------------------------------
drawmatrix:
` Where on screen to draw matrix
box 111,251,529,289
ink rgb(0,0,0),1
box 112,252,528,288
ink rgb(255,255,255),0
left=111
for a=1 to 12
line left,251,left,289
inc left,38
next a
return
` -------------------------------------------------
` Subroutine to check for selection
` -------------------------------------------------
check_selection:
`Wait for mouse click
suspend for mouse
` If mouse button is pressed
x=mousex()
y=mousey()
` This command will hide the mouse pointer
hide mouse
if (x>=112 and x<=148) and (y>=252 and y<=288)
selection=0
goto re_turn
endif
if (x>=150 and x<=186) and (y>=252 and y<=288)
selection=1
goto re_turn
endif
if (x>=188 and x<=224) and (y>=252 and y<=288)
selection=2
goto re_turn
endif
if (x>=226 and x<=262) and (y>=252 and y<=288)
selection=3
goto re_turn
endif
if (x>=264 and x<=300) and (y>=252 and y<=288)
selection=4
goto re_turn
endif
if (x>=302 and x<=338) and (y>=252 and y<=288)
selection=5
goto re_turn
endif
if (x>=340 and x<=376) and (y>=252 and y<=288)
selection=6
goto re_turn
endif
if (x>=378 and x<=414) and (y>=252 and y<=288)
selection=7
goto re_turn
endif
if (x>=416 and x<=452) and (y>=252 and y<=288)
selection=8
goto re_turn
endif
if (x>=454 and x<=490) and (y>=252 and y<=288)
selection=9
goto re_turn
endif
if (x>=492 and x<=528) and (y>=252 and y<=288)
answer$=end$
return
endif
goto no_selection
re_turn:
result$=result$+str$(selection)
return
Like the others, highlight text, right click, copy and paste into DBClassic.
Enjoy. There's more to come.
gearce
LANG MAY YER LUM REEK