Beispiel #1
0
void PhySprite::update(float delta) {
	if (b2PhyBody) {
		this->setPosition(ccp(b2c(b2PhyBody->GetPosition().x),
		b2c(b2PhyBody->GetPosition().y)));
		this->setRotation(-1 * CC_RADIANS_TO_DEGREES(b2PhyBody->GetAngle()));
	}
}
void ConsoleMenuBoolInput::execute(int argc, char** argv) {
  bool validValue = false;
  while(!validValue) {
    validValue = false;

    Serial.print("Enter value (y/n) [");
    Serial.print(b2c(*valueTarget));
    Serial.print("]: ");
    int p = 0;
    int c;

    do {
      if(Serial.available()) {
        c = Serial.read();
        if(c == NEW_LINE_CHAR) {
          inputBuffer[p] = '\0';
          Serial.println();
          break;
        }

        Serial.print((byte)c);
        inputBuffer[p++] = c;
      }
    }
    while(p < INPUT_SIZE);

    if(p == 0) {
      Serial.print("Using current value (");
      Serial.print(b2c(*valueTarget));
      Serial.println(")");
      value = *valueTarget;
      validValue = true;
      break;
    }
    else if(p == 1) {
      switch(inputBuffer[0]) {
      case 'y':
      case 'Y':
        value = true;
        validValue = true;
        break;
      case 'n':
      case 'N':
        value = false;
        validValue = true;
        break;
      default:
        validValue = false;
        break;
      }
    }
  }

  Serial.print("Entered value: ");
  Serial.print(b2c(value));
  Serial.println();
	*valueTarget = value;
}
Beispiel #3
0
bool PhySprite::initWithBody(b2Body *body) {
	if (CCSprite::init()) {
		b2PhyBody = body;
		b2PhyBody->SetUserData(this);
		this->setAnchorPoint(ccp(0.5, 0.5));
		this->setPosition(ccp(b2c(b2PhyBody->GetPosition().x),
		b2c(b2PhyBody->GetPosition().y)));
		return true;
	} else {
		return false;
	}
}
Beispiel #4
0
INLINE STRPTR GetTaskName( struct Task *task, UWORD *namelen )
{
	struct Process *pr = (struct Process *) task;
	STRPTR name = NULL;
	
//	ENTER();
//	DBG_POINTER(task);
	
	#define b2c(x) ( x << 2 )  /*  BPTR to C string */
	
	if(namelen) (*namelen) = 0;
	
	if (task->tc_Node.ln_Type == NT_PROCESS && pr->pr_CLI != (BPTR)NULL)
	{
		struct CommandLineInterface *cli =
			(struct CommandLineInterface *)BADDR(pr->pr_CLI);
		
		if(cli && cli->cli_Module && cli->cli_CommandName)
		{
			STRPTR bn = (STRPTR) b2c(cli->cli_CommandName);
			
			if(*bn > 0)
			{
				if((name = StrNDup( &bn[1], *bn )))
				{
					if(namelen) (*namelen) = *bn;
				}
			}
		}
	}
	
	if( name == NULL )
	{
		UWORD len = strlen(task->tc_Node.ln_Name);
		
		if((name = StrNDup(task->tc_Node.ln_Name, len )))
		{
			if(namelen) (*namelen) = len;
		}
	}
	
//	DBG_STRING(name);
	
//	RETURN(name);
	return(name);
}