Compare commits
	
		
			No commits in common. "ec9d0e500719d694a9d67d991bfad6ad9a52316b" and "08c5c086690e2cc5ebe4eb1ab2193314c82c370b" have entirely different histories.
		
	
	
		
			ec9d0e5007
			...
			08c5c08669
		
	
		
							
								
								
									
										20
									
								
								card.c
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								card.c
									
									
									
									
									
								
							@ -44,15 +44,6 @@ void shuffle_hand(Hand *h) {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void remove_from_hand(Hand *h, Card *c) {
 | 
			
		||||
  bool card_found = false;
 | 
			
		||||
  for (int i = 0; i < h->count - 1; i++) {
 | 
			
		||||
    if (h->cards[i] == c) card_found = true;
 | 
			
		||||
    h->cards[i] = h->cards[i + 1];
 | 
			
		||||
  }
 | 
			
		||||
  h->count--;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void add_to_hand(Hand *h, Card *c) {
 | 
			
		||||
  h->cards[h->count] = c;
 | 
			
		||||
 | 
			
		||||
@ -71,7 +62,7 @@ void add_to_hand(Hand *h, Card *c) {
 | 
			
		||||
  }
 | 
			
		||||
  c->move.curve = CURVE_EASE_IN_OUT;
 | 
			
		||||
  c->move.current_time = 0.;
 | 
			
		||||
  c->move.end_time = 0.1;
 | 
			
		||||
  c->move.end_time = 0.5;
 | 
			
		||||
 | 
			
		||||
  h->count++;
 | 
			
		||||
}
 | 
			
		||||
@ -88,12 +79,3 @@ void deal(Hand *from, Hand *to, int count, bool up) {
 | 
			
		||||
    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
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								card.h
									
									
									
									
									
								
							@ -75,6 +75,5 @@ bool point_within_card(Card *c, Vector2 v);
 | 
			
		||||
void shuffle_hand(Hand *h);
 | 
			
		||||
void deal(Hand *from, Hand *to, int count, bool up);
 | 
			
		||||
bool card_done_moving(Card *c);
 | 
			
		||||
Rectangle next_card_position(Hand *h);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										111
									
								
								game.c
									
									
									
									
									
								
							
							
						
						
									
										111
									
								
								game.c
									
									
									
									
									
								
							@ -6,7 +6,6 @@
 | 
			
		||||
#include "teyaku.h"
 | 
			
		||||
#include "dekiyaku.h"
 | 
			
		||||
#include "field_multiplier.h"
 | 
			
		||||
#include "play.h"
 | 
			
		||||
 | 
			
		||||
Vector2 mouse_pos;
 | 
			
		||||
char teyaku_calculation[400];
 | 
			
		||||
@ -76,15 +75,6 @@ void initialize_game(Game *g) {
 | 
			
		||||
  g->field.count = 0;
 | 
			
		||||
  g->field.position = (Vector2) { 400, 300 };
 | 
			
		||||
  g->field.display_type = HAND_DISPLAY_FIELD;
 | 
			
		||||
  g->player_scored.count = 0;
 | 
			
		||||
  g->player_scored.position = (Vector2) { 300, 750 };
 | 
			
		||||
  g->player_scored.display_type = HAND_DISPLAY_ROW;
 | 
			
		||||
  g->right_scored.count = 0;
 | 
			
		||||
  g->right_scored.position = (Vector2) { 50, 25 };
 | 
			
		||||
  g->right_scored.display_type = HAND_DISPLAY_ROW;
 | 
			
		||||
  g->left_scored.count = 0;
 | 
			
		||||
  g->left_scored.position = (Vector2) { 750, 25 };
 | 
			
		||||
  g->left_scored.display_type = HAND_DISPLAY_ROW;
 | 
			
		||||
 | 
			
		||||
  strcpy(teyaku_calculation, "");
 | 
			
		||||
 | 
			
		||||
@ -102,65 +92,13 @@ void handle_input(Game *g) {
 | 
			
		||||
      mouse_pos = GetMousePosition();
 | 
			
		||||
      for (int i = 0; i < g->player_hand.count; i++) {
 | 
			
		||||
	if (point_within_card(g->player_hand.cards[i], mouse_pos)) {
 | 
			
		||||
	  for (int j = 0; j < 48; j++) {
 | 
			
		||||
	    g->cards[j].selected = false;
 | 
			
		||||
	  }
 | 
			
		||||
	  g->player_hand.cards[i]->selected = true;
 | 
			
		||||
	  // g->selected_card = g->player_hand.cards[i];
 | 
			
		||||
	  break;
 | 
			
		||||
	}
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    break;
 | 
			
		||||
  case GAME_STATE_PLAYER_CHOOSING_TARGET:
 | 
			
		||||
    if (IsMouseButtonPressed(0)) {
 | 
			
		||||
      mouse_pos = GetMousePosition();
 | 
			
		||||
      bool clicked_hand_card = false;
 | 
			
		||||
      for (int i = 0; i < g->player_hand.count; i++) {
 | 
			
		||||
	if (point_within_card(g->player_hand.cards[i], mouse_pos)) {
 | 
			
		||||
	  clicked_hand_card = true;
 | 
			
		||||
	  if (g->player_hand.cards[i]->selected) {
 | 
			
		||||
	    g->player_hand.cards[i]->selected = false;
 | 
			
		||||
	  } else {
 | 
			
		||||
	    for (int j = 0; j < g->player_hand.count; j++) {
 | 
			
		||||
	      g->player_hand.cards[j]->selected = false;
 | 
			
		||||
	    }
 | 
			
		||||
	    g->player_hand.cards[i]->selected = true;
 | 
			
		||||
	  }
 | 
			
		||||
	}
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      Card *selected_card = NULL;
 | 
			
		||||
      for (int i = 0; i < g->player_hand.count; i++) {
 | 
			
		||||
	if (g->player_hand.cards[i]->selected) {
 | 
			
		||||
	  selected_card = g->player_hand.cards[i];
 | 
			
		||||
	  break;
 | 
			
		||||
	}
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      for (int i = 0; i < g->field.count; i++) {
 | 
			
		||||
	if (point_within_card(g->field.cards[i], mouse_pos)) {
 | 
			
		||||
	  if (selected_card == NULL) printf("No card selected, whoops");
 | 
			
		||||
	  if (valid_play(&g->field, selected_card, g->field.cards[i])) {
 | 
			
		||||
	    g->current_play_from_hand = selected_card;
 | 
			
		||||
	    g->current_play_target = g->field.cards[i];
 | 
			
		||||
	    printf("Valid\n");
 | 
			
		||||
	    break;
 | 
			
		||||
	  } else {
 | 
			
		||||
	    printf("Invalid\n");
 | 
			
		||||
	  }
 | 
			
		||||
	}
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (CheckCollisionPointRec(mouse_pos, next_card_position(&g->field))) {
 | 
			
		||||
	if (valid_play(&g->field, selected_card, NULL)) {
 | 
			
		||||
	  g->current_play_from_hand = selected_card;
 | 
			
		||||
	  g->current_play_target = NULL;
 | 
			
		||||
	  printf("Valid\n");
 | 
			
		||||
	} else {
 | 
			
		||||
	  printf("Invalid\n");
 | 
			
		||||
	}
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    break;
 | 
			
		||||
  default:
 | 
			
		||||
    break;
 | 
			
		||||
@ -196,53 +134,13 @@ void run_frame_calculating_field_multiplier(Game *g) {
 | 
			
		||||
 | 
			
		||||
void run_frame_calculating_teyaku(Game *g) {
 | 
			
		||||
  calculate_teyaku(g->player_hand, &g->player_teyaku);
 | 
			
		||||
  for (int i = 0; i < 48; i++) {
 | 
			
		||||
    g->cards[i].selected = false;
 | 
			
		||||
  }
 | 
			
		||||
  // g->selected_card = NULL;
 | 
			
		||||
  g->state = GAME_STATE_PLAYER_CHOOSING_FROM_HAND;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void run_frame_player_choosing_from_hand(Game *g) {
 | 
			
		||||
  for (int i = 0; i < g->player_hand.count; i++) {
 | 
			
		||||
    if (g->player_hand.cards[i]->selected) {
 | 
			
		||||
      g->state = GAME_STATE_PLAYER_CHOOSING_TARGET;
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void run_frame_player_choosing_target(Game *g) {
 | 
			
		||||
  bool no_cards_selected = true;
 | 
			
		||||
  for (int i = 0; i < g->player_hand.count; i++) {
 | 
			
		||||
    if (g->player_hand.cards[i]->selected) {
 | 
			
		||||
      no_cards_selected = false;
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (no_cards_selected) {
 | 
			
		||||
    g->state = GAME_STATE_PLAYER_CHOOSING_FROM_HAND;
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (g->current_play_from_hand) {
 | 
			
		||||
    if (g->current_play_target) {
 | 
			
		||||
      g->current_play_from_hand->selected = false;
 | 
			
		||||
      remove_from_hand(&g->player_hand, g->current_play_from_hand);
 | 
			
		||||
      add_to_hand(&g->player_scored, g->current_play_from_hand);
 | 
			
		||||
      remove_from_hand(&g->field, g->current_play_target);
 | 
			
		||||
      add_to_hand(&g->player_scored, g->current_play_target);
 | 
			
		||||
      g->current_play_from_hand = NULL;
 | 
			
		||||
      g->current_play_target = NULL;
 | 
			
		||||
    } else {
 | 
			
		||||
      g->current_play_from_hand->selected = false;
 | 
			
		||||
      remove_from_hand(&g->player_hand, g->current_play_from_hand);
 | 
			
		||||
      add_to_hand(&g->field, g->current_play_from_hand);
 | 
			
		||||
      g->current_play_from_hand = NULL;
 | 
			
		||||
    }
 | 
			
		||||
    g->state = GAME_STATE_INITIALIZING;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void run_frame(Game *g) {
 | 
			
		||||
@ -293,11 +191,10 @@ void draw_frame(Game *g) {
 | 
			
		||||
 | 
			
		||||
  switch (g->state) {
 | 
			
		||||
  case GAME_STATE_PLAYER_CHOOSING_FROM_HAND:
 | 
			
		||||
    DrawText("Choose a card to play", 60, 485, 20, BLACK);
 | 
			
		||||
    DrawText("Choose a card to play", 60, 485, 40, BLACK);
 | 
			
		||||
    break;
 | 
			
		||||
  case GAME_STATE_PLAYER_CHOOSING_TARGET:
 | 
			
		||||
    DrawText("Choose a target on the field", 60, 485, 20, BLACK);
 | 
			
		||||
    DrawRectangleRec(next_card_position(&g->field), BLUE);
 | 
			
		||||
    DrawText("Choose a target on the field", 60, 485, 40, BLACK);
 | 
			
		||||
    break;
 | 
			
		||||
  default:
 | 
			
		||||
    break;
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										5
									
								
								game.h
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								game.h
									
									
									
									
									
								
							@ -23,12 +23,9 @@ struct Game {
 | 
			
		||||
  bool should_close;
 | 
			
		||||
  Card cards[48];
 | 
			
		||||
  Texture2D cards_texture;
 | 
			
		||||
  Hand player_hand, left_hand, right_hand;
 | 
			
		||||
  Hand deck, field;
 | 
			
		||||
  Hand player_scored, left_scored, right_scored;
 | 
			
		||||
  Hand player_hand, left_hand, right_hand, deck, field;
 | 
			
		||||
  FieldMultiplier *field_multiplier;
 | 
			
		||||
  Teyaku player_teyaku, left_teyaku, right_teyaku;
 | 
			
		||||
  Card *current_play_from_hand, *current_play_target;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void initialize_game(Game *g);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								play.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								play.c
									
									
									
									
									
								
							@ -6,7 +6,7 @@ bool valid_play(Hand *field, Card *played, Card *target) {
 | 
			
		||||
  if (target == NULL) {
 | 
			
		||||
    bool matching_month_in_field = false;
 | 
			
		||||
    for (int i = 0; i < field->count; i++) {
 | 
			
		||||
      if (field->cards[i]->month == played->month) {
 | 
			
		||||
      if (field->cards[i]->month == target->month) {
 | 
			
		||||
	matching_month_in_field = true;
 | 
			
		||||
	break;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user