News:

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

Main Menu

From my Merlin's Mystical Magic series - Magic Number 15

Started by geecee, May 20, 2009, 01:02:16 AM

Previous topic - Next topic

geecee

Hi there!

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

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
*************************************************
The Magic Number 15
=======================================================
remend


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

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

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

rem Declare array/s
Dim cardimage(52)
dim random_index(52)
dim card$(4)
dim x$(4)
dim selection(4)
rem Create an array with 52 spaces (+1 to avoid using '0')
dim deck(53)

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

for lp=1 to 13
CardIMage(lp) = LoadNewImage(Str$(lp)+"H"+".Bmp")
CardIMage(13+lp) = LoadNewImage(Str$(lp)+"C"+".Bmp")
CardIMage(26+lp) = LoadNewImage(Str$(lp)+"D"+".Bmp")
CardIMage(39+lp) = LoadNewImage(Str$(lp)+"S"+".Bmp")
next

rem Fill the deck(xx) with values 1 to 52
for cards=1 to 52
deck(cards)=cards
next cards

rem Declare global variables
global x$

rem Determine card width and height
CardWidth =71
CardHeight =96

rem Set text style and size
setfont font1

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 Wide and Wonderful World"
centertext 300,330,"of Mystical Magic."
centertext 300,500,"Click mouse to continue."

rem Display screen
sync

rem Wait for mouse click
Waitmouse false, (1+2)
mb=mousebutton()

rem Wait until the mouse button is released
WaitNoInput

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

rem Write text to screen
centertext 300,270,"Select any four cards from the 28."
centertext 300,300,"No matter which four you select the"
centertext 300,330,"total will always be 15."
centertext 300,500,"Click mouse to continue."

rem Display screen
sync

rem Wait for mouse click
Waitmouse false, (1+2)
mb=mousebutton()

rem Wait until the mouse button is released
WaitNoInput

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 Set variable values to zero
selection=0
selection(1)=0:selection(2)=0:selection(3)=0:selection(4)=0

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

rem Display screen
sync

rem Set times counter to zero
times=0

rem Determine answer
answer=15

rem Set down coordinate
down=45

rem Draw card images
for place=1 to 28

select place
case 1:across=42:down=down+100
case 1, 8, 15, 22:across=42:down=down+100
case 2 to 7:across=across+75:down=down
case 9 to 14:across=across+75:down=down
case 16 to 21:across=across+75:down=down
case 23 to 28:across=across+75:down=down
endselect

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
Merlin's Mystical Magic series - Magical When You Were Born Calculator

LANG MEY YER LUM REEK

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