Clone wiki

cs1917-group-project / HexTiles


Board / hexTileLoc


Code Samples

Parsing a path

pathObject obj;
if (!parsePath (game, "LRLRLR", &obj)) {
    printf ("Failed to parse path.\n");

Getting/setting owners of a side and vertex

Example using getSide and setSide:

pathObject obj;

// find out what's on this side
int sideType = getSide (game, obj);
if (sideType == PATH_FAILURE) {
    // is parsePath worked, there's not much
    // point in checking this
    // maybe an assert?
    printf ("Unable to parse side\n");

printf ("Is uni A's arc on this side? ");
if (sideType == ARC_A) {
     printf ("Yes\n");
} else {
     printf ("No\n");

// set it and the vertex it's pointing to
// to become vacant
if (setSide (game, obj, VACANT_ARC) == PATH_FAILURE) {
    // again, maybe just an assert
    printf ("Unable to set side to VACANT_ARC\n");

setVertex (game, obj, VACANT_VERTEX);

Getting adjacent sides

pathObject obj, adjObj;

// ...

if (!getAdjacentSide (game, obj, &obj)) {
    printf ("No adjacent side\n");

// from now on, use newTile and newVec to talk about
// the adjacent tile and adjacent side

Getting adjacent vertexes

pathObject obj;
pathObject adjObj[2];
int numAdjacent;

numAdjacent = getAdjacentVertex (game, obj, &adjObj);
printf ("Got back %d adjacent vertices\n", numAdjacent);
if (numAdjacent > 0) {
    printf ("First one at (%d, %d)\n", obj.tile->location.x, obj.tile->location.y);