diff --git a/Solitaire/main.cpp b/Solitaire/main.cpp index d3b69b7..5e7985c 100644 --- a/Solitaire/main.cpp +++ b/Solitaire/main.cpp @@ -3,6 +3,13 @@ using namespace olc; + +const vi2d CARD_SIZE = vi2d{32,48}; + +PixelGameEngine*game; + +class Example : public olc::PixelGameEngine +{ const float PI = 3.14159f; enum Suit { @@ -12,14 +19,34 @@ enum Suit { DIAMOND }; -const vi2d CARD_SIZE = vi2d{32,48}; +enum SlotType { + PLAYDECK, + ACTIVE_PLAYDECK, + HOME, + FIELD +}; + +struct Card { + Suit s; + int number; +}; + +struct CardSlot { + vf2d pos; + SlotType type; + std::vector faceDownCards; + std::vector faceUpCards; + void RenderCards() { + game->DrawRectDecal(pos, CARD_SIZE, WHITE); + } +}; -class Example : public olc::PixelGameEngine -{ public: + Example() { sAppName = "Solitaire"; + game = this; } void RenderCard(vf2d pos, Suit s, int number) { @@ -29,16 +56,38 @@ public: } public: + CardSlot PlayDeck{ {16,8},PLAYDECK }; + CardSlot ActivePlayDeck{ {56,8},ACTIVE_PLAYDECK }; + std::array Home; + std::array Field; bool OnUserCreate() override { - + + for (int i = 0; i < Home.size();i++) { + CardSlot&c = Home[i]; + c.pos = vi2d{ 136 + i * 40,8 }; + c.type = SlotType::HOME; + } + for (int i = 0; i < Field.size(); i++) { + CardSlot&c = Field[i]; + c.pos = vi2d{ 16 + i * 40,64 }; + c.type = SlotType::FIELD; + } return true; } bool OnUserUpdate(float fElapsedTime) override { // called once per frame - RenderCard({ 48,48 }, HEART, 7); + //RenderCard({ 48,48 }, HEART, 7); + PlayDeck.RenderCards(); + ActivePlayDeck.RenderCards(); + for (CardSlot& c : Home) { + c.RenderCards(); + } + for (CardSlot& c : Field) { + c.RenderCards(); + } return true; } };