Draw a target for playing a nonmatching card

This commit is contained in:
Bill Rossi 2025-02-08 07:33:23 -05:00
parent 028da65317
commit 3bac02c752
3 changed files with 14 additions and 3 deletions

11
card.c
View File

@ -62,7 +62,7 @@ void add_to_hand(Hand *h, Card *c) {
} }
c->move.curve = CURVE_EASE_IN_OUT; c->move.curve = CURVE_EASE_IN_OUT;
c->move.current_time = 0.; c->move.current_time = 0.;
c->move.end_time = 0.5; c->move.end_time = 0.1;
h->count++; h->count++;
} }
@ -79,3 +79,12 @@ void deal(Hand *from, Hand *to, int count, bool up) {
from->count--; from->count--;
} }
} }
Rectangle next_card_position(Hand *h) {
return (Rectangle) {
h->position.x + ((h->count / 2) * (CARD_WIDTH + 10)),
h->position.y + (h->count % 2 * (CARD_HEIGHT + 10)),
CARD_WIDTH,
CARD_HEIGHT
};
}

1
card.h
View File

@ -75,5 +75,6 @@ bool point_within_card(Card *c, Vector2 v);
void shuffle_hand(Hand *h); void shuffle_hand(Hand *h);
void deal(Hand *from, Hand *to, int count, bool up); void deal(Hand *from, Hand *to, int count, bool up);
bool card_done_moving(Card *c); bool card_done_moving(Card *c);
Rectangle next_card_position(Hand *h);
#endif #endif

5
game.c
View File

@ -231,10 +231,11 @@ void draw_frame(Game *g) {
switch (g->state) { switch (g->state) {
case GAME_STATE_PLAYER_CHOOSING_FROM_HAND: case GAME_STATE_PLAYER_CHOOSING_FROM_HAND:
DrawText("Choose a card to play", 60, 485, 40, BLACK); DrawText("Choose a card to play", 60, 485, 20, BLACK);
break; break;
case GAME_STATE_PLAYER_CHOOSING_TARGET: case GAME_STATE_PLAYER_CHOOSING_TARGET:
DrawText("Choose a target on the field", 60, 485, 40, BLACK); DrawText("Choose a target on the field", 60, 485, 20, BLACK);
DrawRectangleRec(next_card_position(&g->field), BLUE);
break; break;
default: default:
break; break;