Skip to content

Commit

Permalink
- Added pair validation
Browse files Browse the repository at this point in the history
- Added score/picks tracking
- Added cards stacking under players
  • Loading branch information
iarwain committed Jan 31, 2021
1 parent c373269 commit 2245557
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 54 deletions.
50 changes: 34 additions & 16 deletions data/config/card.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions data/config/ggj2021.ini
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ ChildList = Player1 # Table
@card.ini@
@font.ini@
@sound.ini@
@tutorial.ini@

@dev.ini@
11 changes: 11 additions & 0 deletions data/config/player.ini
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -158,6 +166,9 @@ AnimationSet = HandAnimSet4
[Error]
0 = Object.Create ErrorSound

[ScorePoint]
0 = Object.Create ScoreSound

[Hand@Object]
Scale = 4
Graphic = @
Expand Down
3 changes: 3 additions & 0 deletions data/config/sound.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ Sound = Move.ogg

[ErrorSound@Sound]
Sound = InvalidAction.ogg

[ScoreSound@Sound]
Sound = ScorePoint.ogg
3 changes: 3 additions & 0 deletions include/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__
127 changes: 90 additions & 37 deletions src/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object>(orxConfig_GetString("Hand"));
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2245557

Please sign in to comment.