Programming Blackjack - assigning numbers to playing cards
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Programming Blackjack - assigning numbers to playing cards
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
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
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.)
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.)
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
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