From 6c6cb72b115629805a3b5f09e8f9fcbe63c13a03 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sun, 2 Apr 2023 01:37:42 -0500 Subject: [PATCH] Simple Win Screen! --- Solitaire/assets/club8x8.png | Bin 0 -> 4862 bytes Solitaire/assets/diamond8x8.png | Bin 0 -> 5012 bytes Solitaire/assets/heart8x8.png | Bin 0 -> 4970 bytes Solitaire/assets/spade8x8.png | Bin 0 -> 4865 bytes Solitaire/main.cpp | 146 +++++++++++++++++++++++++++----- 5 files changed, 126 insertions(+), 20 deletions(-) create mode 100644 Solitaire/assets/club8x8.png create mode 100644 Solitaire/assets/diamond8x8.png create mode 100644 Solitaire/assets/heart8x8.png create mode 100644 Solitaire/assets/spade8x8.png diff --git a/Solitaire/assets/club8x8.png b/Solitaire/assets/club8x8.png new file mode 100644 index 0000000000000000000000000000000000000000..017673b2accf56f51a4c11b91c7314fa8aa83b8b GIT binary patch literal 4862 zcmeHLc~leU77rCMQV?)KRG!2Df`!SRNFq@%i4Y~o5)>*flbJ~vAq&Ys0`3Y5N!HE4EgxD;9nFz6qdsUe9^Qb6)>5Ig`xX@7~{c@9(?! z=KGQz5gy`bKhmB;p*YGzrBUFUN?ueu@Y�w}wLLM@v`65>c?3W-#j2coIe<(hL|4 zv*2n9#nSemaMss%#yYIL9w#eU>Xp%8WNqAYIk=$MBj;-2rZQq|+R-EI6w2pugS#?j z`xGsC<95R--kqOWa<}@nd-9I2?PrDs&S@=AUyVO+P1$!gB+cULMnCM^s=WbC8q-|# zV$tO;;{K$SFEYMRcU48)FYxfV(=0gp=JJ``pnFf;UoDNTF=uu7avfL(Y#5uohdF^%eF(cTI$9cKbQs+jtyv|nU z;LqLvk)>=2_;# z!o!l2Pv@-7i$xYU&25qEC7sIy7r(64=<_<9jQP!thgz=HvupAW;=g^fGbjFb?d}DB ziFUP!I$6BotpDAmds4#GehH%!lfKTm_H;qc3249n zwti7Js-})PIc0@nHIb|go5f$BQ5>644IQ8DnI~=tkHD6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9$?~BEb}xD;ZUXbCSw-D76^$i#KXpGQ;nrfJ(X3@5f|2eJOmHfOTKxoA-9tzM ztkYnifAl15uN?oAWKi?@ssJ_VKS#)hcsvda30W`#sSv)39S{K0P00Na-K19&X4r@Y zYXFacE0Ca8u4ukJOEvC8eRBdvt^=S9V)4KEKeMy*dU5m&4~Rw(vRFc**OGg3iglxip)@m2B+$r>;>=}(h65#Exinbm zb{?5Wb9uc=6);bl-{3u<@O563dS1gfL;ADU-3%z2(VpT(=_hu0_57)A2(Y2ZW#Q7Y I$@7-~2iCG5SO5S3 literal 0 HcmV?d00001 diff --git a/Solitaire/assets/diamond8x8.png b/Solitaire/assets/diamond8x8.png new file mode 100644 index 0000000000000000000000000000000000000000..677eaa23e545d0f7710b1eefdb6d97ec0c239335 GIT binary patch literal 5012 zcmeHKc~leU77tWoKtZ&!h`bU57F;HoOcJt?AevB!7>p1Q1zRUG6Br;1$v^_MxKvzP z1+-f5JquPr%d_rS6%}gTMX+_D6s%IURbQ^oUpESFd6JoQIq{7Or(;MgD!(hHK4uVRKV-aXqb%Wgxq=9Xd`x1zJA;%L)1#;NBdozmTx1f8GM8`GA}SbKQ;m4EzpApP@=-OEys z?ftAh{wG#$`>AX1PTUyc>z0`5x1!>kChu7@6Pgn5)OuV$>v}i5z?8cGVFdA``?9xl z)uo)Zsx9Xu<3Eno&d1~wWWXF;wK`LQenTnOWAN}sLs(s;yGg_at z#-43%PIW0;F>Q$Z$qn;ayY3Kfxp1vs^CD+cYYrldc z-#A#2km6a&S?tL;>ds8XJpvYnE)O;YpO4hKP&0XB{5rg(lWs5cpt{8fS3x^UPX~Ydhkcr#_T}Ya6X3Jy$jL&Q4 zH0>3VZ99*oWYx@W+;->CrZu?@OBHv?eTsY4n=aPnUR9PTX6~yfkj_r2ExbK>-b&w0 zWS#$#+qg&D8WYzM5Q18mCyohNGv;}$_;lxxwC2`=(PurH?<>CA&T=h9OD{NJCiCCT zBW0DBp`Tc@4=ol?3(NcHDiZyEo$tC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Yh$I6bW>`s3m1x#LuV^S7K;dFB4CAOC0O)}?uwD%5F~k5NQn3iri}Ye#B5*?C znCvaH)rf+0l14O*;8{#*&IOuq*%Yl>!9lq2bBQ(!r3}CT^Z;qX&34=KB^_xb5-61B zlOHC5g?y1T43;1gvAEZ3Ct?y|wSiisQTZ@e&`SxO7#Ro$P>a%)3ILq2AR3v{N}!b4 zsxzCj6dW3YO0I{W}GzS{V#30 zec1Beq{ompuz#LY)Z0@DM0W2}?_(C}Y$i6_*%mSs>kYw%<`THmPk`0Cgr%dVGy=?z zzJh%wC;y}v2qB*k!LR|s^(kzKp6xJp?=DQFo)L{ERUWT&!Uy{{)-Q}Q(?e}0d~DIFuK4b zl^6(e#0H9xO@>2Z1qU#l1FU7!1DZi?&S9HA;123igs=EGfbh$r& znIcT!1Y`%VNIwRg&-Y@iI90c5T*liChQ$*j%T!6K1Kz_%J#l4lZ;Y&eur8(sm@?E+ LajNZ8=PmjV^j%uk literal 0 HcmV?d00001 diff --git a/Solitaire/assets/heart8x8.png b/Solitaire/assets/heart8x8.png new file mode 100644 index 0000000000000000000000000000000000000000..9d2467b294df52eb41b3dbdcee21dc2d6ec6c4bd GIT binary patch literal 4970 zcmeHKX;c$g77hv#5d;Jjk(M%|qL`$zl0>2`L5Lbe7DZdTtyEP=30X)A5>QlVaibgD z6&rB_To`dfT0uoxQNeArU3wH;QP9B!7oxb$OF+akea;-unf_MnLu85;hj1gI zpiqq0A5WgN;+~KF`$pH<*4|cqPF2m^*-D-LE^TIW0jHk#uwY)%tO+*Apn^sD#}ePp z`I*?+F{5w%(lKV!t||wqNj)Ov*8wo_rN2zUOxCci5<31Jjz}E z{fi-+<1XeJ9Yh*=Z zL0-hGhbuNd8lInhzUQI4&(g5sDGiRPt3t~sW>##gFe%d19u+==2K6IUkLqeYtJDLg z<`wr@-_{UuU}2TA|G7CWZoDgVs--vJ^CxZ}joLIeQ}j4$^3M70#<)zZBpV;$;Ek8; zcl}*?dFqhyF2T~vQ-cFv{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oYcb>NPqI(A`GNtGLb}sCYjBXO2jnt{vu3+5}3&Hiu1T!m;0CAsqYDHq4qd?! z-~t%MU_RUxVxo=!S&1ZcwaN^I0VtFY10X(1=dsy-bS_UIrwfH_KHbj`=Hdu~bA?>k zVhx6h#%gpb1cZ}NA#pfUtB$iQmIU&}3Yv2f1iQWx)&%+p=N~j0m^`s71_~3IHtgz#CDp z4o66hE?T2W5Yx;iKxWO(Wf>?a3?UH-LgD}vW^+U^R|K=8VU`Hyi-7YmPXu?7*ITF8woQ0vfZ!S*E#TeDcTqPqw5=8U&X*z34hD3Z*+YX179WlExZ12 zblH8rOyO#90y2QBl5dSNyomJ1io6L@YYisHdRldFb10+D`Vl9WH8x- zl*&SSG+K9~Qax|hDtCgZ{$xlj8LUy6&*T)#K@rCw13@Yw^FeV+dhdQfh%c1{M!Wxk z&V;C?i>i`Q^gmk?9VwGke3PZe!PN_|rT7he`z|Np>&y4!i|}4~61n<8plB S($UQTfg%kFmy`s}%=iy9FIEHq literal 0 HcmV?d00001 diff --git a/Solitaire/assets/spade8x8.png b/Solitaire/assets/spade8x8.png new file mode 100644 index 0000000000000000000000000000000000000000..0ff60acd6056b6b5060f9413a33b956cc8091d41 GIT binary patch literal 4865 zcmeHLX;2f{77nAth@gOipeUJ$yPb_rNLs=oAn+v05>ynIPPzjPWFcut0FiM45fN7q z6-7s2+{Wb%=qM_VvMD$?%DAsQ9k6&h;6q^4!go8MV$D>&vg*x0lj@}V-tT<(-0z-q za&OiK&-S;n7-d1D(X0Xkd_%!EgSr@W@L4(R+&UU<05e%OpA1C}Os!6%B;s%;nWV*; zxRFrOXvRCww=LZKbb@8Z!wA2;Z(LSa>bUs_Z+qtzI%nVCw*3e>A*uEvFM&2B!uIv* zMH36sdK?}Pi*ypC7yWkXiBo*>W{Y`2?u&08PtGD<-Ap+8i+_^Q-huVgq?@Y8kmuJm z1)Zt4Uz4q#8J(-AC|{olZq0Lcep(}}?YVt5$E)R~)0^c>N83KIDQ-RYJX06{=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/main.cpp @@ -13,7 +13,8 @@ Solitaire*game; class Solitaire : public olc::PixelGameEngine { std::default_random_engine generator; - Renderable club_spr, spade_spr, diamond_spr, heart_spr; + Renderable club_spr, spade_spr, diamond_spr, heart_spr, + club_spr8, spade_spr8, diamond_spr8, heart_spr8; enum Suit { CLUB, DIAMOND, @@ -50,20 +51,48 @@ class Solitaire : public olc::PixelGameEngine }break; } } + Sprite* GetSpriteSprite(Suit s) { + switch (s) { + case CLUB: { + return club_spr8.Sprite(); + }break; + case DIAMOND: { + return diamond_spr8.Sprite(); + }break; + case HEART: { + return heart_spr8.Sprite(); + }break; + case SPADE: { + return spade_spr8.Sprite(); + }break; + } + } void RenderCard(vf2d pos, Suit s, int number) { if (number == -1) { return; } if (s == FACEDOWN) { - FillRectDecal(pos, CARD_SIZE, DARK_CYAN); - DrawRectDecal(pos, CARD_SIZE, BLACK); + if (!game->gameFinished) { + FillRectDecal(pos, CARD_SIZE, DARK_CYAN); + DrawRectDecal(pos, CARD_SIZE, BLACK); + } } else { - FillRectDecal(pos, CARD_SIZE, WHITE); - DrawStringDecal(pos + vf2d{ 2,2 }, number == 1 ? "A" : number == 13 ? "K" : number == 12 ? "Q" : number == 11 ? "J" : std::to_string(number), s == CLUB || s == SPADE ? BLACK : DARK_RED, number == 10 ? vf2d{ 0.6,1 } : vf2d{ 1,1 }); - DrawDecal(pos + vf2d{ 2,12 }, GetSprite(s), { 0.25,0.25 }); - DrawRotatedStringDecal(pos + CARD_SIZE - vf2d{ 2,2 }, number == 1 ? "A" : number == 13 ? "K" : number == 12 ? "Q" : number == 11 ? "J" : std::to_string(number), PI, { 0,0 }, s == CLUB || s == SPADE ? BLACK : DARK_RED, number == 10 ? vf2d{ 0.6,1 } : vf2d{ 1,1 }); - DrawRotatedDecal(pos + CARD_SIZE - vf2d{ 2,12 }, GetSprite(s), PI, { 0,0 }, { 0.25, 0.25 }); - DrawRectDecal(pos, CARD_SIZE, BLACK); + if (game->gameFinished) { + FillRect(pos, CARD_SIZE, WHITE); + DrawString(pos + vf2d{ 2,2 }, number == 1 ? "A" : number == 13 ? "K" : number == 12 ? "Q" : number == 11 ? "J" : std::to_string(number), s == CLUB || s == SPADE ? BLACK : DARK_RED); + DrawSprite(pos + vf2d{ 2,12 }, GetSpriteSprite(s)); + //DrawRotatedString(pos + CARD_SIZE - vf2d{ 2,2 }, number == 1 ? "A" : number == 13 ? "K" : number == 12 ? "Q" : number == 11 ? "J" : std::to_string(number), PI, { 0,0 }, s == CLUB || s == SPADE ? BLACK : DARK_RED, number == 10 ? vf2d{ 0.6,1 } : vf2d{ 1,1 }); + //DrawRotatedSprite(pos + CARD_SIZE - vf2d{ 2,12 }, GetSprite(s), PI, { 0,0 }); + DrawRect(pos, CARD_SIZE, BLACK); + } + else { + FillRectDecal(pos, CARD_SIZE, WHITE); + DrawStringDecal(pos + vf2d{ 2,2 }, number == 1 ? "A" : number == 13 ? "K" : number == 12 ? "Q" : number == 11 ? "J" : std::to_string(number), s == CLUB || s == SPADE ? BLACK : DARK_RED, number == 10 ? vf2d{ 0.6,1 } : vf2d{ 1,1 }); + DrawDecal(pos + vf2d{ 2,12 }, GetSprite(s), { 0.25,0.25 }); + DrawRotatedStringDecal(pos + CARD_SIZE - vf2d{ 2,2 }, number == 1 ? "A" : number == 13 ? "K" : number == 12 ? "Q" : number == 11 ? "J" : std::to_string(number), PI, { 0,0 }, s == CLUB || s == SPADE ? BLACK : DARK_RED, number == 10 ? vf2d{ 0.6,1 } : vf2d{ 1,1 }); + DrawRotatedDecal(pos + CARD_SIZE - vf2d{ 2,12 }, GetSprite(s), PI, { 0,0 }, { 0.25, 0.25 }); + DrawRectDecal(pos, CARD_SIZE, BLACK); + } } } @@ -73,6 +102,10 @@ class Solitaire : public olc::PixelGameEngine std::vector faceDownCards; std::vector faceUpCards; int cardSpacing = 16; + int currentCard = 13; + vf2d cardPos = { -1000,-1000 }; + vf2d vel; + vf2d lastCardDisplay = { -1000,-1000 }; void RenderCards() { game->DrawRectDecal(pos, CARD_SIZE, BLACK); switch (type) { @@ -333,7 +366,16 @@ class Solitaire : public olc::PixelGameEngine } ResetDraggedCard(); draggedCardSuccess: - int a; + bool gameWon = true; + for (int i = 0; i < Home.size(); i++) { + if (Home[i].faceUpCards[Home[i].faceUpCards.size() - 1].number != 13) { + gameWon = false; + break; + } + } + if (gameWon) { + gameFinished = true; + } } } @@ -354,6 +396,9 @@ class Solitaire : public olc::PixelGameEngine std::vector draggedCard = {}; std::vectorpreviousCardInteraction = {}; CardSlot*previousCardSlotInteraction=NULL; + bool gameFinished = false; + bool spritesRendered = false; + const float gravity = 16.f; Card DrawCard() { std::uniform_int_distribution distribution(0, cardDeck.size()-1); @@ -371,17 +416,26 @@ class Solitaire : public olc::PixelGameEngine cardDeck.push_back({ (Suit)i,j }); } } + SetPixelMode(Pixel::MASK); Clear(VERY_DARK_GREEN); club_spr.Load("assets/club.png"); diamond_spr.Load("assets/diamond.png"); heart_spr.Load("assets/heart.png"); spade_spr.Load("assets/spade.png"); + club_spr8.Load("assets/club8x8.png"); + diamond_spr8.Load("assets/diamond8x8.png"); + heart_spr8.Load("assets/heart8x8.png"); + spade_spr8.Load("assets/spade8x8.png"); for (int i = 0; i < Field.size(); i++) { for (int j = 0; j < i; j++) { Field[i].faceDownCards.push_back(DrawCard()); } Field[i].faceUpCards.push_back(DrawCard()); } + Home[0].faceUpCards.push_back({SPADE, 1}); + Home[1].faceUpCards.push_back({ HEART, 1 }); + Home[2].faceUpCards.push_back({ DIAMOND, 1 }); + Home[3].faceUpCards.push_back({ CLUB, 1 }); for (int i = 0; i < Home.size();i++) { CardSlot&c = Home[i]; c.pos = vi2d{ 136 + i * 40,8 }; @@ -403,18 +457,70 @@ class Solitaire : public olc::PixelGameEngine // called once per frame //RenderCard({ 48,48 }, HEART, 7); - UpdateCardSlots(); + if (!gameFinished) { + UpdateCardSlots(); - PlayDeck.RenderCards(); - ActivePlayDeck.RenderCards(); - for (CardSlot& c : Home) { - c.RenderCards(); - } - for (CardSlot& c : Field) { - c.RenderCards(); + PlayDeck.RenderCards(); + ActivePlayDeck.RenderCards(); + for (CardSlot& c : Home) { + c.RenderCards(); + } + for (CardSlot& c : Field) { + c.RenderCards(); + } + for (int i = 0; i < draggedCard.size(); i++) { + RenderCard(GetMousePos() - CARD_SIZE / 2 + vi2d{ 0,i * 16 }, draggedCard[i].s, draggedCard[i].number); + } } - for (int i = 0; i < draggedCard.size(); i++) { - RenderCard(GetMousePos() - CARD_SIZE / 2 + vi2d{0,i*16}, draggedCard[i].s, draggedCard[i].number); + else { + if (!spritesRendered) { + spritesRendered = true; + + PlayDeck.RenderCards(); + ActivePlayDeck.RenderCards(); + for (CardSlot& c : Home) { + c.RenderCards(); + } + for (CardSlot& c : Field) { + c.RenderCards(); + } + for (int i = 0; i < draggedCard.size(); i++) { + RenderCard(GetMousePos() - CARD_SIZE / 2 + vi2d{ 0,i * 16 }, draggedCard[i].s, draggedCard[i].number); + } + } + else { + std::uniform_real_distribution randHorizontalVelocity(-30, 30); + std::uniform_real_distribution randVerticalVelocity(-30, -1); + for (int i = 0; i < Home.size(); i++) { + if (Home[i].cardPos.x<-CARD_SIZE.x || Home[i].cardPos.x>ScreenWidth()) { + if (Home[i].currentCard > 0) { + Home[i].currentCard--; + Home[i].cardPos = Home[i].pos; + Home[i].vel = { randHorizontalVelocity(generator), randVerticalVelocity(generator) }; + if (std::abs(Home[i].vel.x) < 8) { + if (Home[i].vel.x < 0) { + Home[i].vel.x -= 8; + } + else { + Home[i].vel.x += 8; + } + } + } + } + else { + Home[i].cardPos += Home[i].vel * fElapsedTime; + Home[i].vel.y += gravity * fElapsedTime; + if (Home[i].cardPos.y + CARD_SIZE.y > ScreenHeight()) { + Home[i].cardPos.y = ScreenHeight() - CARD_SIZE.y; + Home[i].vel.y *= -0.95; + } + if (std::pow(Home[i].cardPos.x - Home[i].lastCardDisplay.x, 2) + std::pow(Home[i].cardPos.y - Home[i].lastCardDisplay.y, 2) > 9) { + Home[i].lastCardDisplay = Home[i].cardPos; + RenderCard(Home[i].cardPos, Home[i].faceUpCards[0].s, Home[i].currentCard); + } + } + } + } } return true; }