Skip to content

Commit

Permalink
Use the player's marker for 2p local system
Browse files Browse the repository at this point in the history
Fix LEDs for CPU moves, result screen
  • Loading branch information
AEFeinstein committed Dec 4, 2024
1 parent 5cc8789 commit 0cdfa3b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
14 changes: 8 additions & 6 deletions main/modes/games/ultimateTTT/ultimateTTT.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ const char tttMarkerKey[] = "ttt_marker";
const char tttTutorialKey[] = "ttt_tutor";
const char tttUnlockKey[] = "ttt_unlock";

static const led_t utttLedMenuColor = {
.r = 0xFF,
.g = 0x99,
.b = 0xCC,
};

/**
* Marker names to load WSGs
*/
Expand Down Expand Up @@ -122,18 +128,13 @@ static void tttEnterMode(void)
// Initialize a menu renderer
ttt->menuRenderer = initMenuManiaRenderer(&ttt->font_righteous, NULL, &ttt->font_rodin);
// Color the menu like Poe
led_t menuColor = {
.r = 0xFF,
.g = 0x00,
.b = 0x00,
};
static const paletteColor_t shadowColors[] = {c500, c511, c522, c533, c544, c555, c544, c533, c522, c511};
recolorMenuManiaRenderer(ttt->menuRenderer, //
c500, c555, c111, // titleBgColor, titleTextColor, textOutlineColor
c333, // bgColor
c534, c544, // outerRingColor, innerRingColor
c212, c555, // rowColor, rowTextColor
shadowColors, ARRAY_SIZE(shadowColors), menuColor);
shadowColors, ARRAY_SIZE(shadowColors), utttLedMenuColor);

// Initialize the main menu
ttt->menu = initMenu(tttName, tttMenuCb);
Expand Down Expand Up @@ -488,6 +489,7 @@ void tttShowUi(tttUi_t ui)

// Assume menu LEDs should be on
setManiaLedsOn(ttt->menuRenderer, true);
ttt->menuRenderer->baseLedColor = utttLedMenuColor;

// Initialize the new UI
switch (ttt->ui)
Expand Down
12 changes: 12 additions & 0 deletions main/modes/games/ultimateTTT/ultimateTTTgame.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ void tttBeginGame(ultimateTTT_t* ttt)
ttt->game.cpu.state = TCPU_THINKING;
}

// Set own marker type
ttt->game.p2MarkerIdx = ttt->activeMarkerIdx;

// Randomize markers to be not match
ttt->game.p1MarkerIdx = esp_random() % ttt->numUnlockedMarkers;
// While the markers match
Expand Down Expand Up @@ -882,8 +885,17 @@ static playOrder_t tttGetPlayOrder(ultimateTTT_t* ttt)
*/
void tttDrawGame(ultimateTTT_t* ttt)
{
// LED setting for wireless & pass and play
bool isP1 = (GOING_FIRST == tttGetPlayOrder(ttt));

// Override for CPU matches during the CPU's turn
if ((true == ttt->game.singleSystem) && //
(false == ttt->game.passAndPlay) && //
(ttt->game.state == TGS_WAITING))
{
isP1 = !isP1;
}

// Light LEDs for p1/p2
led_t leds[CONFIG_NUM_LEDS] = {0};
for (int32_t lIdx = 0; lIdx < CONFIG_NUM_LEDS; lIdx++)
Expand Down
10 changes: 8 additions & 2 deletions main/modes/games/ultimateTTT/ultimateTTTresult.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,17 @@ void tttDrawResult(ultimateTTT_t* ttt, int64_t elapsedUs)
{
if (GOING_FIRST == ttt->game.singlePlayerPlayOrder)
{
resultStr = redStr;
resultStr = redStr;
ttt->menuRenderer->baseLedColor.r = 0xFF;
ttt->menuRenderer->baseLedColor.g = 0x00;
ttt->menuRenderer->baseLedColor.b = 0x00;
}
else
{
resultStr = blueStr;
resultStr = blueStr;
ttt->menuRenderer->baseLedColor.r = 0x00;
ttt->menuRenderer->baseLedColor.g = 0x00;
ttt->menuRenderer->baseLedColor.b = 0xFF;
}
}
else
Expand Down

0 comments on commit 0cdfa3b

Please sign in to comment.