Affine background now turns red on game over + other WIP changes for game over screen

This commit is contained in:
MeirGavish
2025-08-19 16:31:32 +03:00
parent 7bbaec261b
commit 6d6bb39c97
3 changed files with 22 additions and 20 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

+7 -12
View File
@@ -52,13 +52,8 @@
// By default TTE characters occupy a single tile // By default TTE characters occupy a single tile
#define TTE_CHAR_SIZE TILE_SIZE #define TTE_CHAR_SIZE TILE_SIZE
typedef struct // When making this, missed that it already exists in tonc_math.h
{ typedef RECT Rect;
int left;
int top;
int right;
int bottom;
} Rect;
/* Gets the screenblock tile for the given coordinates (x, y). /* Gets the screenblock tile for the given coordinates (x, y).
* x and y are in number of tiles. * x and y are in number of tiles.
@@ -68,15 +63,15 @@ u16 main_bg_se_get_tile(BG_POINT pos);
INLINE int rect_width(const Rect* rect) INLINE int rect_width(const Rect* rect)
{ {
/* Extra parens to avoid issues in case compiler turns INLINE into macro /* Extra parens to avoid issues in case compiler turns INLINE into macro
* Not sure if necessary, could be just paranoia * Not sure if necessary, could be just paranoia
*/ */
return (((rect)->right) - ((rect)->left) + 1); return (((rect)->right) - ((rect)->left) + 1);
} }
INLINE int rect_height(const Rect* rect) INLINE int rect_height(const Rect* rect)
{ {
return (((rect)->bottom) - ((rect)->top) + 1); return (((rect)->bottom) - ((rect)->top) + 1);
} }
/* Clears a rect in the main background. /* Clears a rect in the main background.
+15 -8
View File
@@ -205,6 +205,8 @@ static const Rect TOP_LEFT_PANEL_ANIM_RECT = {0, 0, 8, 4 };
static const BG_POINT TOP_LEFT_BLIND_TITLE_POINT = {0, 21, }; static const BG_POINT TOP_LEFT_BLIND_TITLE_POINT = {0, 21, };
static const Rect BIG_BLIND_TITLE_SRC_RECT = {0, 26, 8, 26 }; static const Rect BIG_BLIND_TITLE_SRC_RECT = {0, 26, 8, 26 };
static const Rect BOSS_BLIND_TITLE_SRC_RECT = {0, 27, 8, 27 }; static const Rect BOSS_BLIND_TITLE_SRC_RECT = {0, 27, 8, 27 };
// static const BG_POINT GAME_OVER_SRC_RECT_3X3_POS = {25, 29};
// static const Rect GAME_OVER_MSG_DEST_RECT = {10, 6, 24, 10 };
// Rects for TTE (in pixels) // Rects for TTE (in pixels)
static const Rect HAND_SIZE_RECT = {128, 128, 152, 160 }; // Seems to include both SELECT and PLAYING static const Rect HAND_SIZE_RECT = {128, 128, 152, 160 }; // Seems to include both SELECT and PLAYING
@@ -236,7 +238,8 @@ static const Rect ROUND_END_BLIND_REWARD_RECT = { 168, 96, UNDEFINED, UNDEF
static const Rect ROUND_END_NUM_HANDS_RECT = {88, 116, UNDEFINED, UNDEFINED }; static const Rect ROUND_END_NUM_HANDS_RECT = {88, 116, UNDEFINED, UNDEFINED };
static const Rect HAND_REWARD_RECT = {168, UNDEFINED, UNDEFINED, UNDEFINED }; static const Rect HAND_REWARD_RECT = {168, UNDEFINED, UNDEFINED, UNDEFINED };
static const Rect CASHOUT_RECT = {88, 72, UNDEFINED, UNDEFINED }; static const Rect CASHOUT_RECT = {88, 72, UNDEFINED, UNDEFINED };
static const Rect SHOP_REROLL_RECT = {88, 96, UNDEFINED, UNDEFINED }; static const Rect SHOP_REROLL_RECT = {88, 96, UNDEFINED, UNDEFINED };
// static const Rect GAME_OVER_MSG_TEXT_RECT = {104, 56, UNDEFINED, UNDEFINED};
static const BG_POINT HELD_JOKERS_POS = {108, 10}; static const BG_POINT HELD_JOKERS_POS = {108, 10};
static const BG_POINT JOKER_DISCARD_TARGET = {240, 30}; static const BG_POINT JOKER_DISCARD_TARGET = {240, 30};
@@ -974,6 +977,12 @@ void game_round_init()
deck_shuffle(); // Shuffle the deck at the start of the round deck_shuffle(); // Shuffle the deck at the start of the round
} }
void game_lose_init()
{
affine_background_set_color(CLR_RED); // TODO: Use text color?
}
void init_game_state(enum GameState game_state_to_init) void init_game_state(enum GameState game_state_to_init)
{ {
// Switch written out, add init for states as needed // Switch written out, add init for states as needed
@@ -989,6 +998,7 @@ void init_game_state(enum GameState game_state_to_init)
case GAME_BLIND_SELECT: case GAME_BLIND_SELECT:
break; break;
case GAME_LOSE: case GAME_LOSE:
game_lose_init();
break; break;
default: default:
break; break;
@@ -1753,6 +1763,10 @@ static void played_cards_update_loop(bool* discarded_card, int* played_selection
display_ante(++ante); display_ante(++ante);
} }
} }
else if (hands <= 0)
{
game_set_state(GAME_LOSE);
}
else else
{ {
hand_state = HAND_DRAW; hand_state = HAND_DRAW;
@@ -1870,13 +1884,6 @@ static void game_round_end_cashout()
void game_playing() void game_playing()
{ {
// TODO: Blind rect sliding into view animation...
if (hand_state == HAND_SELECT && hands == 0)
{
// TODO: Check if it's safe to change to game_set_state() without side effects
game_state = GAME_LOSE;
}
// Background logic (thissss might be moved to the card'ssss logic later. I'm a sssssnake) // Background logic (thissss might be moved to the card'ssss logic later. I'm a sssssnake)
if (hand_state == HAND_DRAW || hand_state == HAND_DISCARD || hand_state == HAND_SELECT) if (hand_state == HAND_DRAW || hand_state == HAND_DISCARD || hand_state == HAND_SELECT)
{ {