Refactor hand_discard function to return a boolean and update game logic for discarding cards; add background_play_gfx and improve text engine initialization.
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.2 KiB |
@@ -0,0 +1 @@
|
||||
-g! -gB8 -m -mR8 -mLs -mRtf -p!
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.2 KiB |
+1
-1
@@ -68,7 +68,7 @@ void hand_set_focus(int index); // This makes the card at the given index the on
|
||||
int hand_get_focus(); // This gets the index of the card that's being looked at
|
||||
void hand_select(); // This lets the player select the card they're looking at for the next action
|
||||
void hand_change_sort(); // This sorts the hand by suit or rank
|
||||
void hand_discard(); // This discards the selected cards
|
||||
bool hand_discard(); // This discards the selected cards
|
||||
int hand_get_size(); // This gets the size of the hand
|
||||
int hand_get_max_size(); // This gets the maximum size of the hand (this doesn't get the array max, it gets the total amount of cards that you have)
|
||||
|
||||
|
||||
+12
-11
@@ -273,6 +273,14 @@ void card_update() // This whole function is currently pretty unoptimized due to
|
||||
hand_x = int2fx(240);
|
||||
hand_y = int2fx(70);
|
||||
|
||||
if (!sound_played)
|
||||
{
|
||||
const int pitch_lut[MAX_SELECTION_SIZE] = {1024, 960, 896, 832, 768};
|
||||
mm_sound_effect sfx_draw = {{SFX_CARD_DRAW}, pitch_lut[cards_drawn], 0, 255, 128,};
|
||||
mmEffectEx(&sfx_draw);
|
||||
sound_played = true;
|
||||
}
|
||||
|
||||
if (hand[i]->x >= hand_x)
|
||||
{
|
||||
card_object_destroy(&hand[i]);
|
||||
@@ -283,14 +291,6 @@ void card_update() // This whole function is currently pretty unoptimized due to
|
||||
sound_played = false;
|
||||
}
|
||||
|
||||
if (!sound_played)
|
||||
{
|
||||
const int pitch_lut[MAX_SELECTION_SIZE] = {1024, 960, 896, 832, 768};
|
||||
mm_sound_effect sfx_draw = {{SFX_CARD_DRAW}, pitch_lut[cards_drawn], 0, 255, 128,};
|
||||
mmEffectEx(&sfx_draw);
|
||||
sound_played = true;
|
||||
}
|
||||
|
||||
discarded_card = true;
|
||||
}
|
||||
else
|
||||
@@ -351,7 +351,7 @@ void card_update() // This whole function is currently pretty unoptimized due to
|
||||
// Hand functions
|
||||
void hand_set_focus(int index)
|
||||
{
|
||||
if (index < 0 || index > hand_top) return;
|
||||
if (index < 0 || index > hand_top || hand_state != HAND_SELECT) return;
|
||||
card_focused = index;
|
||||
|
||||
mm_sound_effect sfx_focus = {{SFX_CARD_FOCUS}, 1024 + rand() % 512, 0, 255, 128,};
|
||||
@@ -391,11 +391,12 @@ void hand_change_sort()
|
||||
sort_cards();
|
||||
}
|
||||
|
||||
void hand_discard()
|
||||
bool hand_discard()
|
||||
{
|
||||
if (hand_state != HAND_SELECT) return;
|
||||
if (hand_state != HAND_SELECT || hand_selections == 0) return false;
|
||||
hand_state = HAND_DISCARD;
|
||||
card_focused = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int hand_get_size()
|
||||
|
||||
+34
-4
@@ -8,9 +8,26 @@
|
||||
#include "sprite.h"
|
||||
#include "card.h"
|
||||
|
||||
static int hand = 4;
|
||||
static int discard = 4;
|
||||
|
||||
void game_init()
|
||||
{
|
||||
|
||||
tte_printf("#{P:128,128; cx:0}%d/%d", hand_get_size(), hand_get_max_size()); // Hand size/max size
|
||||
tte_printf("#{P:200,152}%d/%d", deck_get_size(), deck_get_max_size()); // Deck size/max size
|
||||
|
||||
tte_printf("#{P:32,48;}*%d", 0); // Score
|
||||
|
||||
tte_printf("#{P:24,80;}%d", 0); // Chips
|
||||
tte_printf("#{P:40,80;}%d", 0); // Mult
|
||||
|
||||
tte_printf("#{P:16,104; cx:0x2000}%d", hand); // Hand
|
||||
tte_printf("#{P:48,104; cx:0x3000}%d", discard); // Discard
|
||||
|
||||
tte_printf("#{P:24,120; cx:0x1000}$%d", 4); // Money
|
||||
|
||||
tte_printf("#{P:48,144}%d", 1); // Round
|
||||
tte_printf("#{P:8,144}%d#{cx:0}/%d", 1, 8); // Ante
|
||||
}
|
||||
|
||||
void game_update()
|
||||
@@ -36,9 +53,22 @@ void game_update()
|
||||
|
||||
if (key_hit(KEY_SELECT))
|
||||
{
|
||||
hand_discard();
|
||||
if (discard > 0 && hand_discard())
|
||||
{
|
||||
discard--;
|
||||
tte_printf("#{P:48,104; cx:0x3000}%d", discard);
|
||||
}
|
||||
}
|
||||
|
||||
tte_printf("#{es; P:128,130}%d/%d", hand_get_size(), hand_get_max_size());
|
||||
tte_printf("#{P:200,155}%d/%d", deck_get_size(), deck_get_max_size());
|
||||
static int last_hand_size = 0;
|
||||
static int last_deck_size = 0;
|
||||
|
||||
if (last_hand_size != hand_get_size() || last_deck_size != deck_get_size())
|
||||
{
|
||||
tte_printf("#{P:128,128; cx:0}%d/%d", hand_get_size(), hand_get_max_size()); // Hand size/max size
|
||||
tte_printf("#{P:200,152}%d/%d", deck_get_size(), deck_get_max_size()); // Deck size/max size
|
||||
|
||||
last_hand_size = hand_get_size();
|
||||
last_deck_size = deck_get_size();
|
||||
}
|
||||
}
|
||||
+12
-6
@@ -9,6 +9,7 @@
|
||||
// Graphics
|
||||
#include "deck_gfx.h"
|
||||
#include "background_gfx.h"
|
||||
#include "background_play_gfx.h"
|
||||
|
||||
// Audio
|
||||
#include "soundbank.h"
|
||||
@@ -23,14 +24,10 @@ void init()
|
||||
mmInitDefault((mm_addr)soundbank_bin, 12);
|
||||
mmStart(MOD_MAIN_THEME, MM_PLAY_LOOP);
|
||||
|
||||
// Initialize text engine
|
||||
tte_init_se(1, BG_CBB(1) | BG_SBB(31) | BG_8BPP, 0, CLR_WHITE, 11, NULL, NULL);
|
||||
tte_init_con();
|
||||
|
||||
// Set up the video mode
|
||||
REG_DISPCNT = DCNT_MODE0 | DCNT_OBJ_1D | DCNT_BG0 | DCNT_BG1 | DCNT_OBJ;
|
||||
REG_BG0CNT = BG_PRIO(1) | BG_CBB(0) | BG_SBB(30) | BG_8BPP | BG_REG_64x32;
|
||||
REG_BG1CNT = BG_PRIO(0) | BG_CBB(1) | BG_SBB(31) | BG_8BPP;
|
||||
REG_BG0CNT = BG_PRIO(1) | BG_CBB(0) | BG_SBB(30) | BG_8BPP | BG_REG_64x32;
|
||||
REG_BG1CNT = BG_PRIO(0) | BG_CBB(1) | BG_SBB(31) | BG_4BPP;
|
||||
|
||||
// Load the tiles and palette
|
||||
memcpy(pal_bg_mem, background_gfxPal, background_gfxPalLen);
|
||||
@@ -40,6 +37,15 @@ void init()
|
||||
memcpy(&tile_mem[4][0], deck_gfxTiles, deck_gfxTilesLen);
|
||||
memcpy(pal_obj_mem, deck_gfxPal, deck_gfxPalLen);
|
||||
|
||||
// Initialize text engine
|
||||
tte_init_se(1, BG_CBB(1) | BG_SBB(31), 0, CLR_WHITE, 11, NULL, NULL);
|
||||
tte_erase_screen();
|
||||
tte_init_con();
|
||||
|
||||
pal_bg_bank[1][12] = 0x029F; // honestly fuck libtonc because i cannot figure out how you're supposed to select a color from the palette index so i'm doing it like this
|
||||
pal_bg_bank[2][12] = pal_bg_bank[0][11];
|
||||
pal_bg_bank[3][12] = pal_bg_bank[0][2];
|
||||
|
||||
// Initialize subsystems
|
||||
sprite_init();
|
||||
card_init();
|
||||
|
||||
Reference in New Issue
Block a user