1 /* src/client/map_window.c */
3 #include "map_window.h"
4 #include <stdint.h> /* uint16_t */
5 #include "misc.h" /* center_offset() */
6 #include "windows.h" /* struct Win, get_win_by_id() */
7 #include "world.h" /* for global world */
11 extern void map_scroll(char d)
13 struct Win * win = get_win_by_id('m');
15 if (('N' == d || 'S' == d) && world.map.size.y > win->frame_size.y)
17 offset = center_offset(win->center.y,
18 world.map.size.y, win->frame_size.y);
19 win->center.y = offset + (win->frame_size.y / 2);
20 if ('S' == d && win->center.y < world.map.size.y - 1)
25 win->center.y = win->center.y - ('N' == d && win->center.y > 0);
27 else if (('W' == d || 'E' == d) && world.map.size.x > win->frame_size.x)
29 offset = center_offset(win->center.x,
30 world.map.size.x, win->frame_size.x);
31 win->center.x = offset + (win->frame_size.x / 2);
32 if ('E' == d && win->center.x < world.map.size.x - 1)
37 win->center.x = win->center.x - ('W' == d && win->center.x > 0);
43 extern void map_center()
45 struct Win * win_map = get_win_by_id('m');
46 win_map->center = world.player_pos;