diff --git a/data/config/LostEcho.ini b/data/config/LostEcho.ini index 78accdb..f8ea1a7 100644 --- a/data/config/LostEcho.ini +++ b/data/config/LostEcho.ini @@ -15,7 +15,7 @@ Sound = game.dat # ../data/sound [Input] DefaultThreshold= 0.4 -SetList = MainInput +SetList = MainInput # SelectInput [MainInput] KEY_ESCAPE = Quit @@ -38,6 +38,75 @@ JOY_A_2 = Restart # Start JOY_A_3 = Restart # Start JOY_A_4 = Restart # Start +[SelectInput] +KEY_ESCAPE = Quit +KEY_SPACE = 1P # Start +KEY_ENTER = 1P # Start +KEY_1 = 1P # Start +KEY_2 = 2P # Start +KEY_3 = 3P # Start +KEY_4 = 4P # Start + +JOY_START_1 = 1P # Start +JOY_START_2 = 2P # Start +JOY_START_3 = 3P # Start +JOY_START_4 = 4P # Start + +JOY_A_1 = 1P # Start +JOY_A_2 = 2P # Start +JOY_A_3 = 3P # Start +JOY_A_4 = 4P # Start + +KEY_A = PreviousCount +KEY_LEFT = PreviousCount +KEY_D = NextCount +KEY_RIGHT = NextCount + +-JOY_LX_1 = PreviousCount +JOY_LEFT_1 = PreviousCount ++JOY_LX_1 = NextCount +JOY_RIGHT_1 = NextCount + +-JOY_LX_2 = PreviousCount +JOY_LEFT_2 = PreviousCount ++JOY_LX_2 = NextCount +JOY_RIGHT_2 = NextCount + +-JOY_LX_3 = PreviousCount +JOY_LEFT_3 = PreviousCount ++JOY_LX_3 = NextCount +JOY_RIGHT_3 = NextCount + +-JOY_LX_4 = PreviousCount +JOY_LEFT_4 = PreviousCount ++JOY_LX_4 = NextCount +JOY_RIGHT_4 = NextCount + +KEY_W = PreviousDeck +KEY_UP = PreviousDeck +KEY_S = NextDeck +KEY_DOWN = NextDeck + +-JOY_LY_1 = PreviousDeck +JOY_UP_1 = PreviousDeck ++JOY_LY_1 = NextDeck +JOY_DOWN_1 = NextDeck + +-JOY_LY_2 = PreviousDeck +JOY_UP_2 = PreviousDeck ++JOY_LY_2 = NextDeck +JOY_DOWN_2 = NextDeck + +-JOY_LY_3 = PreviousDeck +JOY_UP_3 = PreviousDeck ++JOY_LY_3 = NextDeck +JOY_DOWN_3 = NextDeck + +-JOY_LY_4 = PreviousDeck +JOY_UP_4 = PreviousDeck ++JOY_LY_4 = NextDeck +JOY_DOWN_4 = NextDeck + [MainViewport] Camera = MainCamera BackgroundColor = (25, 50, 60) @@ -61,7 +130,9 @@ Pivot = center truncate [Game] ViewportList = MainViewport WrapAround = false - +Counts = 16 # 28 # 36 +Count = 28 +Deck = GeoDeck @player.ini@ @table.ini@ diff --git a/data/config/select.ini b/data/config/select.ini index bba243b..31bf423 100644 --- a/data/config/select.ini +++ b/data/config/select.ini @@ -1,5 +1,10 @@ [Select] -ChildList = ModeTitle # PlayerSelection # InputText +ChildList = ModeTitle # PlayerSelection # InputText # SelectTable + +[SelectTable@Table] +Scale = 0.65 +SelectDeck = 1 +SelectCount = 1 [ModeTitle] ParentCamera = MainCamera @@ -30,8 +35,8 @@ Position = (0, .35) Scale = 5 Graphic = @ Text = @ -String = "[RIGHT, LEFT] CHOOSE NUMBER OF CARDS -[UP, DOWN] CHOOSE DECK" +String = "[RIGHT, LEFT] CHOOSE DECK SIZE +[UP, DOWN] CHOOSE DECK TYPE" [BlinkTrack] 1 = Object.SetAlpha ^ 0 diff --git a/data/config/table.ini b/data/config/table.ini index 6609997..bfa7f2b 100644 --- a/data/config/table.ini +++ b/data/config/table.ini @@ -1,15 +1,26 @@ -[Scene] -ChildList = Player1 # Player2 # Table +[1P] +ChildList = Player1 # Table + +[2P] +ChildList = Player1 # Player2 # Table + +[3P] +ChildList = Player1 # Player2 # Player3 # Table + +[4P] +ChildList = Player1 # Player2 # Player3 # Player4 # Table + +[Scene@2P] [Table] -Count = 20 -AttractDelay= 0.2 ~ 1.5 -Padding = (65, 65) -Deck = GeoDeck +AttractDelay = 0.2 ~ 1.5 +Padding = (65, 65) +Count = @Game +Deck = @Game [Slot] [EmptySlot] -Scale = 4 -Graphic = @ -Texture = empty.png +Scale = 4 +Graphic = @ +Texture = empty.png diff --git a/include/Table.h b/include/Table.h index f4e8374..5c918db 100644 --- a/include/Table.h +++ b/include/Table.h @@ -26,6 +26,7 @@ class Table : public Object orxU32 u32Height = 0; orxBOOL bGameOver = orxFALSE; orxBOOL bAttract = orxFALSE; + orxBOOL bSelect = orxFALSE; protected: diff --git a/src/Table.cpp b/src/Table.cpp index ef5d236..d6a2c8a 100644 --- a/src/Table.cpp +++ b/src/Table.cpp @@ -8,9 +8,8 @@ void orxFASTCALL Attract(const orxCLOCK_INFO *_pstClockInfo, void *_pContext) { - Table *poTable = (Table *)_pContext; - - Card *poCard = poTable->astSlots[orxMath_GetRandomU32(0, poTable->u32Count - 1)].poCard; + Table *poTable = (Table *)_pContext; + Card *poCard = poTable->astSlots[orxMath_GetRandomU32(0, poTable->u32Count - 1)].poCard; poCard->SetAnim("Show"); poTable->PushConfigSection(); @@ -22,12 +21,6 @@ void Table::OnCreate() { // Init variables orxConfig_SetBool("IsTable", orxTRUE); - u32Count = orxConfig_GetU32("Count"); - u32Width = ((orxU32)orxMath_Ceil(orxMath_Sqrt(orxU2F(u32Count)))) & ~1; - u32Height = u32Count / u32Width; - u32Count = u32Width * u32Height; - bGameOver = orxFALSE; - astSlots = (Slot *) orxMemory_Allocate(u32Count * sizeof(Slot), orxMEMORY_TYPE_MAIN); // Deal cards Deal(); @@ -35,71 +28,150 @@ void Table::OnCreate() void Table::OnDelete() { - // Clear variables + // Clear slots orxMemory_Free(astSlots); // Remove attract mode orxClock_RemoveGlobalTimer(Attract, -orxFLOAT_1, orxNULL); + + if(bSelect) + { + orxInput_SelectSet("MainInput"); + } } void Table::Update(const orxCLOCK_INFO &_rstInfo) { - if(!bGameOver && !bAttract) + if(!bAttract) { - // Check cards - bGameOver = orxTRUE; - for(orxU32 i = 0; i < u32Count; i++) + if(bSelect) { - if(astSlots[i].poCard != orxNULL) + orxBOOL bUpdate = orxFALSE; + orxU32 u32Decks, u32Counts, u32SelectDeck, u32SelectCount; + + u32Decks = orxConfig_GetListCount("Decks"); + u32Counts = orxConfig_GetListCount("Counts"); + + PushConfigSection(); + + if(orxInput_HasBeenActivated("PreviousCount")) { - bGameOver = orxFALSE; - break; + orxConfig_SetU32("SelectCount", (orxConfig_GetU32("SelectCount") - 1 + u32Counts) % u32Counts); + bUpdate = orxTRUE; + } + else if(orxInput_HasBeenActivated("NextCount")) + { + orxConfig_SetU32("SelectCount", (orxConfig_GetU32("SelectCount") + 1) % u32Counts); + bUpdate = orxTRUE; + } + else if(orxInput_HasBeenActivated("PreviousDeck")) + { + orxConfig_SetU32("SelectDeck", (orxConfig_GetU32("SelectDeck") - 1 + u32Decks) % u32Decks); + bUpdate = orxTRUE; + } + else if(orxInput_HasBeenActivated("NextDeck")) + { + orxConfig_SetU32("SelectDeck", (orxConfig_GetU32("SelectDeck") + 1) % u32Decks); + bUpdate = orxTRUE; + } + + u32SelectCount = orxConfig_GetU32("SelectCount"); + u32SelectDeck = orxConfig_GetU32("SelectDeck"); + + PopConfigSection(); + + if(bUpdate) + { + orxConfig_SetString("Deck", orxConfig_GetListString("Decks", u32SelectDeck)); + orxConfig_SetString("Count", orxConfig_GetListString("Counts", u32SelectCount)); + PushConfigSection(); + Deal(); + PopConfigSection(); + } + + if(orxInput_HasBeenActivated("1P")) + { + orxConfig_SetParent("Scene", "1P"); + } + else if(orxInput_HasBeenActivated("2P")) + { + orxConfig_SetParent("Scene", "2P"); + } + else if(orxInput_HasBeenActivated("3P")) + { + orxConfig_SetParent("Scene", "3P"); + } + else if(orxInput_HasBeenActivated("4P")) + { + orxConfig_SetParent("Scene", "4P"); } - } - // Game Over? - if(bGameOver) + if(orxInput_HasBeenActivated("Start")) + { + orxObject_Delete(orxOBJECT(orxObject_GetOwner(GetOrxObject()))); + ggj2021::GetInstance().CreateObject("Scene"); + } + } + else { - ggj2021 &roGame = ggj2021::GetInstance(); - Player *poWinner = orxNULL; - orxCHAR acName[128] = {}; - orxBOOL bTie = orxFALSE; - - for(Player *poPlayer = roGame.GetNextObject(); - poPlayer; - poPlayer = roGame.GetNextObject(poPlayer)) + if(!bGameOver) { - if((!poWinner) - || (poPlayer->u32Score > poWinner->u32Score) - || ((poPlayer->u32Score == poWinner->u32Score) - && (poPlayer->u32Picks < poWinner->u32Picks))) + // Check cards + bGameOver = orxTRUE; + for(orxU32 i = 0; i < u32Count; i++) { - poWinner = poPlayer; - bTie = orxFALSE; + if(astSlots[i].poCard != orxNULL) + { + bGameOver = orxFALSE; + break; + } } - else if((poPlayer->u32Score == poWinner->u32Score) - && (poPlayer->u32Picks == poWinner->u32Picks)) + + // Game Over? + if(bGameOver) { - bTie = orxTRUE; + ggj2021 &roGame = ggj2021::GetInstance(); + Player *poWinner = orxNULL; + orxCHAR acName[128] = {}; + orxBOOL bTie = orxFALSE; + + for(Player *poPlayer = roGame.GetNextObject(); + poPlayer; + poPlayer = roGame.GetNextObject(poPlayer)) + { + if((!poWinner) + || (poPlayer->u32Score > poWinner->u32Score) + || ((poPlayer->u32Score == poWinner->u32Score) + && (poPlayer->u32Picks < poWinner->u32Picks))) + { + poWinner = poPlayer; + bTie = orxFALSE; + } + else if((poPlayer->u32Score == poWinner->u32Score) + && (poPlayer->u32Picks == poWinner->u32Picks)) + { + bTie = orxTRUE; + } + poPlayer->astHands[0].poHand->Enable(orxFALSE); + poPlayer->astHands[1].poHand->Enable(orxFALSE); + } + + orxConfig_PushSection("GameOver"); + orxString_NPrint(acName, sizeof(acName) - 1, "%s", poWinner->GetModelName()); + orxConfig_SetString("Winner", bTie ? "Tie" : acName); + orxString_UpperCase(acName); + orxConfig_SetString("WINNER", bTie ? "TIE" : acName); + orxConfig_PopSection(); + roGame.CreateObject("GameOver"); + } + } + else + { + if(orxInput_HasBeenActivated("Restart")) + { + orxInput_SetValue("Reset", orxFLOAT_1); } - poPlayer->astHands[0].poHand->Enable(orxFALSE); - poPlayer->astHands[1].poHand->Enable(orxFALSE); } - - orxConfig_PushSection("GameOver"); - orxString_NPrint(acName, sizeof(acName) - 1, "%s", poWinner->GetModelName()); - orxConfig_SetString("Winner", bTie ? "Tie" : acName); - orxString_UpperCase(acName); - orxConfig_SetString("WINNER", bTie ? "TIE" : acName); - orxConfig_PopSection(); - roGame.CreateObject("GameOver"); - } - } - else - { - if(orxInput_HasBeenActivated("Restart")) - { - orxInput_SetValue("Reset", orxFLOAT_1); } } } @@ -110,6 +182,24 @@ void Table::Deal() Card *apoShuffleCards[1024] = {}; orxU32 u32CardIndex = 0; + // Delete all cards + if(astSlots) + { + for(orxU32 i = 0; i < u32Count; i++) + { + roGame.DeleteObject(astSlots[i].poCard); + } + orxMemory_Free(astSlots); + } + + // Inits variables + u32Count = orxConfig_GetU32("Count"); + u32Width = ((orxU32)orxMath_Ceil(orxMath_Sqrt(orxU2F(u32Count)))) & ~1; + u32Height = u32Count / u32Width; + u32Count = u32Width * u32Height; + bGameOver = orxFALSE; + astSlots = (Slot *) orxMemory_Allocate(u32Count * sizeof(Slot), orxMEMORY_TYPE_MAIN); + // Create cards orxConfig_PushSection(orxConfig_GetString("Deck")); for(orxU32 i = 0; i < u32Count; i += 2) @@ -190,6 +280,9 @@ void Table::Deal() { astSlots[i].poCard->SetAnim("Show"); } + orxInput_SelectSet("SelectInput"); + orxInput_SetValue("Start", orxFLOAT_0); + bSelect = orxTRUE; } } }