From my Merlin's Mystical Magic series - Magical card Predictor

Started by geecee, May 01, 2009, 04:20:19 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 Card Predictor.

There is one small but insignificant problem ...... When clicking outside card areas, some text flashes ...... I don't know why ...... Perhaps someone will find where I've gone wrong.

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

PlayBASIC Code: [Select]
rem ==========================================================================
rem Initialise program
rem ==========================================================================

rem Set the max frames per second this program should execute at
SetFps 61.7

rem Pre-load required fonts
Arial24 =loadnewfont("arial bold",24,0)
Arial40 =loadnewfont("arial bold",40,0)

rem Declare array/s
Dim CardIMages(1)
Dim cardimage(52)
rem Create an array with 52 spaces (+1 to avoid using '0').
Dim deck(53)

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 tc
global across
global down
global choice

rem Declare global font
global Arial24

rem Pre-load required media
baseimage=loadnewimage("base.bmp")
backdropimage=loadnewimage("backdrop.bmp")
global cardbackimage=loadnewimage("Cardback.bmp")
global backdrop2image=loadnewimage("backdrop2.png")

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 Determine card width, height and number of unique cards in pack
CardWidth =71
CardHeight =96
NumberOfCardsInDeck =50

rem Set text style and size
setfont arial24

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

rem Call function to create images to represent the deck of cards.
Make_Card_Graphics(NumberOfCardsInDeck,CardWidth,CardHeight,CardImages())

rem ==========================================================================
rem Declare Type to represent CARDS within the game
rem ==========================================================================
Type tCard

rem State of this card. Not matched/ Selected / or matched
State

rem Screen position of this card
Xpos
Ypos

EndType

rem ==========================================================================
rem Programme Main Loop
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 Card Predictor."
centertext 310,500,"Press any key to start."

rem wait for a keypress
waitkey
waitnokey

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

rem Jump to Play a game
Gosub PLay_Game

rem Call the end of program sub routine
gosub End_OF_Program:

rem END (TERMINATE) the PROGRAM
End

rem ==========================================================================
rem End Program Subroutine
rem ==========================================================================
End_OF_Program:

rem Set text style and size
setfont arial40

StartTime=Timer()
repeat
boxc 0,0,798,598,1,rgb(255,0,0)
CurrentTime=Timer()
Timepast=ClipRange(Timer()-StartTime,1,1000)
Ink rgbfade(rgb(255,217,128),(1000-TimePast)/10.0)

Xpos= GetScreenWidth()/2
Ypos= GetScreenHeight()*0.40
CenterText Xpos,Ypos,"Thanks For Playing!"

rem Display the Screen
Sync
until CurrentTime>(StartTime+1000)

rem Return to where this subroutine was called
return

rem ==========================================================================
rem Play Game Subroutine
rem ==========================================================================
PLay_Game:

rem Calculate the number of cards that the player will be able to choose from
NumberOfCards=NumberOfCardsInDeck

rem Dimension the card array to hold the info about each of the cards
Dim Cards(NumberOfCards) as tCard

rem Create and randomize the card sequence
Dim CardSequence(NumberOfCards)
index=1
For lp=1 to NumberOfCards step 2
CardSequence(lp)=Index
CardSequence(lp+1)=Index
Inc index
next

rem Initialise cards position and layout upon the screen.
Row =0
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
LANG MEY YER LUM REEK

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

micky4fun

Hi geecee

nice little demo again

cut line 203: boxc 400,0,798,40,1,rgb(255,0,0)
and paste it in line 217:boxc 400,0,798,40,1,rgb(255,0,0)
this will stop the flickering text as it will draw box that is causing the flicker only if mouse is over a card

drawing a box around unwated text seem a little over the top , how about just changing the ink for text to red in this case
then back to white to read it
must be another way of doing this

anyway i used to have a marvin magic set yonks ago , the best card tricks i can remember was the invisible deck , were you pulled a spectators card they choose upside down in pack ,
simple trick but one that got a great responce , another trick i remember was one where you stacked the cards first in a certain order something like 10c 7h 4d 1s and so on , then asked spectator to pick a card out of pack and you could tell them the card they had picked , by having a quick glance of the card they cut to in your hand , something like that anyway

keep up the unusall programs

mick :)

geecee

Hi there micky4fun.

Thanks for your reply and suggestion about moving the box ...... Works OK now ...... Guess I should have picked that up.

Quotehow about just changing the ink for text to red in this case
then back to white to read it

I tried that but I found, going from the light coloured text to RED, didn't work as the RED didn't completely hide the lighter colour ...... For some reason it left an outline ...... Anyway, thanks for your suggestion.

:)
geecee

LANG MEY YER LUM REEK

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

kevin


If you're going to post a 'series' of the snippets, the please take the time to cross reference them.  So users can follow links to the various articles.   See Related to Example

geecee

Thanks for your reply kevin.

How do I achieve this ...... by inserting a Hyperlink (which I know how to use) or is this the purpose of the FTP link (which I don't know how to use)?

???
geecee


Like this,
Merlin's Mystical Magic series - Puzzle 2
LANG MEY YER LUM REEK

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

geecee

Thanks for your reply kevin.

Much appreciated ...... Is there a shortcut button?

:)
geecee
LANG MEY YER LUM REEK

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