the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 98 lines 1.7 kB view raw
1#include "stdafx.h" 2#include "Direction.h" 3#include "Facing.h" 4 5const int Direction::STEP_X[] = 6{ 7 0, -1, 0, 1 8}; 9 10const int Direction::STEP_Z[] = 11{ 12 1, 0, -1, 0 13}; 14 15const wstring Direction::NAMES[] = {L"SOUTH", L"WEST", L"NORTH", L"EAST" }; 16 17// for [direction] it gives [tile-face] 18int Direction::DIRECTION_FACING[4] = 19{ 20 Facing::SOUTH, Facing::WEST, Facing::NORTH, Facing::EAST 21}; 22 23// for [facing] it gives [direction] 24int Direction::FACING_DIRECTION[] = 25{ 26 UNDEFINED, UNDEFINED, NORTH, SOUTH, WEST, EAST 27}; 28 29int Direction::DIRECTION_OPPOSITE[4] = 30{ 31 NORTH, EAST, SOUTH, WEST 32}; 33 34// for [direction] it gives [90 degrees clockwise direction] 35int Direction::DIRECTION_CLOCKWISE[] = 36{ 37 WEST, NORTH, EAST, SOUTH 38}; 39 40// for [direction] it gives [90 degrees counter clockwise direction] 41int Direction::DIRECTION_COUNTER_CLOCKWISE[] = 42{ 43 EAST, SOUTH, WEST, NORTH 44}; 45 46int Direction::RELATIVE_DIRECTION_FACING[4][6] = 47{ 48 // south 49 { 50 Facing::UP, Facing::DOWN, Facing::SOUTH, Facing::NORTH, Facing::EAST, Facing::WEST 51 }, 52 // west 53 { 54 Facing::UP, Facing::DOWN, Facing::EAST, Facing::WEST, Facing::NORTH, Facing::SOUTH 55 }, 56 // north 57 { 58 Facing::UP, Facing::DOWN, Facing::NORTH, Facing::SOUTH, Facing::WEST, Facing::EAST 59 }, 60 // east 61 { 62 Facing::UP, Facing::DOWN, Facing::WEST, Facing::EAST, Facing::SOUTH, Facing::NORTH 63 } 64}; 65 66int Direction::getDirection(double xd, double zd) 67{ 68 if (Mth::abs((float) xd) > Mth::abs((float) zd)) 69 { 70 if (xd > 0) 71 { 72 return WEST; 73 } 74 else 75 { 76 return EAST; 77 } 78 } 79 else 80 { 81 if (zd > 0) 82 { 83 return NORTH; 84 } 85 else 86 { 87 return SOUTH; 88 } 89 } 90} 91 92int Direction::getDirection(int x0, int z0, int x1, int z1) 93{ 94 int xd = x0 - x1; 95 int zd = z0 - z1; 96 97 return getDirection(xd, zd); 98}