Ejemplo n.º 1
0
void DirectionSprite::readSpriteFile(const char* sprite_nfo)
{
    VarFile vf = VarFile(sprite_nfo);

    vf.read();

    //up# : starting with 0;
    //down# : starting with 0;
    //left# : starting with 0;
    //right# : starting with 0;

    parseDirection("up", SD_UP, &vf);
    parseDirection("down", SD_DOWN, &vf);
    parseDirection("left", SD_LEFT, &vf);
    parseDirection("right", SD_RIGHT, &vf);
    parseDirection("idle", SD_IDLE, &vf);
}
Ejemplo n.º 2
0
	Constraint* parseConstraint(TiXmlElement* elem, Track* track, Node* node)
	{
		if(strcmp(elem->Attribute("type"), "CurrentEdge") == 0)
		{
			vector<Node*> nodes;
			vector<Direction> dirs;
			TiXmlElement* inner;
			nodes.push_back(node);
			dirs.push_back(parseDirection(elem->Attribute("direction")));
			for(inner = elem->FirstChildElement("Element"); inner; inner = inner->NextSiblingElement("Element"))
			{
				string label(inner->Attribute("node"));
				Direction d = parseDirection(inner->Attribute("direction"));
				nodes.push_back(track->getFirstNode(label));
				dirs.push_back(d);
			}
			return new CurrentEdge(nodes, dirs);
		}
	}
Ejemplo n.º 3
0
KILLENUM Runtime::execGo()
{
  accept( Token::GO );
  int dir = parseDirection();
  if ( dir == DIRECTION_ERROR )
    return throwError("DIRECTION ERROR");

  const bool didMove = thing->execGo( dir );
  if ( !didMove ) advanceIP = false;

  return PROCEED;
}
Ejemplo n.º 4
0
KILLENUM Runtime::execThrowstar()
{
  accept( Token::THROWSTAR );

  int dir = parseDirection();
  if ( dir == DIRECTION_ERROR )
    return throwError("DIRECTION ERROR");

  thing->execThrowstar( dir );

  return PROCEED;
}
Ejemplo n.º 5
0
KILLENUM Runtime::execShoot()
{
  accept( Token::SHOOT );

  int dir = parseDirection();
  if ( dir == DIRECTION_ERROR )
    return throwError("DIRECTION ERROR");

  thing->execShoot( dir );

  return PROCEED;
}
Ejemplo n.º 6
0
KILLENUM Runtime::execTry()
{
  accept( Token::TRY );

  int dir = parseDirection();
  if ( dir == DIRECTION_ERROR )
    return throwError("DIRECTION ERROR");

  const bool didMove = thing->execTry( dir );
  if ( !didMove ) {
    sendMessage( tokenizer.string() );
    return ENDCYCLE;
  }
  return PROCEED;
}
Ejemplo n.º 7
0
byte parseCommandShift(
  char       *message,
  byte        length,
  byte       *position,
  command_t  *command,
  bytecode_t *bytecode) {

  byte axis;
  byte direction;
  byte errorCode = 0;
  bytecode->executer = command->executer;

  skipWhitespace(message, length, position);
  errorCode = parseAxis(message, length, position, & axis);
  skipWhitespace(message, length, position);
  errorCode = parseDirection(message, length, position, & direction);

  if (errorCode == 0) cubeShift(axis, direction);

  return(errorCode);
};
Ejemplo n.º 8
0
int Runtime::parseDirection( const int stackLimit )
{
  if ( stackLimit <= 0 ) {
    return DIRECTION_ERROR;
  }

  switch ( tokenizer.token() )
  {
    case Token::IDLE:
      accept( Token::IDLE );
      return ZZTThing::Idle;

    case Token::NORTH:
      accept( Token::NORTH );
      return ZZTThing::North;

    case Token::SOUTH:
      accept( Token::SOUTH );
      return ZZTThing::South;

    case Token::WEST:
      accept( Token::WEST );
      return ZZTThing::West;

    case Token::EAST:
      accept( Token::EAST );
      return ZZTThing::East;

    case Token::SEEK:
      accept( Token::SEEK );
      return thing->seekDir();

    case Token::FLOW:
      accept( Token::FLOW );
      return thing->flowDir();

    case Token::CLOCKWISE:
      accept( Token::CLOCKWISE );
      return cardinal_clockwise( parseDirection( stackLimit - 1 ) );

    case Token::COUNTER:
      accept( Token::COUNTER );
      return cardinal_counterwise( parseDirection( stackLimit - 1 ) );

    case Token::OPPOSITE:
      accept( Token::OPPOSITE );
      return cardinal_opposite( parseDirection( stackLimit - 1 ) );

    case Token::RANDNS:
      accept( Token::RANDNS );
      return cardinal_randns();

    case Token::RANDNE:
      accept( Token::RANDNE );
      return cardinal_randne();

    case Token::RANDP:
      accept( Token::RANDP );
      return cardinal_randp( parseDirection( stackLimit - 1 ) );

    default:
      return DIRECTION_ERROR;
  }

  return DIRECTION_ERROR;
}
Ejemplo n.º 9
0
	void Track::loadFromFile(const string& filename)
	{
		TiXmlDocument doc( filename.c_str() );
		
		bool loadOkay = doc.LoadFile();
		if(!loadOkay)
		{
			cerr << "Unable to open file." << endl;
			return;
		}

		TiXmlElement* root = doc.FirstChildElement();
		TiXmlElement* elem;
		TiXmlElement* innerElem;
		if(!root) return;

		//block: Nodes
		{
			nodes.clear();

			for(elem = root->FirstChildElement("Nodes")->FirstChildElement("Node"); elem; elem = elem->NextSiblingElement("Node"))
			{
				string label(elem->Attribute("label"));
				NodeFlags flags = parseNodeFlags(elem->Attribute("flags"));
				//if(label == "" || flags == NODE_NONE)
				//	continue;
				nodes.push_back(new Node(label, flags));
			}
		}

		//block: Edges
		{			
			for(elem = root->FirstChildElement("Nodes")->FirstChildElement("Node"); elem; elem = elem->NextSiblingElement("Node"))
			{
				string nodeLabel(elem->Attribute("label"));
				Node* node = getNodes(nodeLabel)[0];
				for(innerElem = elem->FirstChildElement("Edge"); innerElem; innerElem = innerElem->NextSiblingElement("Edge"))
				{
					string label(innerElem->Attribute("label"));
					EdgeFlags flags = parseEdgeFlags(innerElem->Attribute("flags"));
					Direction dir = parseDirection(innerElem->Attribute("direction"));
					string endpointLabel(innerElem->Attribute("endpoint"));
					Node* otherNode = getNodes(endpointLabel)[0];
					node->makeEdge(*otherNode, flags, dir, label);
				}
			}
		}

		//block: Constraints
		{
			for(elem = root->FirstChildElement("Nodes")->FirstChildElement("Node"); elem; elem = elem->NextSiblingElement("Node"))
			{
				string nodeLabel(elem->Attribute("label"));
				Node* node = getFirstNode(nodeLabel);
				for(innerElem = elem->FirstChildElement("Constraint"); innerElem; innerElem = innerElem->NextSiblingElement("Constraint"))
				{
					Constraint* c = parseConstraint(innerElem, this, node);
					vector<Node*> nodes = c->getAffectedNodes();
					for(size_t x = 0; x < nodes.size(); ++x)
					{
						nodes[x]->addConstraint(c);
					}
				}
			}
		}
	}