-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.c
80 lines (73 loc) · 2.22 KB
/
map.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Filler.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mvolkov <mvolkov@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/01/05 17:02:54 by mvolkov #+# #+# */
/* Updated: 2018/07/22 19:57:54 by dskrypny ### ########.fr */
/* */
/* ************************************************************************** */
#include "header.h"
void update_map(WINDOW *win_info, WINDOW *win_champs)
{
int x;
int y;
wclear(win_info);
wclear(win_champs);
getmaxyx(stdscr, y, x);
wresize(win_info, INFO_HEIGHT, x - 1);
wresize(win_champs, y - INFO_HEIGHT, CHAMPS_WIDTH);
box(win_info, 0, 0);
box(win_champs, 0, 0);
wrefresh(win_info);
wrefresh(win_champs);
}
static void print_lines(WINDOW *win, int y, int x, int count)
{
while (count < (x - 1))
{
mvwprintw(win, 0, count, "-");
mvwprintw(win, (y - 5) / 4, count, "-");
mvwprintw(win, ((y - 5) / 4) * 2, count, "-");
mvwprintw(win, ((y - 5) / 4) * 3, count, "-");
mvwprintw(win, y - 5, count, "-");
count++;
}
}
static void print_rows(WINDOW *win, int y, int x, int count)
{
while (count < (y - 1))
{
mvwprintw(win, count, 0, "|");
mvwprintw(win, count, (x - CHAMPS_WIDTH) / 4, "|");
mvwprintw(win, count, ((x - CHAMPS_WIDTH) / 4) * 2, "|");
mvwprintw(win, count, ((x - CHAMPS_WIDTH) / 4) * 3, "|");
mvwprintw(win, count, x - CHAMPS_WIDTH - 1, "|");
count++;
}
}
void draw_map(WINDOW *win)
{
int x;
int y;
int count;
getmaxyx(stdscr, y, x);
wclear(win);
if (y < 18 || x < 65)
{
clear();
mvprintw(0, 0, "too small");
while (y < 18 || x < 65)
{
refresh();
getmaxyx(stdscr, y, x);
}
clear();
}
count = 0;
print_lines(win, y, x, count);
print_rows(win, y, x, count);
wrefresh(win);
}