https://github.com/dennisliu1993/blackjack
Using MFC to create a BlackJack game platform
https://github.com/dennisliu1993/blackjack
blackjack cbuttonst cpp doublebuffer mfc userinterface
Last synced: 3 months ago
JSON representation
Using MFC to create a BlackJack game platform
- Host: GitHub
- URL: https://github.com/dennisliu1993/blackjack
- Owner: DennisLiu1993
- Created: 2022-09-03T21:04:31.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-09-30T08:29:38.000Z (about 3 years ago)
- Last Synced: 2025-06-26T15:51:17.966Z (4 months ago)
- Topics: blackjack, cbuttonst, cpp, doublebuffer, mfc, userinterface
- Language: C++
- Homepage:
- Size: 11.6 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BlackJack
Using MFC to create a BlackJack game platform# What Techniques Used in This Project
1. **double buffer drawing** strategy in MFC to prevent controls or numbers from blinking (see OnPaint ())
2. usage of **CButtonST** (Image Button with features of **transparent background** and no border)
3. OpenCV **perspective tranform** to show slanted cards (see WarpPespective ())
4. dynamically show number changes (see code when win or lose)
5. **dealing cards animation**# Interface
# Demo Gif
# How to Build
1. Download Visual Studio 2017 or newer versions
2. Check on the option of "x86 and x64 version of C++ MFC"
3. Install
4. Open BlackJack.vcxproj
5. Upgrade if it is required
6. Open this project's property page
7. Choose the SDK version you have in "General-Windows SDK Version"
8. Choose the right toolset you have in "General-Platform Toolset" (for me, it is Visual Studio 2017 (v141))
9. Go to "C/C++ - General", and type in "Additional Include Directories" for your own OpenCV include headers (e.g. C:\OpenCV3.1\opencv\build\include or C:\OpenCV4.0\opencv\build\include)
11. Type in "Library Directories" for your own OpenCV's library path (the directory where your opencv_worldXX.lib locates)
12. Go to "Linker-Input", and type in library name (e.g. C:\OpenCV3.1\build2017_worldx64\lib\opencv_world310d_vs2017_x64.lib)
13. Make sure that your opencv_worldXX.dll and is in the same directory as .exe of this project (after building)# Extentions
With Perspective Tranform, we can make the animation of deal more fluent and sophistocated.If we want to build a full action of flipping cards, we need to divide this action into several steps.
For instance, now I break flipping cards into 20 actions with 20 different perspective matrix:
In this way, showing all cards continually can simulate the action of flipping

















code to output images like this:
```
Point2f vecLT2RT = PLAYER_CARD1_RT - PLAYER_CARD1_LT;
Point2f vecLB2RB = PLAYER_CARD1_RB - PLAYER_CARD1_LB;
for (int i = 1; i < 20; i++)
{
Mat matShow = m_matShow.clone ();
m_ptsPlayerOne[0] = PLAYER_CARD1_LT + vecLT2RT / 40 * i;//LT
m_ptsPlayerOne[1] = PLAYER_CARD1_RT - vecLT2RT / 40 * i;//RT
m_ptsPlayerOne[2] = PLAYER_CARD1_LB + vecLT2RT / 40 * i;//LB
m_ptsPlayerOne[3] = PLAYER_CARD1_RB - vecLT2RT / 40 * i;//RB
Mat matAction = getPerspectiveTransform (m_ptsTableTop, m_ptsPlayerOne);
warpPerspective (m_matHoleCard, matShow, matAction, m_matTableTop.size (), 1, BORDER_TRANSPARENT);
string s = format ("C:\\users\\user\\Downloads\\%d.jpg", i);
imwrite (s, matShow (rect));
}
```