Draw cards in the correct order so they don't overlap
This commit is contained in:
parent
881e3928f9
commit
2651157b3a
43
game.c
43
game.c
@ -79,6 +79,17 @@ void initialize_game(Game *g) {
|
|||||||
g->right.points_string[0] = '\0';
|
g->right.points_string[0] = '\0';
|
||||||
g->left.points_string[0] = '\0';
|
g->left.points_string[0] = '\0';
|
||||||
|
|
||||||
|
g->player.hand.count = 0;
|
||||||
|
g->right.hand.count = 0;
|
||||||
|
g->left.hand.count = 0;
|
||||||
|
g->field.count = 0;
|
||||||
|
g->player.scored.count = 0;
|
||||||
|
g->right.scored.count = 0;
|
||||||
|
g->left.scored.count = 0;
|
||||||
|
g->player.dekiyaku_score = 0;
|
||||||
|
g->left.dekiyaku_score = 0;
|
||||||
|
g->right.dekiyaku_score = 0;
|
||||||
|
|
||||||
g->player.teyaku.calculated = false;
|
g->player.teyaku.calculated = false;
|
||||||
g->right.teyaku.calculated = false;
|
g->right.teyaku.calculated = false;
|
||||||
g->left.teyaku.calculated = false;
|
g->left.teyaku.calculated = false;
|
||||||
@ -302,12 +313,12 @@ bool misdeal(Game *g) {
|
|||||||
|
|
||||||
void run_frame_dealing(Game *g) {
|
void run_frame_dealing(Game *g) {
|
||||||
if (current_player(g)->hand.count < 4) {
|
if (current_player(g)->hand.count < 4) {
|
||||||
deal(&g->deck, ¤t_player(g)->hand, 4, true);
|
deal(&g->deck, ¤t_player(g)->hand, 4, is_player_turn(g));
|
||||||
g->turn_number++;
|
g->turn_number++;
|
||||||
} else if (g->field.count < 3) {
|
} else if (g->field.count < 3) {
|
||||||
deal(&g->deck, &g->field, 3, true);
|
deal(&g->deck, &g->field, 3, true);
|
||||||
} else if (current_player(g)->hand.count < 7) {
|
} else if (current_player(g)->hand.count < 7) {
|
||||||
deal(&g->deck, ¤t_player(g)->hand, 3, true);
|
deal(&g->deck, ¤t_player(g)->hand, 3, is_player_turn(g));
|
||||||
g->turn_number++;
|
g->turn_number++;
|
||||||
} else if (g->field.count < 6) {
|
} else if (g->field.count < 6) {
|
||||||
deal(&g->deck, &g->field, 3, true);
|
deal(&g->deck, &g->field, 3, true);
|
||||||
@ -596,12 +607,34 @@ void run_frame(Game *g) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void draw_player_cards(Game *g, Player *p) {
|
||||||
|
for (int i = 0; i < p->hand.count; i++) {
|
||||||
|
draw_card(p->hand.cards[i], &g->cards_texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < p->scored.count; i++) {
|
||||||
|
draw_card(p->scored.cards[i], &g->cards_texture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_cards(Game *g) {
|
||||||
|
draw_player_cards(g, &g->player);
|
||||||
|
draw_player_cards(g, &g->right);
|
||||||
|
draw_player_cards(g, &g->left);
|
||||||
|
for (int i = 0; i < g->field.count; i++) {
|
||||||
|
draw_card(g->field.cards[i], &g->cards_texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < g->deck.count; i++) {
|
||||||
|
draw_card(g->deck.cards[i], &g->cards_texture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void draw_frame(Game *g) {
|
void draw_frame(Game *g) {
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
for (int i = 0; i < 48; i++) {
|
|
||||||
draw_card(&g->cards[i], &g->cards_texture);
|
draw_cards(g);
|
||||||
}
|
|
||||||
|
|
||||||
if (g->field_multiplier) DrawText(g->field_multiplier->name, 60, 385, 40, BLACK);
|
if (g->field_multiplier) DrawText(g->field_multiplier->name, 60, 385, 40, BLACK);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user