Page 1 of 1
Programming Blackjack - assigning numbers to playing cards
Posted: Wed Feb 11, 2009 4:15 pm
by sel203
Hello,
I am very inexperienced at programming but I have managed to set up a simplified version of blackjack for my psychology experiment I am running. I would like to assign numbers of the cards to actual images of playing cards to appear on screen. I have saved each image of the playing cards in separate pdf files but I am struggling to sort out how to make this appear when, say, a '7' comes up.
Would appreciate any advice on this.
Thanks
Sara
Posted: Wed Feb 11, 2009 8:49 pm
by SparkOut
Do you need the application to open the pdf in an external pdf reader? or display the image in the stack application?
If you make an array, then either way it should be simple.
for displaying external pdf files:
put "<<the path to pdf file for card1.pdf>>" into tArrCards[1]
put "<<the path to pdf file for card2.pdf>>" into tArrCards[2]
--etc, (you can make this less tedious by "splitting a list" but it doesn't matter how you build the array)
when you get the number of the card you want to display (say in "theCardNumber" variable), then you can:
launch document ("file:" & tArrCards[theCardNumber])
--
if you want to display the images inside the stack, then it would be best to change from pdf format to an image format like png.
Make an image placeholder on your stack the right dimensions to hold the card image. Build an array similar to above.
When you get the number of the card you want to display (say in theCardNumber variable), then you can:
set the filename of image "imgPlaceHolder" to ("binfile:" & tArrCards[theCardNumber])
(If you need to make it portable, it would also be possible to import all the images into the stack and use the id of those (hidden, or placed on another card) to be the array contents. Then you can: set the text of image "imgPlaceHolder" to the text of image id (tArrCards[theCardNumber]) or some similar approach. Lots of ways to skin a cat in Rev.)
Posted: Wed Feb 11, 2009 10:15 pm
by sel203
Thank you for the advice. I need the cards to appear in the stack so I will try what you suggest.
Posted: Wed Feb 11, 2009 10:51 pm
by Klaus
Small corection:
set the filename of image "imgPlaceHolder" to ("binfile:" & tArrCards[theCardNumber])
Should be a simple:
set the filename of image "imgPlaceHolder" to tArrCards[theCardNumber]
Without "binfile:"!
Best
Klaus
Posted: Wed Feb 11, 2009 11:07 pm
by SparkOut
Whoops yes. That'd get you the contents of the file inserted as the filename which would certainly not be what you want. Sorry for the confusion.
Posted: Sat Feb 21, 2009 4:53 pm
by sel203
Hello,
Thank you for you help but I'm struggling! Unfortuately I am very unexperienced - I've tried but I'm not sure how to create an image placeholder? There is a .csv file that indicates which card image I want selected i.e. 10D (10 of diamonds) needs to bring up the pgn image of the 10D in a certain place on the screen. Still not sure how.
Thanks in advance,
Sarah
Posted: Sat Feb 21, 2009 10:27 pm
by gyroscope
Hi Sarah, I think I can help here:
Very straightforward: drag an image box (just below the Little Arrows control) from the toolbar onto your stack and name it "imgPlaceHolder"
