home · contact · privacy
Rewrote update_log () for a comeback of the message repition compression feature...
[plomrogue] / src / actors.c
index 288bb49d1efa2ad6097edf1b65dd12be1e1a4a4a..ca1305ce6540dc636e6a6e42b854be2b30542068 100644 (file)
@@ -1,14 +1,14 @@
-#include "stdlib.h"
-#include "stdint.h"
+#include "actors.h"
+#include <stdlib.h>
+#include <stdio.h>
 #include "yx_uint16.h"
 #include "roguelike.h"
-#include "actors.h"
 
-extern char is_passable (struct Map * map, uint16_t y, uint16_t x) {
+extern char is_passable (struct Map * map, struct yx_uint16 pos) {
 // Check if coordinate on (or beyond) map is accessible to actor movement.
   char passable = 0;
-  if (0 <= x && x < map->size.x && 0 <= y && y < map->size.y)
-    if ('.' == map->cells[y * map->size.x + x])
+  if (0 <= pos.x && pos.x < map->size.x && 0 <= pos.y && pos.y < map->size.y)
+    if ('.' == map->cells[pos.y * map->size.x + pos.x])
       passable = 1;
   return passable; }
 
@@ -26,11 +26,11 @@ extern void move_monster (struct World * world, struct Monster * monster) {
     if (yx_uint16_cmp (t, other_monster->pos)) {
       update_log (world, "\nMonster hits monster.");
       return; } }
-  if (is_passable(world->map, t.y, t.x))
+  if (is_passable(world->map, t))
     monster->pos = t; }
 
 extern void move_player (struct World * world, char d) {
-// Move player in direction d, increment turn counter and update log.
+// Move player in direction d, update log and turn over to the enemy.
   struct yx_uint16 t = mv_yx_in_dir (d, world->player->pos);
   struct Monster * monster;
   for (monster = world->monster; monster != 0; monster = monster->next)
@@ -45,7 +45,7 @@ extern void move_player (struct World * world, char d) {
   else if (EAST  == d) dir = "east" ;
   else if (SOUTH == d) dir = "south";
   else if (WEST  == d) dir = "west" ;
-  if (is_passable(world->map, t.y, t.x)) {
+  if (is_passable(world->map, t)) {
     msg_content = "You move";
     world->player->pos = t; }
   sprintf(msg, "\n%s %s.", msg_content, dir);