Making room for cursor, DRY'ing up code.

This commit is contained in:
Murilo Soares Pereira 2010-04-19 21:58:31 -03:00
parent 67f4775dc4
commit a7bcc8e5a7
3 changed files with 68 additions and 35 deletions

View File

@ -50,19 +50,58 @@ void draw_empty_stacks() {
empty_stack = malloc(EMPTY_STACKS_NUMBER * sizeof(**empty_stack));
empty_stack[0] = newwin(FRAME_HEIGHT, FRAME_WIDTH, 1, 1);
empty_stack[1] = newwin(FRAME_HEIGHT, FRAME_WIDTH, 1, 9);
empty_stack[2] = newwin(FRAME_HEIGHT, FRAME_WIDTH, 1, 25);
empty_stack[3] = newwin(FRAME_HEIGHT, FRAME_WIDTH, 1, 33);
empty_stack[4] = newwin(FRAME_HEIGHT, FRAME_WIDTH, 1, 41);
empty_stack[5] = newwin(FRAME_HEIGHT, FRAME_WIDTH, 1, 49);
empty_stack[6] = newwin(FRAME_HEIGHT, FRAME_WIDTH, 7, 1);
empty_stack[7] = newwin(FRAME_HEIGHT, FRAME_WIDTH, 7, 9);
empty_stack[8] = newwin(FRAME_HEIGHT, FRAME_WIDTH, 7, 17);
empty_stack[9] = newwin(FRAME_HEIGHT, FRAME_WIDTH, 7, 25);
empty_stack[10] = newwin(FRAME_HEIGHT, FRAME_WIDTH, 7, 33);
empty_stack[11] = newwin(FRAME_HEIGHT, FRAME_WIDTH, 7, 41);
empty_stack[12] = newwin(FRAME_HEIGHT, FRAME_WIDTH, 7, 49);
empty_stack[0] = newwin(FRAME_HEIGHT,
FRAME_WIDTH,
STOCK_STARTING_Y,
STOCK_STARTING_X);
empty_stack[1] = newwin(FRAME_HEIGHT,
FRAME_WIDTH,
WASTE_PILE_STARTING_Y,
WASTE_PILE_STARTING_X);
empty_stack[2] = newwin(FRAME_HEIGHT,
FRAME_WIDTH,
FOUNDATION_STARTING_Y,
FOUNDATION_0_STARTING_X);
empty_stack[3] = newwin(FRAME_HEIGHT,
FRAME_WIDTH,
FOUNDATION_STARTING_Y,
FOUNDATION_1_STARTING_X);
empty_stack[4] = newwin(FRAME_HEIGHT,
FRAME_WIDTH,
FOUNDATION_STARTING_Y,
FOUNDATION_2_STARTING_X);
empty_stack[5] = newwin(FRAME_HEIGHT,
FRAME_WIDTH,
FOUNDATION_STARTING_Y,
FOUNDATION_3_STARTING_X);
empty_stack[6] = newwin(FRAME_HEIGHT,
FRAME_WIDTH,
MANEUVRE_STARTING_Y,
MANEUVRE_0_STARTING_X);
empty_stack[7] = newwin(FRAME_HEIGHT,
FRAME_WIDTH,
MANEUVRE_STARTING_Y,
MANEUVRE_1_STARTING_X);
empty_stack[8] = newwin(FRAME_HEIGHT,
FRAME_WIDTH,
MANEUVRE_STARTING_Y,
MANEUVRE_2_STARTING_X);
empty_stack[9] = newwin(FRAME_HEIGHT,
FRAME_WIDTH,
MANEUVRE_STARTING_Y,
MANEUVRE_3_STARTING_X);
empty_stack[10] = newwin(FRAME_HEIGHT,
FRAME_WIDTH,
MANEUVRE_STARTING_Y,
MANEUVRE_4_STARTING_X);
empty_stack[11] = newwin(FRAME_HEIGHT,
FRAME_WIDTH,
MANEUVRE_STARTING_Y,
MANEUVRE_5_STARTING_X);
empty_stack[12] = newwin(FRAME_HEIGHT,
FRAME_WIDTH,
MANEUVRE_STARTING_Y,
MANEUVRE_6_STARTING_X);
for (int i = 0; i < EMPTY_STACKS_NUMBER; i++) {
box(empty_stack[i], 0, 0);

View File

@ -13,37 +13,37 @@ void set_stacks_coordinates(struct deck *deck) {
WASTE_PILE_STARTING_Y,
WASTE_PILE_STARTING_X);
set_frame(deck->foundation_0->card->frame,
FOUNDATION_0_STARTING_Y,
FOUNDATION_STARTING_Y,
FOUNDATION_0_STARTING_X);
set_frame(deck->foundation_1->card->frame,
FOUNDATION_1_STARTING_Y,
FOUNDATION_STARTING_Y,
FOUNDATION_1_STARTING_X);
set_frame(deck->foundation_2->card->frame,
FOUNDATION_2_STARTING_Y,
FOUNDATION_STARTING_Y,
FOUNDATION_2_STARTING_X);
set_frame(deck->foundation_3->card->frame,
FOUNDATION_3_STARTING_Y,
FOUNDATION_STARTING_Y,
FOUNDATION_3_STARTING_X);
set_frame(deck->maneuvre_0->card->frame,
MANEUVRE_0_STARTING_Y,
MANEUVRE_STARTING_Y,
MANEUVRE_0_STARTING_X);
set_frame(deck->maneuvre_1->card->frame,
MANEUVRE_1_STARTING_Y,
MANEUVRE_STARTING_Y,
MANEUVRE_1_STARTING_X);
set_frame(deck->maneuvre_2->card->frame,
MANEUVRE_2_STARTING_Y,
MANEUVRE_STARTING_Y,
MANEUVRE_2_STARTING_X);
set_frame(deck->maneuvre_3->card->frame,
MANEUVRE_3_STARTING_Y,
MANEUVRE_STARTING_Y,
MANEUVRE_3_STARTING_X);
set_frame(deck->maneuvre_4->card->frame,
MANEUVRE_4_STARTING_Y,
MANEUVRE_STARTING_Y,
MANEUVRE_4_STARTING_X);
set_frame(deck->maneuvre_5->card->frame,
MANEUVRE_5_STARTING_Y,
MANEUVRE_STARTING_Y,
MANEUVRE_5_STARTING_X);
set_frame(deck->maneuvre_6->card->frame,
MANEUVRE_6_STARTING_Y,
MANEUVRE_STARTING_Y,
MANEUVRE_6_STARTING_X);
return;

View File

@ -7,30 +7,24 @@
#define STOCK_STARTING_X 1
#define STOCK_STARTING_Y 1
#define WASTE_PILE_STARTING_X 9
#define WASTE_PILE_STARTING_Y 1
#define FOUNDATION_STARTING_Y 1
#define FOUNDATION_0_STARTING_X 25
#define FOUNDATION_0_STARTING_Y 1
#define FOUNDATION_1_STARTING_X 33
#define FOUNDATION_1_STARTING_Y 1
#define FOUNDATION_2_STARTING_X 41
#define FOUNDATION_2_STARTING_Y 1
#define FOUNDATION_3_STARTING_X 49
#define FOUNDATION_3_STARTING_Y 1
#define MANEUVRE_STARTING_Y 9
#define MANEUVRE_0_STARTING_X 1
#define MANEUVRE_0_STARTING_Y 7
#define MANEUVRE_1_STARTING_X 9
#define MANEUVRE_1_STARTING_Y 7
#define MANEUVRE_2_STARTING_X 17
#define MANEUVRE_2_STARTING_Y 7
#define MANEUVRE_3_STARTING_X 25
#define MANEUVRE_3_STARTING_Y 7
#define MANEUVRE_4_STARTING_X 33
#define MANEUVRE_4_STARTING_Y 7
#define MANEUVRE_5_STARTING_X 41
#define MANEUVRE_5_STARTING_Y 7
#define MANEUVRE_6_STARTING_X 49
#define MANEUVRE_6_STARTING_Y 7
void set_stacks_coordinates(struct deck *);
void fill_deck(struct deck *);