Updated shop state to have rough functionality to switch to the next state
This commit is contained in:
@@ -0,0 +1 @@
|
||||
-gB8 -mR8 -mLs -mRtf
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.3 KiB |
+147
-16
@@ -18,11 +18,11 @@
|
||||
|
||||
#include "soundbank.h"
|
||||
|
||||
static int timer = 1; // This might already exist in libtonc but idk so i'm just making my own
|
||||
static int timer = 0; // This might already exist in libtonc but idk so i'm just making my own
|
||||
static int game_speed = 1;
|
||||
static int background = 0;
|
||||
|
||||
static enum GameState game_state = GAME_PLAYING; // The current game state, this is used to determine what the game is doing at any given time
|
||||
static enum GameState game_state = GAME_ROUND_END; // The current game state, this is used to determine what the game is doing at any given time
|
||||
static enum HandState hand_state = HAND_DRAW;
|
||||
static enum PlayState play_state = PLAY_PLAYING;
|
||||
|
||||
@@ -377,15 +377,15 @@ void change_background(int id)
|
||||
|
||||
// Set the outline colors for the shop background
|
||||
memset16(&pal_bg_mem[27], 0x213D, 1);
|
||||
memset16(&pal_bg_mem[7], 0x10B4, 1);
|
||||
memset16(&pal_bg_mem[6], 0x10B4, 1);
|
||||
|
||||
memset16(&pal_bg_mem[14], 0x32BE, 1); // Reset the shop lights to correct colors
|
||||
memset16(&pal_bg_mem[17], 0x4B5F, 1);
|
||||
memset16(&pal_bg_mem[22], 0x5F9F, 1);
|
||||
memset16(&pal_bg_mem[8], 0xFFFF, 1);
|
||||
|
||||
memcpy16(&pal_bg_mem[6], &pal_bg_mem[3], 1); // Disable the button highlight colors
|
||||
memcpy16(&pal_bg_mem[13], &pal_bg_mem[15], 1);
|
||||
memcpy16(&pal_bg_mem[7], &pal_bg_mem[3], 1); // Disable the button highlight colors
|
||||
memcpy16(&pal_bg_mem[5], &pal_bg_mem[16], 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1695,8 +1695,8 @@ void game_round_end() // Writing this kind a made me want to kms. If somewone wa
|
||||
timer = 0;
|
||||
state = 9;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
timer = 0;
|
||||
sequence_step = 0;
|
||||
@@ -1713,6 +1713,17 @@ void game_shop()
|
||||
{
|
||||
change_background(BG_ID_SHOP);
|
||||
|
||||
// TODO: Later move these static variables somewhere else so they can be reused for each game state
|
||||
static int state = 0;
|
||||
|
||||
// these are for controlling the shop menu
|
||||
static bool top_row = true;
|
||||
static ushort selection_x = 0;
|
||||
|
||||
// temp variables for future implementation
|
||||
const ushort max_items_top = 0;
|
||||
const ushort max_items_bottom = 0;
|
||||
|
||||
if (timer % 20 == 0) // Shift palette around the border of the shop icon
|
||||
{
|
||||
unsigned short shifted_palette[4];
|
||||
@@ -1734,18 +1745,19 @@ void game_shop()
|
||||
memcpy16(&pal_bg_mem[17], &shifted_palette[1], 1);
|
||||
memcpy16(&pal_bg_mem[22], &shifted_palette[2], 1);
|
||||
memcpy16(&pal_bg_mem[8], &shifted_palette[3], 1);
|
||||
|
||||
}
|
||||
|
||||
if (timer < 13)
|
||||
switch (state) // I'm only using magic numbers here for the sake of simplicity since it's just sequential, but you can replace them with named constants or enums if it makes it clearer
|
||||
{
|
||||
for (int y = 7; y < 40; y++)
|
||||
case 0: // Intro sequence (menu and shop icon coming into frame)
|
||||
{
|
||||
for (int y = 7; y < 40; y++) // Shift the shop panel
|
||||
{
|
||||
int x = 9;
|
||||
memcpy16(&se_mem[MAIN_BG_SBB][x + 32 * (y - 1)], &se_mem[MAIN_BG_SBB][x + 32 * y], 16);
|
||||
}
|
||||
|
||||
if (timer >= 7)
|
||||
if (timer >= 7) // Shift the shop icon
|
||||
{
|
||||
int timer_offset = timer - 6;
|
||||
|
||||
@@ -1757,12 +1769,131 @@ void game_shop()
|
||||
}
|
||||
}
|
||||
|
||||
// if (timer == 8)
|
||||
// {
|
||||
// int y_from = 26;
|
||||
// int y_to = 0;
|
||||
// memcpy16(&se_mem[MAIN_BG_SE_BASE][32 * y_to], &se_mem[MAIN_BG_SE_BASE][32 * y_from], 9);
|
||||
// }
|
||||
if (timer == 12)
|
||||
{
|
||||
state = 1;
|
||||
timer = 0; // Reset the timer
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 1: // Shop menu input and selection
|
||||
{
|
||||
// Shop input logic
|
||||
if (key_hit(KEY_UP))
|
||||
{
|
||||
top_row = true;
|
||||
|
||||
if (selection_x > max_items_top)
|
||||
{
|
||||
selection_x = max_items_top;
|
||||
}
|
||||
}
|
||||
else if (key_hit(KEY_DOWN))
|
||||
{
|
||||
top_row = false;
|
||||
|
||||
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))
|
||||
{
|
||||
if (top_row && selection_x < max_items_top)
|
||||
{
|
||||
selection_x++;
|
||||
}
|
||||
else if (!top_row && selection_x < max_items_bottom)
|
||||
{
|
||||
selection_x++;
|
||||
}
|
||||
}
|
||||
|
||||
// Shop selection logic
|
||||
if (selection_x == 0 && top_row)
|
||||
{
|
||||
memcpy16(&pal_bg_mem[7], &pal_bg_mem[3], 1);
|
||||
memset16(&pal_bg_mem[5], 0xFFFF, 1);
|
||||
|
||||
if (key_hit(KEY_A))
|
||||
{
|
||||
// Go to next blind selection game state
|
||||
state = 2; // Go to the outro sequence state
|
||||
timer = 0; // Reset the timer
|
||||
|
||||
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 && !top_row)
|
||||
{
|
||||
memset16(&pal_bg_mem[7], 0xFFFF, 1);
|
||||
memcpy16(&pal_bg_mem[5], &pal_bg_mem[16], 1);
|
||||
|
||||
if (key_hit(KEY_A))
|
||||
{
|
||||
// Do shop re-roll for money
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // Outro sequence (menu and shop icon going out of frame)
|
||||
{
|
||||
// This is reused from game_round_end()
|
||||
// Shift the shop panel
|
||||
int x = 9;
|
||||
for (int y = 19; y > 5; y--)
|
||||
{
|
||||
memcpy16(&se_mem[MAIN_BG_SBB][x + 32 * (y + 1)], &se_mem[MAIN_BG_SBB][x + 32 * y], 16);
|
||||
}
|
||||
|
||||
// Shift the shop icon
|
||||
for (int y = 0; y < 5; y++)
|
||||
{
|
||||
memcpy16(&se_mem[MAIN_BG_SBB][32 * (y - 1)], &se_mem[MAIN_BG_SBB][32 * y], 9);
|
||||
}
|
||||
|
||||
if (timer == 1)
|
||||
{
|
||||
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)], 0x0408, 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 >= 20)
|
||||
{
|
||||
state = 3; // Go to the next state
|
||||
timer = 0; // Reset the timer
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user