From a8c98d47561a70e3395c584a658fe33882f75f7a Mon Sep 17 00:00:00 2001 From: Murilo Pereira Date: Sun, 6 Feb 2011 00:15:21 -0200 Subject: [PATCH] Moving cursor declaration to the game file. * Also moving some functions around. --- lib/game.c | 27 ++++++++++++++------------- lib/game.h | 3 ++- lib/keyboard.c | 1 - src/tty-solitaire.c | 7 ++----- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/lib/game.c b/lib/game.c index 2693b09..91b2409 100644 --- a/lib/game.c +++ b/lib/game.c @@ -195,21 +195,22 @@ void greet_player() { 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() { 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); return; diff --git a/lib/game.h b/lib/game.h index c2c26fb..078b250 100644 --- a/lib/game.h +++ b/lib/game.h @@ -2,6 +2,7 @@ #define GAME_H #include "deck.h" +#include "cursor.h" #define NUMBER_OF_CARDS 52 @@ -27,6 +28,7 @@ #define MANEUVRE_6_STARTING_X 49 struct deck *deck; +struct cursor *cursor; void set_stacks_coordinates(struct deck *); void fill_deck(struct deck *); @@ -34,7 +36,6 @@ void shuffle_deck(struct deck *); void deal_cards(struct deck *); void greet_player(); void initialize_game(); -void prepare_game(struct deck **); void end_game(); #endif diff --git a/lib/keyboard.c b/lib/keyboard.c index 279c34b..a174435 100644 --- a/lib/keyboard.c +++ b/lib/keyboard.c @@ -3,7 +3,6 @@ #include "keyboard.h" void mark_origin(struct cursor *cursor) { - return; } diff --git a/src/tty-solitaire.c b/src/tty-solitaire.c index 747a248..ca368db 100644 --- a/src/tty-solitaire.c +++ b/src/tty-solitaire.c @@ -5,10 +5,10 @@ #include "../lib/keyboard.h" extern struct deck *deck; +extern struct cursor *cursor; int main(int argc, const char *argv[]) { int option; - struct cursor *cursor; initialize_curses(); @@ -21,15 +21,12 @@ int main(int argc, const char *argv[]) { break; case 'q': case 'Q': + end_game(); end_curses(); exit(0); } } - allocate_cursor(&cursor); - initialize_cursor(cursor); - draw_cursor(cursor); - while (1) { switch (option = getch()) { case 'h':