Hello,
I am trying to build a card game. It’s called “14 Out.” 52 playing cards are displayed on the screen. There are 12 columns, and in the last 8 columns there are 4 cards. The first 4 columns have 5 cards in them. The user must click on 2 cards whose “values” add to 14, as in 8 and 6,etc…
The user is only able to click on the last card in each column. Once 2 cards whose sum of values is 14 have been selected, they disappear from the screen. I have successfully texture mapped 52 bitmap files to 52 textures.
However, I am unable to get picking to work. I don’t know how to pick the individual cards and I also don’t know how to assign a value to each bitmap file.
I have run picking tutorials, but I need a way to figure out which bitmap image is mapped to the texture the user has clicked on. I can then find the “value” of the card. However, I am completely lost on how to do this. I have looked at virtually every picking tutorial on the web, and I don’t know how to do it. All of the tutorials return the mouse coordinates of where the user has clicked. I want to select the individual card and determine its value. Also, I can’t even get picking itself to work. Which would be the easiest method to pick and how do I figure out the value for each texture? What makes this harder is that the cards are randomized for every run. I do this by randomly selecting a bitmap image out of a char array of 52 bitmap images. This bitmap is then mapped to a quad. This happens in a for loop.
I was thinking of having a switch statement. Once I’ve figured out which card has ben selected, I can, from its name, determine its value. But I don’t know how to do that. I’m sure there’s a way, but I just don’t know of one. I am also using SDL with OpenGl, if that helps.
This is my list of cards:
redacted at uploader's request
This is my texture loading function:
redacted at uploader's request
Finally, this is my quad drawing function:
redacted at uploader's request