X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;f=src%2Fclient%2Fmap.c;fp=src%2Fclient%2Fmap.c;h=a41903906dcc012bfedfbae7e1c71f6917664d85;hb=e03020342a74aef143b1ec38c18966dac64181b5;hp=0000000000000000000000000000000000000000;hpb=0255432b4e8d3a7b3aec71c4e43e7fb063c45833;p=plomrogue diff --git a/src/client/map.c b/src/client/map.c new file mode 100644 index 0000000..a419039 --- /dev/null +++ b/src/client/map.c @@ -0,0 +1,47 @@ +/* src/client/map.c */ + +#include "map.h" +#include /* uint16_t */ +#include "misc.h" /* center_offset() */ +#include "windows.h" /* struct Win, get_win_by_id() */ +#include "world.h" /* for global world */ + + + +extern void map_scroll(char d) +{ + struct Win * win = get_win_by_id('m'); + uint16_t offset; + if (('8' == d || '2' == d) && world.map.size.y > win->frame_size.y) + { + offset = center_offset(win->center.y, + world.map.size.y, win->frame_size.y); + win->center.y = offset + (win->frame_size.y / 2); + if ('2' == d && win->center.y < world.map.size.y - 1) + { + win->center.y++; + return; + } + win->center.y = win->center.y - ('8' == d && win->center.y > 0); + } + else if (('4' == d || '6' == d) && world.map.size.x > win->frame_size.x) + { + offset = center_offset(win->center.x, + world.map.size.x, win->frame_size.x); + win->center.x = offset + (win->frame_size.x / 2); + if ('6' == d && win->center.x < world.map.size.x - 1) + { + win->center.x++; + return; + } + win->center.x = win->center.x - ('4' == d && win->center.x > 0); + } +} + + + +extern void map_center() +{ + struct Win * win_map = get_win_by_id('m'); + win_map->center = world.player_pos; +}