diff --git a/data/config/card.ini b/data/config/card.ini index f1e3367..7ed7cc7 100644 --- a/data/config/card.ini +++ b/data/config/card.ini @@ -15,19 +15,20 @@ Hide = 0 HideLoud = 0 ShuffleLeft = 0 ShuffleRight = 0 -Reveal = 0 -RevealLoud = 0 -Revealed = 0 +RevealLeft = 0 +RevealRight = 0 +RevealedLeft = 0 +RevealedRight = 0 Hidden-> = Hidden # .Show # -.ShowLoud -Show-> = !Visible # !Reveal # -!RevealLoud -ShowLoud-> = !Visible # !Reveal # -!RevealLoud -Visible-> = Visible # .Hide # -.HideLoud # -.!ShuffleLeft # -.!ShuffleRight # .!Reveal # -.!RevealLoud +Show-> = !Visible # -!RevealLeft # -!RevealRight +ShowLoud-> = !Visible # -!RevealLeft # -!RevealRight +Visible-> = Visible # .Hide # -.HideLoud # -.!ShuffleLeft # -.!ShuffleRight # -.!RevealLeft # -.!RevealRight Hide-> = !Hidden HideLoud-> = !Hidden ShuffleLeft-> = Hidden ShuffleRight-> = Hidden -Reveal-> = Revealed -RevealLoud-> = Revealed +RevealLeft-> = RevealedLeft +RevealRight-> = RevealedRight Prefix = @ [Hidden1] @@ -61,15 +62,18 @@ KeyDuration = % > Get Flip EndTime, * < 0.5 KeyEvent = Object.AddFX ^ ShuffleRight, > Object.GetParent ^, Object.AddFX < Drop KeyDuration = % > Get Flip EndTime, * < 0.5 -[Reveal1] -KeyEvent = Object.AddFX ^ Reveal, > Object.GetParent ^, Object.AddFX < Drop -KeyDuration = % > Get Drop EndTime, * < 0.5 +[RevealLeft1] +KeyEvent = Object.AddFX ^ RevealLeft, Object.Create DropSound +KeyDuration = % > Get MoveStash EndTime, * < 0.5 -[RevealLoud1] -KeyEvent = Object.AddFX ^ Reveal, > Object.GetParent ^, Object.AddFX < Drop, Object.Create DropSound -KeyDuration = % > Get Drop EndTime, * < 0.5 +[RevealRight1] +KeyEvent = Object.AddFX ^ RevealRight +KeyDuration = % > Get MoveStash EndTime, * < 0.5 -[Revealed1] +[RevealedLeft1] +TextureOrigin = (0, 0) + +[RevealedRight1] [Show] SlotList = Flip @@ -85,7 +89,13 @@ DoNotCache = true SlotList = MoveRight # Flip DoNotCache = true -[Reveal] +[RevealLeft] +SlotList = MoveLeft # Spin # Drop +DoNotCache = true + +[RevealRight] +SlotList = MoveRight # Spin # Drop +DoNotCache = true [Flip] Type = scale @@ -95,6 +105,14 @@ EndTime = 0.3 StartValue = 1 EndValue = (0, 1) +[Spin] +Type = rotation +Curve = smooth +StartTime = 0 +EndTime = 0.3 +StartValue = 0 +EndValue = 360 # -360 + [Pick] Type = scale Curve = smooth diff --git a/data/config/ggj2021.ini b/data/config/ggj2021.ini index 7fd0511..de3e854 100644 --- a/data/config/ggj2021.ini +++ b/data/config/ggj2021.ini @@ -51,5 +51,6 @@ ChildList = Player1 # Table @card.ini@ @font.ini@ @sound.ini@ +@tutorial.ini@ @dev.ini@ diff --git a/data/config/player.ini b/data/config/player.ini index c1b827b..6548901 100644 --- a/data/config/player.ini +++ b/data/config/player.ini @@ -1,5 +1,11 @@ [Player] +ParentCamera = MainCamera +UseParentSpace = position WrapAround = @Game +Graphic = @ +Texture = pixel +TextureSize = (0, 0) +Offset = (4, 2, -0.001) [Input] SetList += Player1Input # Player2Input # Player3Input # Player4Input @@ -43,6 +49,7 @@ JOY_RTRIGGER_1 = Pick # Shuffle Input = Player1Input Hand = Hand1 Color = (255, 90, 90) +Position = (-0.45, -0.25, 1) [Hand1@Hand] Color = @Player1 @@ -77,6 +84,7 @@ JOY_RTRIGGER_2 = Pick # Shuffle Input = Player2Input Hand = Hand2 Color = (25, 150, 255) +Position = (0.35, -0.25, 1) [Hand2@Hand] Color = @Player2 @@ -158,6 +166,9 @@ AnimationSet = HandAnimSet4 [Error] 0 = Object.Create ErrorSound +[ScorePoint] +0 = Object.Create ScoreSound + [Hand@Object] Scale = 4 Graphic = @ diff --git a/data/config/sound.ini b/data/config/sound.ini index add6dff..523c568 100644 --- a/data/config/sound.ini +++ b/data/config/sound.ini @@ -14,3 +14,6 @@ Sound = Move.ogg [ErrorSound@Sound] Sound = InvalidAction.ogg + +[ScoreSound@Sound] +Sound = ScorePoint.ogg diff --git a/include/Player.h b/include/Player.h index 5b42e4b..a3f5723 100644 --- a/include/Player.h +++ b/include/Player.h @@ -37,7 +37,10 @@ class Player : public Object private: const orxSTRING GetConfigVar(const orxSTRING _zVar) const; + orxU32 u32Score = 0; + orxU32 u32Picks = 0; orxBOOL bBusy = {}; + orxBOOL bScore = {}; }; #endif // __PLAYER_H__ diff --git a/src/Player.cpp b/src/Player.cpp index 5ce4232..e5e100e 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -34,7 +34,10 @@ void Player::OnCreate() ggj2021 &roGame = ggj2021::GetInstance(); // Init variables + u32Score = u32Picks = 0; orxConfig_SetBool("IsPlayer", orxTRUE); + orxConfig_SetU32("Score", u32Score); + orxConfig_SetU32("Picks", u32Picks); for(orxU32 i = 0; i < 2; i++) { astHands[i].poHand = roGame.CreateObject(orxConfig_GetString("Hand")); @@ -63,50 +66,93 @@ void Player::Update(const orxCLOCK_INFO &_rstInfo) // Busy? if(bBusy) { - // Drop/Shuffle? - if(orxInput_HasBeenActivated("Drop") || orxInput_HasBeenActivated("Shuffle")) - { - Card *poLeftCard, *poRightCard; + Card *poLeftCard, *poRightCard; - poLeftCard = poTable->astSlots[astHands[0].u32SlotIndex].poCard; - poRightCard = poTable->astSlots[astHands[1].u32SlotIndex].poCard; + poLeftCard = poTable->astSlots[astHands[0].u32SlotIndex].poCard; + poRightCard = poTable->astSlots[astHands[1].u32SlotIndex].poCard; - if((astHands[0].u32SlotIndex != orxU32_UNDEFINED) - && (astHands[1].u32SlotIndex != orxU32_UNDEFINED) - && (astHands[0].u32SlotIndex != astHands[1].u32SlotIndex) - && (poLeftCard->IsVisible()) - && (poRightCard->IsVisible())) + if((poLeftCard != poRightCard) + && (poLeftCard) + && (poRightCard) + && (poLeftCard->IsVisible()) + && (poRightCard->IsVisible())) + { + // Valid? + if(!orxString_Compare(poLeftCard->GetModelName(), poRightCard->GetModelName())) { - // Shuffle? - if(orxInput_HasBeenActivated("Shuffle")) + // Should score? + if(!bScore) { - orxVECTOR vPos; - orxObject_Detach(poLeftCard->GetOrxObject()); - orxObject_Attach(poLeftCard->GetOrxObject(), poTable->astSlots[astHands[1].u32SlotIndex].pstParent); - poTable->astSlots[astHands[1].u32SlotIndex].poCard = poLeftCard; - orxObject_Detach(poRightCard->GetOrxObject()); - orxObject_Attach(poRightCard->GetOrxObject(), poTable->astSlots[astHands[0].u32SlotIndex].pstParent); - poTable->astSlots[astHands[0].u32SlotIndex].poCard = poRightCard; + // Score + AddTrack("ScorePoint"); + orxConfig_SetU32("Score", ++u32Score); + bScore = orxTRUE; + } + // Drop/Shuffle? + if(orxInput_HasBeenActivated("Drop") || orxInput_HasBeenActivated("Shuffle")) + { + orxVECTOR vPos, vOffset; + orxObject_Attach(poLeftCard->GetOrxObject(), GetOrxObject()); + poTable->astSlots[astHands[0].u32SlotIndex].poCard = orxNULL; + orxObject_AddFX(poTable->astSlots[astHands[0].u32SlotIndex].pstParent, "Drop"); + orxObject_Attach(poRightCard->GetOrxObject(), GetOrxObject()); + poTable->astSlots[astHands[1].u32SlotIndex].poCard = orxNULL; + orxObject_AddFX(poTable->astSlots[astHands[1].u32SlotIndex].pstParent, "Drop"); + + orxVector_Mulf(&vOffset, orxConfig_GetVector("Offset", &vOffset), orxU2F(2 * u32Score)); orxConfig_PushSection("MoveLeft"); poLeftCard->GetPosition(vPos); - orxConfig_SetVector("EndValue", orxVector_Neg(&vPos, &vPos)); + orxConfig_SetVector("EndValue", orxVector_Add(&vPos, orxVector_Neg(&vPos, &vPos), &vOffset)); orxConfig_PopSection(); - poLeftCard->SetAnim("ShuffleLeft"); + poLeftCard->SetAnim("RevealLeft"); + orxVector_Mulf(&vOffset, orxConfig_GetVector("Offset", &vOffset), orxU2F(2 * u32Score + 1)); orxConfig_PushSection("MoveRight"); poRightCard->GetPosition(vPos); - orxConfig_SetVector("EndValue", orxVector_Neg(&vPos, &vPos)); + orxConfig_SetVector("EndValue", orxVector_Add(&vPos, orxVector_Neg(&vPos, &vPos), &vOffset)); orxConfig_PopSection(); - poRightCard->SetAnim("ShuffleRight"); + poRightCard->SetAnim("RevealRight"); + bBusy = orxFALSE; } - else + } + else + { + // Drop/Shuffle? + if(orxInput_HasBeenActivated("Drop") || orxInput_HasBeenActivated("Shuffle")) { - poLeftCard->SetAnim("HideLoud"); - poRightCard->SetAnim("Hide"); + // Shuffle? + if(orxInput_HasBeenActivated("Shuffle")) + { + orxVECTOR vPos; + orxObject_Attach(poLeftCard->GetOrxObject(), poTable->astSlots[astHands[1].u32SlotIndex].pstParent); + poTable->astSlots[astHands[1].u32SlotIndex].poCard = poLeftCard; + orxObject_Attach(poRightCard->GetOrxObject(), poTable->astSlots[astHands[0].u32SlotIndex].pstParent); + poTable->astSlots[astHands[0].u32SlotIndex].poCard = poRightCard; + + orxConfig_PushSection("MoveLeft"); + poLeftCard->GetPosition(vPos); + orxConfig_SetVector("EndValue", orxVector_Neg(&vPos, &vPos)); + orxConfig_PopSection(); + poLeftCard->SetAnim("ShuffleLeft"); + orxConfig_PushSection("MoveRight"); + poRightCard->GetPosition(vPos); + orxConfig_SetVector("EndValue", orxVector_Neg(&vPos, &vPos)); + orxConfig_PopSection(); + poRightCard->SetAnim("ShuffleRight"); + } + else + { + poLeftCard->SetAnim("HideLoud"); + poRightCard->SetAnim("Hide"); + } + bBusy = orxFALSE; } - bBusy = orxFALSE; } - else + } + else + { + // Drop/Shuffle? + if(orxInput_HasBeenActivated("Drop") || orxInput_HasBeenActivated("Shuffle")) { AddTrack("Error"); } @@ -178,15 +224,22 @@ void Player::Update(const orxCLOCK_INFO &_rstInfo) // Pick? if(orxInput_HasBeenActivated("Pick")) { - if((astHands[0].u32SlotIndex != orxU32_UNDEFINED) - && (astHands[1].u32SlotIndex != orxU32_UNDEFINED) - && (astHands[0].u32SlotIndex != astHands[1].u32SlotIndex) - && (poTable->astSlots[astHands[0].u32SlotIndex].poCard->IsHidden()) - && (poTable->astSlots[astHands[1].u32SlotIndex].poCard->IsHidden())) + Card *poLeftCard, *poRightCard; + + poLeftCard = poTable->astSlots[astHands[0].u32SlotIndex].poCard; + poRightCard = poTable->astSlots[astHands[1].u32SlotIndex].poCard; + + if((poLeftCard != poRightCard) + && (poLeftCard) + && (poRightCard) + && (poLeftCard->IsHidden()) + && (poRightCard->IsHidden())) { - poTable->astSlots[astHands[0].u32SlotIndex].poCard->SetAnim("ShowLoud"); - poTable->astSlots[astHands[1].u32SlotIndex].poCard->SetAnim("Show"); - bBusy = orxTRUE; + poLeftCard->SetAnim("ShowLoud"); + poRightCard->SetAnim("Show"); + orxConfig_SetU32("Picks", ++u32Picks); + bBusy = orxTRUE; + bScore = orxFALSE; } else { diff --git a/src/Table.cpp b/src/Table.cpp index db442b7..1c6d683 100644 --- a/src/Table.cpp +++ b/src/Table.cpp @@ -11,7 +11,7 @@ void Table::OnCreate() // Init variables orxConfig_SetBool("IsTable", orxTRUE); u32CardCount = orxConfig_GetU32("CardCount"); - u32Width = ((orxU32)orxMath_Sqrt(orxU2F(u32CardCount))) & ~1; + u32Width = ((orxU32)orxMath_Ceil(orxMath_Sqrt(orxU2F(u32CardCount)))) & ~1; u32Height = u32CardCount / u32Width; u32CardCount = u32Width * u32Height; astSlots = (Slot *) orxMemory_Allocate(u32CardCount * sizeof(Slot), orxMEMORY_TYPE_MAIN);