(Manual conflict res on game.c) Merged main into ttm/joker-scop-1
This commit is contained in:
+259
-201
@@ -15,6 +15,7 @@
|
||||
#include "graphic_utils.h"
|
||||
#include "tonc_video.h"
|
||||
#include "audio_utils.h"
|
||||
#include "selection_grid.h"
|
||||
|
||||
#include "background_gfx.h"
|
||||
#include "background_shop_gfx.h"
|
||||
@@ -185,7 +186,7 @@ int get_money(void) {
|
||||
return money;
|
||||
}
|
||||
|
||||
IntList* jokers_available_to_shop; // List of joker IDs
|
||||
List* jokers_available_to_shop; // List of joker IDs
|
||||
|
||||
// Consts
|
||||
|
||||
@@ -251,12 +252,15 @@ static const Rect ROUND_END_NUM_HANDS_RECT = {88, 116, UNDEFINED, UNDEF
|
||||
static const Rect HAND_REWARD_RECT = {168, UNDEFINED, UNDEFINED, UNDEFINED };
|
||||
static const Rect CASHOUT_RECT = {88, 72, UNDEFINED, UNDEFINED };
|
||||
static const Rect SHOP_REROLL_RECT = {88, 96, UNDEFINED, UNDEFINED };
|
||||
#define ITEM_SHOP_Y 71 // TODO: Needs to be a rect?
|
||||
|
||||
//TODO: Properly define and use
|
||||
#define MENU_POP_OUT_ANIM_FRAMES 20
|
||||
|
||||
#define SCORED_CARD_TEXT_Y 48
|
||||
|
||||
#define HIGHLIGHT_COLOR 0xFFFF
|
||||
|
||||
#define PITCH_STEP_DISCARD_SFX (-64)
|
||||
#define PITCH_STEP_DRAW_SFX 24
|
||||
#define PITCH_STEP_UNDISCARD_SFX 2*PITCH_STEP_DRAW_SFX
|
||||
@@ -1010,11 +1014,11 @@ void game_set_state(enum GameState new_game_state)
|
||||
game_state = new_game_state;
|
||||
}
|
||||
|
||||
void jokers_avialable_to_shop_init()
|
||||
void jokers_available_to_shop_init()
|
||||
{
|
||||
int num_defined_jokers = get_joker_registry_size();
|
||||
jokers_available_to_shop = int_list_new(num_defined_jokers);
|
||||
for (int i = 0; i < num_defined_jokers; i++)
|
||||
jokers_available_to_shop = list_new(num_defined_jokers);
|
||||
for (intptr_t i = 0; i < num_defined_jokers; i++)
|
||||
{
|
||||
// Add all joker IDs sequentially
|
||||
int_list_append(jokers_available_to_shop, i);
|
||||
@@ -1023,7 +1027,7 @@ void jokers_avialable_to_shop_init()
|
||||
|
||||
void game_init()
|
||||
{
|
||||
jokers_avialable_to_shop_init();
|
||||
jokers_available_to_shop_init();
|
||||
|
||||
hands = max_hands;
|
||||
discards = max_discards;
|
||||
@@ -1797,11 +1801,6 @@ static void held_jokers_update_loop()
|
||||
jokers[i]->sprite_object->tx = hand_x - int2fx(spacing_lut[jokers_top][i]);
|
||||
jokers[i]->sprite_object->ty = hand_y;
|
||||
|
||||
if (joker_object_is_selected(jokers[i]))
|
||||
{
|
||||
jokers[i]->sprite_object->ty -= int2fx(10);
|
||||
}
|
||||
|
||||
joker_object_update(jokers[i]);
|
||||
}
|
||||
}
|
||||
@@ -2145,44 +2144,60 @@ void game_round_end()
|
||||
}
|
||||
}
|
||||
|
||||
static void game_shop_create_items(JokerObject *shop_jokers[])
|
||||
// Shop
|
||||
static List *shop_jokers = NULL;
|
||||
#define REROLL_BASE_COST 5 // Base cost for rerolling the shop items
|
||||
static int reroll_cost = REROLL_BASE_COST;
|
||||
|
||||
#define NEXT_ROUND_BTN_SEL_X 0
|
||||
|
||||
#define NEXT_ROUND_BTN_FRAME_PAL_IDX 5
|
||||
#define NEXT_ROUND_BTN_PAL_IDX 16
|
||||
#define REROLL_BTN_FRAME_PAL_IDX 7
|
||||
#define REROLL_BTN_PAL_IDX 3
|
||||
|
||||
static void game_shop_create_items()
|
||||
{
|
||||
tte_erase_rect_wrapper(SHOP_PRICES_TEXT_RECT);
|
||||
if (int_list_get_size(jokers_available_to_shop) == 0)
|
||||
if (list_get_size(jokers_available_to_shop) == 0)
|
||||
{
|
||||
// No jokers to create
|
||||
return;
|
||||
}
|
||||
|
||||
shop_jokers = list_new(MAX_SHOP_JOKERS);
|
||||
|
||||
for (int i = 0; i < MAX_SHOP_JOKERS; i++)
|
||||
{
|
||||
// TODO: weight the random choice by joker rarity
|
||||
int joker_idx = random() % int_list_get_size(jokers_available_to_shop);
|
||||
int joker_id = int_list_get(jokers_available_to_shop, joker_idx);
|
||||
int_list_remove_by_idx(jokers_available_to_shop, joker_idx);
|
||||
int joker_idx = random() % list_get_size(jokers_available_to_shop);
|
||||
intptr_t joker_id = int_list_get(jokers_available_to_shop, joker_idx);
|
||||
list_remove_by_idx(jokers_available_to_shop, joker_idx);
|
||||
|
||||
shop_jokers[i] = joker_object_new(joker_new(joker_id));
|
||||
shop_jokers[i]->sprite_object->x = int2fx(120 + i * 32);
|
||||
shop_jokers[i]->sprite_object->y = int2fx(160);
|
||||
shop_jokers[i]->sprite_object->tx = shop_jokers[i]->sprite_object->x;
|
||||
shop_jokers[i]->sprite_object->ty = int2fx(71);
|
||||
JokerObject *joker_object = joker_object_new(joker_new(joker_id));
|
||||
|
||||
int x = fx2int(shop_jokers[i]->sprite_object->tx) + TILE_SIZE - (get_digits_even(shop_jokers[i]->joker->value) - 1) * TILE_SIZE;
|
||||
int y = fx2int(shop_jokers[i]->sprite_object->ty) + CARD_SPRITE_SIZE + TILE_SIZE;
|
||||
tte_printf("#{P:%d,%d; cx:0xC000}$%d", x, y, shop_jokers[i]->joker->value);
|
||||
joker_object->sprite_object->x = int2fx(120 + i * CARD_SPRITE_SIZE);
|
||||
joker_object->sprite_object->y = int2fx(160);
|
||||
joker_object->sprite_object->tx = joker_object->sprite_object->x;
|
||||
joker_object->sprite_object->ty = int2fx(ITEM_SHOP_Y);
|
||||
|
||||
sprite_position(joker_object_get_sprite(shop_jokers[i]), fx2int(shop_jokers[i]->sprite_object->x), fx2int(shop_jokers[i]->sprite_object->y));
|
||||
int x = fx2int(joker_object->sprite_object->tx) + TILE_SIZE - (get_digits_even(joker_object->joker->value) - 1) * TILE_SIZE;
|
||||
int y = fx2int(joker_object->sprite_object->ty) + CARD_SPRITE_SIZE + TILE_SIZE;
|
||||
tte_printf("#{P:%d,%d; cx:0xC000}$%d", x, y, joker_object->joker->value);
|
||||
|
||||
sprite_position(joker_object_get_sprite(joker_object), fx2int(joker_object->sprite_object->x), fx2int(joker_object->sprite_object->y));
|
||||
list_append(shop_jokers, joker_object);
|
||||
}
|
||||
}
|
||||
|
||||
// Intro sequence (menu and shop icon coming into frame)
|
||||
static void game_shop_intro(JokerObject* shop_jokers[])
|
||||
static void game_shop_intro()
|
||||
{
|
||||
main_bg_se_copy_rect_1_tile_vert(POP_MENU_ANIM_RECT, SE_UP);
|
||||
|
||||
if (timer == 1)
|
||||
{
|
||||
game_shop_create_items(shop_jokers);
|
||||
game_shop_create_items();
|
||||
}
|
||||
|
||||
if (timer >= 7) // Shift the shop icon
|
||||
@@ -2209,27 +2224,31 @@ static void game_shop_intro(JokerObject* shop_jokers[])
|
||||
}
|
||||
}
|
||||
|
||||
static void game_shop_reroll(JokerObject** shop_jokers, int *reroll_cost)
|
||||
static void game_shop_reroll(int *reroll_cost)
|
||||
{
|
||||
money -= *reroll_cost;
|
||||
display_money(money); // Update the money display
|
||||
for (int i = 0; i < MAX_SHOP_JOKERS; i++)
|
||||
for (int i = 0; i < list_get_size(shop_jokers); i++)
|
||||
{
|
||||
if (shop_jokers[i] != NULL)
|
||||
JokerObject *joker_object = list_get(shop_jokers, i);
|
||||
if (joker_object != NULL)
|
||||
{
|
||||
int_list_append(jokers_available_to_shop, shop_jokers[i]->joker->id);
|
||||
joker_object_destroy(&shop_jokers[i]); // Destroy the joker object if it exists
|
||||
int_list_append(jokers_available_to_shop, joker_object->joker->id);
|
||||
joker_object_destroy(&joker_object); // Destroy the joker object if it exists
|
||||
}
|
||||
}
|
||||
|
||||
game_shop_create_items(shop_jokers);
|
||||
list_destroy(&shop_jokers);
|
||||
|
||||
game_shop_create_items();
|
||||
|
||||
for (int i = 0; i < MAX_SHOP_JOKERS; i++)
|
||||
for (int i = 0; i < list_get_size(shop_jokers); i++)
|
||||
{
|
||||
if (shop_jokers[i] != NULL)
|
||||
JokerObject *joker_object = list_get(shop_jokers, i);
|
||||
if (joker_object != NULL)
|
||||
{
|
||||
shop_jokers[i]->sprite_object->y = shop_jokers[i]->sprite_object->ty; // Set the y position to the target position
|
||||
joker_object_shake(shop_jokers[i], UNDEFINED); // Give the joker a little wiggle animation
|
||||
joker_object->sprite_object->y = joker_object->sprite_object->ty; // Set the y position to the target position
|
||||
joker_object_shake(joker_object, UNDEFINED); // Give the joker a little wiggle animation
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2237,125 +2256,156 @@ static void game_shop_reroll(JokerObject** shop_jokers, int *reroll_cost)
|
||||
tte_printf("#{P:%d,%d; cx:0xF000}$%d", SHOP_REROLL_RECT.left, SHOP_REROLL_RECT.top, *reroll_cost);
|
||||
}
|
||||
|
||||
// Shop menu input and selection
|
||||
static void game_shop_process_user_input(JokerObject** shop_jokers)
|
||||
// Shop input
|
||||
static int shop_top_row_get_size()
|
||||
{
|
||||
static const int REROLL_BASE_COST = 5; // Base cost for rerolling the shop items
|
||||
static int reroll_cost = REROLL_BASE_COST;
|
||||
return list_get_size(shop_jokers) + 1; // + 1 to account for next round button
|
||||
}
|
||||
|
||||
// temp variables for future implementation
|
||||
const ushort max_items_top = MAX_SHOP_JOKERS;
|
||||
const ushort max_items_bottom = 0;
|
||||
static void game_shop_buy_joker(int shop_joker_idx)
|
||||
{
|
||||
JokerObject *joker_object = list_get(shop_jokers, shop_joker_idx);
|
||||
joker_push(joker_object);
|
||||
money -= joker_object->joker->value; // Deduct the money spent on the joker
|
||||
display_money(money); // Update the money display
|
||||
|
||||
Rect joker_price_rect;
|
||||
joker_price_rect.left = fx2int(joker_object->sprite_object->tx);
|
||||
// 2*TILE_SIZE because the item is highlighted and raised by 1 additional tile
|
||||
joker_price_rect.top = fx2int(joker_object->sprite_object->ty) + CARD_SPRITE_SIZE + 2 * TILE_SIZE;
|
||||
joker_price_rect.right = joker_price_rect.left + TILE_SIZE * 3;
|
||||
joker_price_rect.bottom = joker_price_rect.top + TILE_SIZE;
|
||||
|
||||
tte_erase_rect_wrapper(joker_price_rect);
|
||||
|
||||
list_remove_by_idx(shop_jokers, shop_joker_idx); // Remove the joker from the shop
|
||||
}
|
||||
|
||||
static void shop_top_row_on_key_hit(SelectionGrid* selection_grid, Selection* selection)
|
||||
{
|
||||
if (!key_hit(SELECT_CARD))
|
||||
return;
|
||||
|
||||
if (selection->x == NEXT_ROUND_BTN_SEL_X)
|
||||
{
|
||||
// Go to next blind selection game state
|
||||
state = 2; // Go to the outro sequence state
|
||||
timer = 0; // Reset the timer
|
||||
reroll_cost = REROLL_BASE_COST;
|
||||
|
||||
memcpy16(&pal_bg_mem[NEXT_ROUND_BTN_FRAME_PAL_IDX], &pal_bg_mem[6], 1);
|
||||
|
||||
// memcpy16(&pal_bg_mem[16], &pal_bg_mem[6], 1);
|
||||
// This changes the color of the button to a dark red.
|
||||
// However, it shares a palette with the shop icon, so it will change the color of the shop icon as well.
|
||||
// And I don't care enough to fix it right now.
|
||||
}
|
||||
else
|
||||
{
|
||||
int shop_joker_idx = selection->x - 1; // - 1 to account for next round button
|
||||
JokerObject *joker_object = list_get(shop_jokers, shop_joker_idx);
|
||||
if (joker_object == NULL
|
||||
|| jokers_top >= MAX_JOKERS_HELD_SIZE - 1
|
||||
|| money < joker_object->joker->value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
game_shop_buy_joker(shop_joker_idx);
|
||||
|
||||
// In Balatro the selection actually stays on the purchased joker it's easier to just move it left
|
||||
selection_grid_move_selection_horz(selection_grid, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void shop_top_row_on_selection_changed(SelectionGrid* selection_grid, int row_idx,
|
||||
const Selection* prev_selection,
|
||||
const Selection* new_selection)
|
||||
{
|
||||
// The selection grid system only guarantees that the new selection is within bounds
|
||||
if (prev_selection->y == row_idx && prev_selection->x >= 0 && prev_selection->x < shop_top_row_get_size())
|
||||
{
|
||||
if (prev_selection->x == NEXT_ROUND_BTN_SEL_X)
|
||||
{
|
||||
// Remove next round button highlight
|
||||
memcpy16(&pal_bg_mem[NEXT_ROUND_BTN_FRAME_PAL_IDX], &pal_bg_mem[NEXT_ROUND_BTN_PAL_IDX], 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
JokerObject *joker = list_get(shop_jokers, prev_selection->x - 1);
|
||||
sprite_object_set_focus(joker->sprite_object, false);
|
||||
// -1 to account for next round button
|
||||
}
|
||||
}
|
||||
|
||||
if (new_selection->y == row_idx)
|
||||
{
|
||||
if (new_selection->x == NEXT_ROUND_BTN_SEL_X)
|
||||
{
|
||||
// Highlight next round button
|
||||
memset16(&pal_bg_mem[NEXT_ROUND_BTN_FRAME_PAL_IDX], HIGHLIGHT_COLOR, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
JokerObject *joker = list_get(shop_jokers, new_selection->x - 1);
|
||||
sprite_object_set_focus(joker->sprite_object, true);
|
||||
// -1 to account for next round button
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int shop_bottom_row_get_size()
|
||||
{
|
||||
return 1; // Currently only the reroll button
|
||||
}
|
||||
|
||||
static void shop_bottom_row_on_selection_changed(SelectionGrid* selection_grid, int row_idx, const Selection* prev_selection, const Selection* new_selection)
|
||||
{
|
||||
if (row_idx == prev_selection->y)
|
||||
{
|
||||
// Remove highlight
|
||||
memcpy16(&pal_bg_mem[REROLL_BTN_FRAME_PAL_IDX], &pal_bg_mem[REROLL_BTN_PAL_IDX], 1);
|
||||
}
|
||||
else if (row_idx == new_selection->y)
|
||||
{
|
||||
memset16(&pal_bg_mem[REROLL_BTN_FRAME_PAL_IDX], HIGHLIGHT_COLOR, 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void shop_bottom_row_on_key_hit(SelectionGrid* selection_grid, Selection* selection)
|
||||
{
|
||||
if (money >= reroll_cost)
|
||||
{
|
||||
game_shop_reroll(&reroll_cost);
|
||||
}
|
||||
}
|
||||
|
||||
SelectionGridRow shop_selection_rows[] =
|
||||
{
|
||||
{0, shop_top_row_get_size, shop_top_row_on_selection_changed, shop_top_row_on_key_hit},
|
||||
{1, shop_bottom_row_get_size, shop_bottom_row_on_selection_changed, shop_bottom_row_on_key_hit}
|
||||
};
|
||||
|
||||
static const Selection SHOP_INIT_SEL = {-1, 0};
|
||||
|
||||
SelectionGrid shop_selection_grid = {shop_selection_rows, NUM_ELEM_IN_ARR(shop_selection_rows), SHOP_INIT_SEL};
|
||||
|
||||
// Shop menu input and selection
|
||||
static void game_shop_process_user_input()
|
||||
{
|
||||
if (timer == 1)
|
||||
{
|
||||
// The selection grid is initialized outside of bounds and moved
|
||||
// to trigger the selection change so the initial selection is visible
|
||||
shop_selection_grid.selection = SHOP_INIT_SEL;
|
||||
selection_grid_move_selection_horz(&shop_selection_grid, 1);
|
||||
tte_printf("#{P:%d,%d; cx:0xF000}$%d", SHOP_REROLL_RECT.left, SHOP_REROLL_RECT.top, reroll_cost);
|
||||
}
|
||||
|
||||
// Shop input logic
|
||||
if (key_hit(KEY_UP))
|
||||
{
|
||||
selection_y = 0;
|
||||
|
||||
if (selection_x > max_items_top)
|
||||
{
|
||||
selection_x = max_items_top;
|
||||
}
|
||||
}
|
||||
else if (key_hit(KEY_DOWN))
|
||||
{
|
||||
selection_y = 1;
|
||||
|
||||
if (selection_x > max_items_bottom)
|
||||
{
|
||||
selection_x = max_items_bottom;
|
||||
}
|
||||
}
|
||||
else if (key_hit(KEY_LEFT))
|
||||
{
|
||||
if (selection_x > 0)
|
||||
{
|
||||
selection_x--;
|
||||
}
|
||||
}
|
||||
else if (key_hit(KEY_RIGHT))
|
||||
{
|
||||
// TODO: Don't allow cursor on sold items
|
||||
if (selection_y == 0 && selection_x < max_items_top)
|
||||
{
|
||||
selection_x++;
|
||||
}
|
||||
else if (selection_y == 1 && selection_x < max_items_bottom)
|
||||
{
|
||||
selection_x++;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy16(&pal_bg_mem[7], &pal_bg_mem[3], 1);
|
||||
memcpy16(&pal_bg_mem[5], &pal_bg_mem[16], 1);
|
||||
|
||||
// Shop selection logic
|
||||
if (selection_x == 0 && selection_y == 0) // Next round button
|
||||
{
|
||||
memset16(&pal_bg_mem[5], 0xFFFF, 1);
|
||||
|
||||
if (key_hit(SELECT_CARD))
|
||||
{
|
||||
// Go to next blind selection game state
|
||||
state = 2; // Go to the outro sequence state
|
||||
timer = 0; // Reset the timer
|
||||
reroll_cost = REROLL_BASE_COST;
|
||||
|
||||
memcpy16(&pal_bg_mem[5], &pal_bg_mem[6], 1);
|
||||
|
||||
// memcpy16(&pal_bg_mem[16], &pal_bg_mem[6], 1);
|
||||
// This changes the color of the button to a dark red.
|
||||
// However, it shares a palette with the shop icon, so it will change the color of the shop icon as well.
|
||||
// And I don't care enough to fix it right now.
|
||||
}
|
||||
}
|
||||
else if (selection_x == 0 && selection_y == 1) // Reroll button
|
||||
{
|
||||
memset16(&pal_bg_mem[7], 0xFFFF, 1);
|
||||
|
||||
if (key_hit(SELECT_CARD) && money >= reroll_cost)
|
||||
{
|
||||
game_shop_reroll(shop_jokers, &reroll_cost);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_SHOP_JOKERS; i++) // Item selection logic
|
||||
{
|
||||
if (shop_jokers[i] != NULL)
|
||||
{
|
||||
if (i == selection_x - 1 && selection_y == 0)
|
||||
{
|
||||
shop_jokers[i]->sprite_object->ty = int2fx(61);
|
||||
|
||||
if (key_hit(SELECT_CARD) && jokers_top < MAX_JOKERS_HELD_SIZE - 1 && money >= shop_jokers[i]->joker->value)
|
||||
{
|
||||
joker_push(shop_jokers[i]);
|
||||
money -= shop_jokers[i]->joker->value; // Deduct the money spent on the joker
|
||||
display_money(money); // Update the money display
|
||||
|
||||
Rect joker_price_rect;
|
||||
joker_price_rect.left = fx2int(shop_jokers[i]->sprite_object->tx);
|
||||
// 2*TILE_SIZE because the item is highlighted and raised by 1 additional tile
|
||||
joker_price_rect.top = fx2int(shop_jokers[i]->sprite_object->ty) + CARD_SPRITE_SIZE + 2*TILE_SIZE;
|
||||
joker_price_rect.right = joker_price_rect.left + TILE_SIZE * 3;
|
||||
joker_price_rect.bottom = joker_price_rect.top + TILE_SIZE;
|
||||
|
||||
tte_erase_rect_wrapper(joker_price_rect);
|
||||
|
||||
shop_jokers[i] = NULL; // Remove the joker from the shop
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
shop_jokers[i]->sprite_object->ty = int2fx(71);
|
||||
}
|
||||
}
|
||||
}
|
||||
selection_grid_process_input(&shop_selection_grid);
|
||||
}
|
||||
|
||||
static void game_shop_lights_anim_frame()
|
||||
@@ -2383,20 +2433,66 @@ static void game_shop_lights_anim_frame()
|
||||
memcpy16(&pal_bg_mem[8], &shifted_palette[3], 1);
|
||||
}
|
||||
|
||||
// Outro sequence (menu and shop icon going out of frame)
|
||||
static void game_shop_outro()
|
||||
{
|
||||
// Shift the shop panel
|
||||
main_bg_se_move_rect_1_tile_vert(POP_MENU_ANIM_RECT, SE_DOWN);
|
||||
|
||||
main_bg_se_copy_rect_1_tile_vert(TOP_LEFT_PANEL_ANIM_RECT, SE_UP);
|
||||
|
||||
if (timer == 1)
|
||||
{
|
||||
tte_erase_rect_wrapper(SHOP_PRICES_TEXT_RECT); // Erase the shop prices text
|
||||
|
||||
for (int i = 0; i < list_get_size(shop_jokers); i++)
|
||||
{
|
||||
JokerObject *joker_object = list_get(shop_jokers, i);
|
||||
if (joker_object != NULL)
|
||||
{
|
||||
joker_object->sprite_object->ty = int2fx(160);
|
||||
}
|
||||
}
|
||||
|
||||
int y = 6;
|
||||
memset16(&se_mem[MAIN_BG_SBB][32 * (y - 1)], 0x0006, 1);
|
||||
memset16(&se_mem[MAIN_BG_SBB][1 + 32 * (y - 1)], 0x0007, 2);
|
||||
memset16(&se_mem[MAIN_BG_SBB][3 + 32 * (y - 1)], 0x0008, 1);
|
||||
memset16(&se_mem[MAIN_BG_SBB][4 + 32 * (y - 1)], 0x0009, 4);
|
||||
memset16(&se_mem[MAIN_BG_SBB][7 + 32 * (y - 1)], 0x000A, 1);
|
||||
memset16(&se_mem[MAIN_BG_SBB][8 + 32 * (y - 1)], 0x0406, 1);
|
||||
}
|
||||
else if (timer == 2)
|
||||
{
|
||||
int y = 5;
|
||||
memset16(&se_mem[MAIN_BG_SBB][32 * (y - 1)], 0x0001, 1);
|
||||
memset16(&se_mem[MAIN_BG_SBB][1 + 32 * (y - 1)], 0x0002, 7);
|
||||
memset16(&se_mem[MAIN_BG_SBB][8 + 32 * (y - 1)], 0x0401, 1);
|
||||
}
|
||||
|
||||
if (timer >= MENU_POP_OUT_ANIM_FRAMES)
|
||||
{
|
||||
state = 3; // Go to the next state
|
||||
timer = 0; // Reset the timer
|
||||
}
|
||||
}
|
||||
|
||||
void game_shop()
|
||||
{
|
||||
change_background(BG_ID_SHOP);
|
||||
|
||||
static JokerObject *shop_jokers[MAX_SHOP_JOKERS] = {NULL};
|
||||
|
||||
for (int i = 0; i < MAX_SHOP_JOKERS; i++)
|
||||
if (shop_jokers != NULL)
|
||||
{
|
||||
if (shop_jokers[i] != NULL)
|
||||
for (int i = 0; i < list_get_size(shop_jokers); i++)
|
||||
{
|
||||
joker_object_update(shop_jokers[i]);
|
||||
JokerObject *joker_object = list_get(shop_jokers, i);
|
||||
if (joker_object != NULL)
|
||||
{
|
||||
joker_object_update(joker_object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (timer % 20 == 0)
|
||||
{
|
||||
@@ -2407,73 +2503,35 @@ void game_shop()
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
game_shop_intro(shop_jokers);
|
||||
game_shop_intro();
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
game_shop_process_user_input(shop_jokers);
|
||||
game_shop_process_user_input();
|
||||
break;
|
||||
}
|
||||
case 2: // Outro sequence (menu and shop icon going out of frame)
|
||||
case 2:
|
||||
{
|
||||
// Shift the shop panel
|
||||
main_bg_se_move_rect_1_tile_vert(POP_MENU_ANIM_RECT, SE_DOWN);
|
||||
|
||||
main_bg_se_copy_rect_1_tile_vert(TOP_LEFT_PANEL_ANIM_RECT, SE_UP);
|
||||
|
||||
if (timer == 1)
|
||||
{
|
||||
tte_erase_rect_wrapper(SHOP_PRICES_TEXT_RECT); // Erase the shop prices text
|
||||
|
||||
for (int i = 0; i < MAX_SHOP_JOKERS; i++)
|
||||
{
|
||||
if (shop_jokers[i] != NULL)
|
||||
{
|
||||
shop_jokers[i]->sprite_object->ty = int2fx(160);
|
||||
}
|
||||
}
|
||||
|
||||
int y = 6;
|
||||
memset16(&se_mem[MAIN_BG_SBB][32 * (y - 1)], 0x0006, 1);
|
||||
memset16(&se_mem[MAIN_BG_SBB][1 + 32 * (y - 1)], 0x0007, 2);
|
||||
memset16(&se_mem[MAIN_BG_SBB][3 + 32 * (y - 1)], 0x0008, 1);
|
||||
memset16(&se_mem[MAIN_BG_SBB][4 + 32 * (y - 1)], 0x0009, 4);
|
||||
memset16(&se_mem[MAIN_BG_SBB][7 + 32 * (y - 1)], 0x000A, 1);
|
||||
memset16(&se_mem[MAIN_BG_SBB][8 + 32 * (y - 1)], 0x0406, 1);
|
||||
}
|
||||
else if (timer == 2)
|
||||
{
|
||||
int y = 5;
|
||||
memset16(&se_mem[MAIN_BG_SBB][32 * (y - 1)], 0x0001, 1);
|
||||
memset16(&se_mem[MAIN_BG_SBB][1 + 32 * (y - 1)], 0x0002, 7);
|
||||
memset16(&se_mem[MAIN_BG_SBB][8 + 32 * (y - 1)], 0x0401, 1);
|
||||
}
|
||||
|
||||
if (timer >= MENU_POP_OUT_ANIM_FRAMES)
|
||||
{
|
||||
state = 3; // Go to the next state
|
||||
timer = 0; // Reset the timer
|
||||
}
|
||||
|
||||
game_shop_outro();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
state = 0; // Reset the state
|
||||
|
||||
selection_x = 0; // Reset the selection
|
||||
selection_y = 0; // Reset the selection
|
||||
|
||||
for (int i = 0; i < MAX_SHOP_JOKERS; i++)
|
||||
for (int i = 0; i < list_get_size(shop_jokers); i++)
|
||||
{
|
||||
if (shop_jokers[i] != NULL)
|
||||
JokerObject* joker_object = list_get(shop_jokers, i);
|
||||
if (joker_object != NULL)
|
||||
{
|
||||
// Make the joker available back to shop
|
||||
int_list_append(jokers_available_to_shop, shop_jokers[i]->joker->id);
|
||||
// Make the joker available back to shop
|
||||
int_list_append(jokers_available_to_shop, (intptr_t)joker_object->joker->id);
|
||||
}
|
||||
joker_object_destroy(&shop_jokers[i]); // Destroy the joker objects
|
||||
joker_object_destroy(&joker_object); // Destroy the joker objects
|
||||
}
|
||||
|
||||
list_destroy(&shop_jokers);
|
||||
|
||||
increment_blind(BLIND_DEFEATED); // TODO: Move to game_round_end()?
|
||||
game_set_state(GAME_BLIND_SELECT); // If we reach here, we should go to the blind select state
|
||||
|
||||
|
||||
Reference in New Issue
Block a user