From my Merlin's Mystical Magic series - When You Were Born Calculator

Started by geecee, May 15, 2009, 11:08:09 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 When You Were Born Calculator.

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

PlayBASIC Code: [Select]
remstart
=======================================================
Puzzles from my Merlin's Wide and Wonderful World
of Mystical Magic
*************************************************
Author: geecee
Written for Play Basic - May 2009
*************************************************
Magical When You Were Born Calculator
=======================================================
remend


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",20,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 300,270,"Hello! My name is Merlin. "
centertext 300,300,"Welcome to my Mystical Magic When You Were Born Calculator"
centertext 300,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 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*7,"Using a calculator, follow each of the instructions"
text 300-tw,height*8,"carefully then click mouse"
sync:wait 1000
text 300-tw,height*10,"Add 18 to your birth month"
sync:wait 50
text 300-tw,height*11,"Multiply by 25 "
sync:wait 50
text 300-tw,height*12,"Subtract 333"
sync:wait 50
text 300-tw,height*13,"Multiply by 8"
sync:wait 50
text 300-tw,height*14,"Subtract 554"
sync:wait 50
text 300-tw,height*15,"Divide by 2"
sync:wait 50
text 300-tw,height*16,"Add your birth date"
sync:wait 50
text 300-tw,height*17,"Multiply by 5"
sync:wait 50
text 300-tw,height*18,"Add 692"
sync:wait 50
text 300-tw,height*19,"Multiply by 20"
sync:wait 50
text 300-tw,height*20,"Add only the last two digits of your birth year"

rem Display screen
sync

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

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

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

rem Determine remaining stages of calculator
rem Convert non-string to string
answer$=str$(answer-32940)

rem Go to "Determine month, day and year when born" subroutine
gosub getmodaye

rem Write text to screen
text 300-tw,height*24,"You were born on "+month$+" "+day$+" "+year$

rem Display screen
sync

rem Wait for a time before proceeding
wait 500

rem Determine width of longest text and divide by two
tw=gettextwidth("Correct? "+"Thank you")/2

rem Set across coordinate
across=300-tw

rem Write text to screen
text across,height*26,"Correct? "

rem Display screen
sync

Login required to view complete source code


:)
Enjoy
geecee

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

Merlin's Mystical Magic series - Puzzle 1
Merlin's Mystical Magic series - Puzzle 2
Merlin's Mystical Magic series - Puzzle 3
Merlin's Mystical Magic series - Magical Card Predictor
Merlin's Mystical Magic series - Magical Birthday Calculator

LANG MEY YER LUM REEK

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