News:

Function Finder  Find all the functions within source code files

Main Menu

A little bit of card magic

Started by geecee, March 04, 2009, 12:23:58 AM

Previous topic - Next topic

geecee

Another short programme ...... A little bit of card magic.

You will require nine cards, Ace to 9, from a standard deck of playing cards or hand numbered cards or pieces of paper.

remstart
  =======================================================

                A LITTLE BIT OF CARD MAGIC
                  ***********************

                       Author: geecee
            Written for Play Basic - March 2009

                  ***********************

  =======================================================
remend

` Start of programme
start:

` Set text style and size
loadfont "arial bold",1,20,0

` Set new ink colour
ink rgb(255,217,128)

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

` Declare array/s
dim message$(4)

` Title message
title$="A LITTLE BIT OF CARD MAGIC"
centertext 400,100,title$

` Define message/s
message$(1)="From a standard deck of 52 playing cards, remove one of each Ace to 9,"
message$(2)="no matter what suit, place them face up in three rows of three and press"
message$(3)="any key."

` set down coordinate
down=30

` Determine height and width of message/s
height=gettextheight(message$(1))
tw=gettextwidth(message$(1))

` Where to write messages to screen
text 400-tw/2,300-height*1,message$(1)
text 400-tw/2,300,message$(2)
text 400-tw/2,300+height*1,message$(3)

` Wait for a keypress
sync
waitkey

` A short wait before proceeding
sync
wait 100

` Set ink colour and draw a box to hide previous text at location
ink rgb(0,0,0)
box 10,120,790,590,1

` Set new ink colour
ink rgb(255,217,128)

` Define message/s
message$(4)="Now remove any one of the cards and press any key."

` Where to write messages to screen
centertext 400,300,message$(4)

` Wait for a keypress
sync
waitkey

` Set ink colour and draw a box to hide previous text at location
ink rgb(0,0,0)
box 10,120,790,590,1

` Set new ink colour
ink rgb(255,217,128)

  ` Print a number of blank lines
  for a=1 to 16
    print ""
  next a

` Input answer to question
answer$=staticinput("              Now add up the card values in each of the three rows and key in your answer > ")

` A short wait before proceeding
sync
wait 100

` Set ink colour and draw a box to hide previous text at location
ink rgb(0,0,0)
box 10,120,790,590,1

` Set new ink colour
ink rgb(255,217,128)

` Set text style and size
loadfont "arial black",1,20,0

` Define message/s
message$="Now here's the magic ..... watch this"
centertext 400,300,message$

` A short wait before proceeding
sync
wait 3000

` Set ink colour and draw a box to hide previous text at location
ink rgb(0,0,0)
box 10,120,790,590,1

` Set new ink colour
ink rgb(255,217,128)

` Determine the card removed ...... The total value of the 9 face up cards is 45
removed=45-val(answer$)

  ` What happens depending on card removed
  if removed=1
    message$="You removed the "
    cardremoved$="Ace"
  else
    message$="You removed the "
    cardremoved$=str$(removed)
  endif

` Where on screen to write message
centertext 400,200,message$

` Set text style and size
loadfont "arial black",1,288,0
height=gettextheight("arial black")/2

` Where on screen to write card removed
centertext 400,300-height,cardremoved$

` Set text style and size
loadfont "arial bold",1,20,0

` A short wait before proceeding
sync
wait 1000

` Define message/s
message$="Correct? ...... Thank you"

` Determine width of message
tw=gettextwidth(message$)

` Where to write message to screen
text 400-tw/2,430,message$

sync
wait 1000

  ` Print a number of blank lines
  for a=1 to 10
    print ""
  next a

` Padding message of blank characters
x$="                                                             "

` Input answer to question
answer$=staticinput(x$+"Play again [Y] or [N] > ")

` A short wait before proceeding
sync
wait 100

  if answer$="Y" or answer$="y"

    ` Clear screen
    cls rgb(0,0,0)

    ` A short wait before proceeding
    sync
    wait 3000

    ` Restart programme
    gosub start

  else

    ` Set ink colour and draw a box to hide previous text at location
    ink rgb(0,0,0)
    box 10,120,790,590,1

    ` Set new ink colour
    ink rgb(255,217,128)
 
    ` Set text style and size
    loadfont "arial bold",1,40,0

    ` Write message to screen
    centertext 400,300,"BYE!   THANKS FOR PLAYING"
 
    ` Set text style and size
    loadfont "arial bold",1,20,0

    ` A short wait before proceeding
    sync
    wait 3000

    ` End programme
    end
  endif


Any comments, constructive or otherwise, appreciated.

Thanks
geecee
LANG MEY YER LUM REEK

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