Processing: memory card game

Processing: memory card game


We’re going to do this memory card program
in an object-oriented fashion so we’re going to start by creating our cards class. We’re
going to name the class “Card” and traditionally when you create a class, it is named with
a capital letter which is the way the ‘C’ is here. Now I should have these matching;
it should match the name here. So class “Card” and Card. And what it is saved as, that’s
the proper way to do it. I’m going to declare a PImage which is going
to be our cardImage. I’m going to have show. This is going to tell me am I showing the
back of the card which would be 0. I have the cardWidth, I have the cardHeight; those
are just references. I don’t actually use them. I might in some games. I can comment
them out now. It’s good to know what the actual widths are but I don’t actually need to use
them. I have my cardX which is the X position and
the cardY, and faceValue because it’s going to get a face value from our array. We have
an array of cardNames which are the actual locations of the cards. I’ve actually put
in more than I need in case you wanted to take it further. And we have…in the data
folder we have cards — one of my students created these for me — but we have a whole
set…I have a whole set of cards available. This one only goes through jack and queen,
but I do have a full set available that we’ll be using for the final project. And then I’m going to have my constructor
Cards and it is accepting an integer for X, an integer for Y, and an integer for faceValue
and that would be the index of the cards. I have a display () function and ii have a
displayFront () function which makes show=faceValue. In the next video I’ll go through
the memoryStart portion of the program.