home · contact · privacy
MAJOR re-write. Split plomrogue into a server and a client. Re-wrote large parts
[plomrogue] / src / client / map_window.c
1 /* src/client/map_window.c */
2
3 #include "map_window.h"
4 #include <stdint.h> /* uint16_t */
5 #include "misc.h" /* center_offset() */
6 #include "wincontrol.h" /* get_win_by_id() */
7 #include "windows.h" /* struct Win */
8 #include "world.h" /* for global world */
9
10
11
12 extern void map_scroll(char d)
13 {
14     struct Win * win = get_win_by_id('m');
15     uint16_t offset;
16     if (('N' == d || 'S' == d) && world.map.size.y > win->framesize.y)
17     {
18         offset = center_offset(win->center.y,
19                                world.map.size.y, win->framesize.y);
20         win->center.y = offset + (win->framesize.y / 2);
21         if ('S' == d && win->center.y < world.map.size.y - 1)
22         {
23             win->center.y++;
24             return;
25         }
26         win->center.y = win->center.y - ('N' == d && win->center.y > 0);
27     }
28     else if (('W' == d || 'E' == d) && world.map.size.x > win->framesize.x)
29     {
30         offset = center_offset(win->center.x,
31                                world.map.size.x, win->framesize.x);
32         win->center.x = offset + (win->framesize.x / 2);
33         if ('E' == d && win->center.x < world.map.size.x - 1)
34         {
35             win->center.x++;
36             return;
37         }
38         win->center.x = win->center.x - ('W' == d && win->center.x > 0);
39     }
40 }
41
42
43
44 extern void map_center()
45 {
46     struct Win * win_map = get_win_by_id('m');
47     win_map->center = world.player_pos;
48 }