From my Merlin's Mystical Magic series - Magical Birthday Calculator

Started by geecee, May 09, 2009, 07:17:57 PM

Previous topic - Next topic

geecee

Hi there!

Here's another from my Merlin's Wide and Wonderful World of Mystical Magic series ...... Mystical Magic Birthday Calculator.

I have posted the code here but it and necessary media are in the attached .zip file

PlayBASIC Code: [Select]
; PROJECT : Magic Birthday Calculator
; AUTHOR : geecee
; CREATED : 8/05/2009
; EDITED : 10/05/2009
; ---------------------------------------------------------------------

rem ==========================================================================
rem Initialise programme
rem ==========================================================================

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

rem Pre-load required fonts
font1 =loadnewfont("arial bold",22,0)
font2=loadNewfont("arial bold",40,0)

rem Pre-load required media
baseimage=loadnewimage("base.bmp")

rem This command will hide the mouse pointer
mouse off

rem Set text style and size
setfont font1

rem Determine text height
height=gettextheight("arial bold")

rem Set ink colour
ink rgb(255,217,128)

rem ==========================================================================
rem Programme Introduction
rem ==========================================================================

rem Display an image
drawimage baseimage,0,0,false

rem Write text to screen
centertext 310,270,"Hello! My name is Merlin. "
centertext 310,300,"Welcome to my Mystical Magic Birthday Calculator."
centertext 310,500,"Click mouse to start."

rem Display screen
sync

rem Go to "Wait for mouse click subroutine"
gosub waitformouse

rem This do .. loop calls all the procedures in turn to play the game.
do
gosub play_game
gosub play_again
loop

rem End programme
end

rem ================================================================
rem Play game subroutine
rem ================================================================
play_game:

rem Draw a box to hide previous text at location
boxc 2,130,594,598,1,rgb(255,0,0)

rem Display screen
sync

rem A short wait before proceeding
wait 500

rem Determine width of longest text message and divide by two
tw=gettextwidth("Using a calculator, follow each of the instructions")/2

rem Write text to screen, display screen and a short wait before proceeding
text 300-tw,height*6,"Using a calculator, follow each of the instructions"
text 300-tw,height*7,"carefully then click mouse"
sync:wait 1000
text 300-tw,height*9,"Multiply the month of your birth by 7"
sync:wait 50
text 300-tw,height*10,"Subtract 1"
sync:wait 50
text 300-tw,height*11,"Multiply by 13"
sync:wait 50
text 300-tw,height*12,"Add the day of your birth"
sync:wait 50
text 300-tw,height*13,"Add 3"
sync:wait 50
text 300-tw,height*14,"Multiply by 11"
sync:wait 50
text 300-tw,height*15,"Subtract the month of your birth"
sync:wait 50
text 300-tw,height*16,"Subtract the day of your birth"

rem Display screen
sync

rem Go to "Wait for mouse click subroutine"
gosub waitformouse

rem Set cursor position
setcursor 300-tw,height*18

rem Key in answer
answer#=val(staticinput("Key in your answer > "))

rem Determine remaining stages of calculator
answer#=answer#/10
answer#=answer#+11
answer#=answer#/100

rem Convert non-string to string
answer$=str$(answer#)

rem Determine day of birthday calculation
select right$(answer$,1)
case "1":day$="10th"
case "2":day$="20th"
case "3":day$="30th"
endselect
select right$(answer$,2)
case "01":day$="1st"
case "02":day$="2nd"
case "03":day$="3rd"
case "04":day$="4th"
case "05":day$="5th"
case "06":day$="6th"
case "07":day$="7th"
case "08":day$="8th"
case "09":day$="9th"
case "11":day$="11th"
case "12":day$="12th"
case "13":day$="13th"
case "14":day$="14th"
case "15":day$="15th"
case "16":day$="16th"
case "17":day$="17th"
case "18":day$="18th"
case "19":day$="19th"
case "21":day$="21st"
case "22":day$="22nd"
case "23":day$="23rd"
case "24":day$="24th"
case "25":day$="25th"
case "26":day$="26th"
case "27":day$="27th"
case "28":day$="28th"
Login required to view complete source code



Others from my Merlin's Wide and Wonderful World of Mystical Magic series

Merlin's Mystical Magic series - Magical card Predictor
Merlin's Mystical Magic series - Puzzle 1
Merlin's Mystical Magic series - Puzzle 2
Merlin's Mystical Magic series - Puzzle 3

:)
Enjoy
geecee

LANG MEY YER LUM REEK

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