+void move_player(struct player *p, int right, int fwd)
+{
+ static const int step[][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
+ int rdir = (p->dir + 1) & 3;
+ p->cx += step[p->dir][0] * fwd + step[rdir][0] * right;
+ p->cy += step[p->dir][1] * fwd + step[rdir][1] * right;
+}
+
+void turn_player(struct player *p, int turn)
+{
+ if(!turn) return;
+ turn = turn > 0 ? 1 : 3;
+ p->dir = (p->dir + turn) & 3;
+}
+