Added quick move room method

This commit is contained in:
Warwick 2023-08-15 15:57:02 +01:00
parent 2b40943d14
commit 61c57edc70
3 changed files with 27 additions and 0 deletions

View file

@ -0,0 +1,15 @@
#include "command.h"
Room *cmd__move(move_directions direction, Room *current_room) {
switch (direction) {
case NORTH:
return current_room->north;
case EAST:
return current_room->east;
case SOUTH:
return current_room->south;
case WEST:
return current_room->west;
}
return NULL;
}

View file

@ -0,0 +1,10 @@
#pragma once
#include "world.h"
#include <error.h>
typedef enum { NORTH, EAST, SOUTH, WEST } move_directions;
// Returns pointer to new room based on current room and direction If room
// doesn't exist returns NULL
Room *cmd__move(move_directions direction, Room *current_room);

View file

@ -1,3 +1,5 @@
#pragma once
#define WORLD_SIZE 100 #define WORLD_SIZE 100
#include <math.h> #include <math.h>