int turn;
char * log;
struct Map * map;
+ struct Monster * monster;
struct Player * player; };
struct KeyBinding {
int y;
int x; };
+struct Monster {
+ int y;
+ int x; };
+
void draw_with_linebreaks (struct Win *, char *, int);
void draw_text_from_bottom (struct Win *, char *);
void draw_log (struct Win *);
struct World * world = (struct World *) win->data;
struct Map * map = world->map;
struct Player * player = world->player;
+ struct Monster * monster = world->monster;
char * cells = map->cells;
int width_map_av = map->width - map->offset_x;
int height_map_av = map->height - map->offset_y;
if (y < height_map_av && x < width_map_av) {
if (z == (map->width * player->y) + player->x)
mvwaddch(win->curses, y, x, '@');
+ else if (z == (map->width * monster->y) + monster->x)
+ mvwaddch(win->curses, y, x, 'M');
else
mvwaddch(win->curses, y, x, cells[z]);
z++; } } } }
// Check if coordinate on (or beyond) map is accessible to movement.
char passable = 0;
if (0 <= x && x < world->map->width && 0 <= y && y < world->map->height)
- if ('.' == world->map->cells[y * world->map->width + x])
+ if ( '.' == world->map->cells[y * world->map->width + x]
+ && (y != world->monster->y || x != world->monster->x))
passable = 1;
return passable; }
struct Map map = init_map();
world.map = ↦
struct Player player;
- player.y = 10;
- player.x = 10;
+ player.y = 16;
+ player.x = 16;
world.player = &player;
+ struct Monster monster;
+ monster.y = 16;
+ monster.x = 80;
+ world.monster = &monster;
WINDOW * screen = initscr();
noecho();