Moving cursor declaration to the game file.
* Also moving some functions around.
This commit is contained in:
		
							parent
							
								
									58fff35a20
								
							
						
					
					
						commit
						a8c98d4756
					
				
							
								
								
									
										27
									
								
								lib/game.c
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								lib/game.c
									
									
									
									
									
								
							@ -195,21 +195,22 @@ void greet_player() {
 | 
				
			|||||||
  return;
 | 
					  return;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void prepare_game(struct deck **deck) {
 | 
					 | 
				
			||||||
  draw_empty_stacks();
 | 
					 | 
				
			||||||
  allocate_deck(deck);
 | 
					 | 
				
			||||||
  initialize_deck(*deck);
 | 
					 | 
				
			||||||
  set_stacks_coordinates(*deck);
 | 
					 | 
				
			||||||
  fill_deck(*deck);
 | 
					 | 
				
			||||||
  shuffle_deck(*deck);
 | 
					 | 
				
			||||||
  deal_cards(*deck);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  return;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void initialize_game() {
 | 
					void initialize_game() {
 | 
				
			||||||
  clear_screen();
 | 
					  clear_screen();
 | 
				
			||||||
  prepare_game(&deck);
 | 
					
 | 
				
			||||||
 | 
					  allocate_cursor(&cursor);
 | 
				
			||||||
 | 
					  initialize_cursor(cursor);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  allocate_deck(&deck);
 | 
				
			||||||
 | 
					  initialize_deck(deck);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  set_stacks_coordinates(deck);
 | 
				
			||||||
 | 
					  fill_deck(deck);
 | 
				
			||||||
 | 
					  shuffle_deck(deck);
 | 
				
			||||||
 | 
					  deal_cards(deck);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  draw_empty_stacks();
 | 
				
			||||||
 | 
					  draw_cursor(cursor);
 | 
				
			||||||
  draw_game(deck);
 | 
					  draw_game(deck);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return;
 | 
					  return;
 | 
				
			||||||
 | 
				
			|||||||
@ -2,6 +2,7 @@
 | 
				
			|||||||
#define GAME_H
 | 
					#define GAME_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "deck.h"
 | 
					#include "deck.h"
 | 
				
			||||||
 | 
					#include "cursor.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define NUMBER_OF_CARDS 52
 | 
					#define NUMBER_OF_CARDS 52
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -27,6 +28,7 @@
 | 
				
			|||||||
#define MANEUVRE_6_STARTING_X   49
 | 
					#define MANEUVRE_6_STARTING_X   49
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct deck *deck;
 | 
					struct deck *deck;
 | 
				
			||||||
 | 
					struct cursor *cursor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void set_stacks_coordinates(struct deck *);
 | 
					void set_stacks_coordinates(struct deck *);
 | 
				
			||||||
void fill_deck(struct deck *);
 | 
					void fill_deck(struct deck *);
 | 
				
			||||||
@ -34,7 +36,6 @@ void shuffle_deck(struct deck *);
 | 
				
			|||||||
void deal_cards(struct deck *);
 | 
					void deal_cards(struct deck *);
 | 
				
			||||||
void greet_player();
 | 
					void greet_player();
 | 
				
			||||||
void initialize_game();
 | 
					void initialize_game();
 | 
				
			||||||
void prepare_game(struct deck **);
 | 
					 | 
				
			||||||
void end_game();
 | 
					void end_game();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -3,7 +3,6 @@
 | 
				
			|||||||
#include "keyboard.h"
 | 
					#include "keyboard.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void mark_origin(struct cursor *cursor) {
 | 
					void mark_origin(struct cursor *cursor) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
  return;
 | 
					  return;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -5,10 +5,10 @@
 | 
				
			|||||||
#include "../lib/keyboard.h"
 | 
					#include "../lib/keyboard.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern struct deck *deck;
 | 
					extern struct deck *deck;
 | 
				
			||||||
 | 
					extern struct cursor *cursor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, const char *argv[]) {
 | 
					int main(int argc, const char *argv[]) {
 | 
				
			||||||
  int option;
 | 
					  int option;
 | 
				
			||||||
  struct cursor *cursor;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  initialize_curses();
 | 
					  initialize_curses();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -21,15 +21,12 @@ int main(int argc, const char *argv[]) {
 | 
				
			|||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case 'q':
 | 
					      case 'q':
 | 
				
			||||||
      case 'Q':
 | 
					      case 'Q':
 | 
				
			||||||
 | 
					        end_game();
 | 
				
			||||||
        end_curses();
 | 
					        end_curses();
 | 
				
			||||||
        exit(0);
 | 
					        exit(0);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  allocate_cursor(&cursor);
 | 
					 | 
				
			||||||
  initialize_cursor(cursor);
 | 
					 | 
				
			||||||
  draw_cursor(cursor);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  while (1) {
 | 
					  while (1) {
 | 
				
			||||||
    switch (option = getch()) {
 | 
					    switch (option = getch()) {
 | 
				
			||||||
      case 'h':
 | 
					      case 'h':
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user