The arguments of the transform property are functions. There are two sets of functions, 2D transform function and 3D. CSS transform functions are designed to move, scale, rotate, and skew the target DOM elements. The following shows the usage of the transforms functions.
The 3D rotation function rotates the element in 3D space by the given [x, y, z] unit vector.
For example, we can rotate the Y-axis 60 degrees by using rotate3d(0, 1, 0, 60deg):
rotate3d(x, y, z, angle)
We can also rotate one axis only by calling the following handy functions:
rotateX(angle)
rotateY(angle)
rotateZ(angle)
What is CSS3 transition? W3C explains it in one sentence:
CSS transitions allows property changes in CSS values to occur smoothly over a specified duration.
Normally, when we change any properties of the element, the properties are updated to the new value immediately. Transition slows down the changing process. It creates smooth in-between easing from the old value towards the new value in the given duration.
You have to note that the front face has a higher z-index than the back face. When we flip the card, we rotate the front face to back and back face to front. We also swap the z-index of the front and back face.
When a card is “removed”, its container has the class “card-removed” which make the element “disappear” (opacity is set to 0, or, for IE browsers version less than 9, the display:none property is set).
All cards are in on single image. To display each one (from a predefined set) we have to set the background-position style property for them:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
/* define the face graphics of the card deck*/ /* cardAA stands for Spade A */ /* cardA10 stands for Spade 10 */ /* cardAK stands for Spade K */ /* cardB_ stands for Heart _ */ /* cardC_ stands for Club _ */ /* cardD_ stands for Diamond _ */ .cardAA { background-position: 0 0; } .cardA8 { background-position: -553px 0; } .cardA9 { background-position: -632px 0; } .cardA10 { background-position: -711px 0; } .cardAJ { background-position: -790px 0; } .cardAQ { background-position: -869px 0; } .cardAK { background-position: -948px 0; } .cardB8 { background-position: -553px -123px; } .cardB9 { background-position: -632px -123px; } .cardB10 { background-position: -711px -123px; } .cardBJ { background-position: -790px -123px; } .cardBQ { background-position: -869px -123px; } .cardBK { background-position: -948px -123px; } .cardC8 { background-position: -553px -246px; } .cardC9 { background-position: -632px -246px; } .cardC10 { background-position: -711px -246px; } .cardCJ { background-position: -790px -246px; } .cardCQ { background-position: -869px -246px; } .cardCK { background-position: -950px -246px; } .cardA8 { background-position: -553px -369px; } .cardA9 { background-position: -632px -369px; } .cardA10 { background-position: -711px -369px; } .cardDJ { background-position: -790px -369px; } .cardDQ { background-position: -869px -369px; } .cardDK { background-position: -948px -369px; } |
Having this, we can now take care of the game engine.





