From b5721105b14b1384d2a0f2af0462823db483f4c5 Mon Sep 17 00:00:00 2001 From: Bill Rossi Date: Tue, 25 Feb 2025 05:29:50 -0500 Subject: [PATCH] Game works again --- card.c | 1 - game.c | 12 ++++-------- options.c | 1 + title.c | 4 +++- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/card.c b/card.c index f2cf3d3..1c417be 100644 --- a/card.c +++ b/card.c @@ -15,7 +15,6 @@ void draw_card(Card *c, Texture2D *cards_texture, int index) { Color color = index == 1 ? BLACK : BRICKRED; if (c->visible) { - printf("draw card %p\n", cards_texture); fflush(stdout); DrawTexturePro( *cards_texture, (Rectangle) { pos_horiz, pos_vert, CARD_WIDTH, CARD_HEIGHT }, diff --git a/game.c b/game.c index 12b2ebf..2e0b275 100644 --- a/game.c +++ b/game.c @@ -23,8 +23,6 @@ void initialize_game(Game *g) { g->cards_texture_black = LoadTextureFromImage(cards_image_black); UnloadImage(cards_image_black); - printf("%p %p\n", &g->cards_texture_black, &g->cards_texture_red); - g->deck.count = 0; g->deck.position = (Vector2) { 500, 300 }; g->deck.display_type = HAND_DISPLAY_DECK; @@ -85,11 +83,9 @@ void initialize_game(Game *g) { g->cards[i].order = i; g->cards[i].selected = false; g->cards[i].visible = false; - g->deck.count++; + g->deck.cards[g->deck.count++] = &g->cards[i]; } - printf("DONE CARDS\n"); - g->player.points = 100 * g->kan_value; g->right.points = 100 * g->kan_value; g->left.points = 100 * g->kan_value; @@ -873,7 +869,7 @@ void draw_cards(Game *g) { draw_player_cards(g, &g->left); for (int i = 0; i < g->field.count; i++) { draw_card(g->field.cards[i], cards_texture_fun(g), g->black_card_backs); - } + } for (int i = 0; i < g->deck.count; i++) { draw_card(g->deck.cards[i], cards_texture_fun(g), g->black_card_backs); @@ -890,14 +886,14 @@ void draw_frame(Game *g) { return; } - draw_cards(g); - if (g->state == GAME_STATE_OPTIONS) { options_draw(g); EndDrawing(); return; } + draw_cards(g); + if (g->state == GAME_STATE_DEALING) { DrawText("Dealing....", 60, 385, 40, BLACK); } else if (g->field_multiplier) { diff --git a/options.c b/options.c index 4f0962c..88e4384 100644 --- a/options.c +++ b/options.c @@ -1,3 +1,4 @@ +#include #include "options.h" int kan_value_from_index(int index) { return index == 0 ? 10 : 12; } diff --git a/title.c b/title.c index 2d0fab8..a9056ad 100644 --- a/title.c +++ b/title.c @@ -10,6 +10,9 @@ void initialize_title(Game *g) { } void title_handle_click_start(Game *g) { + for (int i = 0; i < 48; i++) { + g->cards[i].move.end_time = 0.; + } g->state = GAME_STATE_INITIALIZING; } @@ -108,7 +111,6 @@ void title_fly_card(Game *g, Card *card) { move->current_time = 0.; move->end_time = (rand() % 5) + 1; - printf("current: %f, end: %f\n", card->move.current_time, card->move.end_time); } void run_frame_title(Game *g) {