コード例 #1
0
static void updateGGA(void* arg) {
	argsCarrier *Args = (argsCarrier*)arg;
	nmeaINFO *info = Args->info;
	char* NMEA2 = Args->NMEA;
	GpsLocation newLoc;
	GpsStatus gpsStat;

	gpsStat.size = sizeof(gpsStat);
	if (info->sig == 0) {
		LOGV("No valid fix data.");
		goto endGGA;
	}

	newLoc.size = sizeof(GpsLocation);
	newLoc.flags = GPS_LOCATION_HAS_LAT_LONG | GPS_LOCATION_HAS_ALTITUDE | GPS_LOCATION_HAS_ACCURACY;
	newLoc.accuracy = info->HDOP;
	newLoc.altitude = info->elv;
	newLoc.latitude = convertCoord(info->lat);
	newLoc.longitude = convertCoord(info->lon);
	newLoc.timestamp = getUTCTime(&(info->utc));
	LOGV("Lat: %lf Long: %lf", newLoc.latitude, newLoc.longitude);
	if (adamGpsCallbacks != NULL) {
		adamGpsCallbacks->location_cb(&newLoc);
	}
	endGGA:	
	free(info);
	free(NMEA2);
	free(arg);
}
コード例 #2
0
// No real need for this function.
// GGA does the same and more.
static void updateRMC(void* arg) {
	argsCarrier *Args = (argsCarrier*)arg;
	nmeaINFO *info = Args->info;
	char* NMEA2 = Args->NMEA;
	GpsLocation newLoc;

	if (info->sig == 0) {
		LOGV("No valid fix data.");
		goto endRMC;
	}

	newLoc.size = sizeof(GpsLocation);
	newLoc.flags = GPS_LOCATION_HAS_LAT_LONG;
	newLoc.latitude = convertCoord(info->lat);
	newLoc.longitude = convertCoord(info->lon);
	newLoc.timestamp = getUTCTime(&(info->utc));
	LOGV("Lat: %lf Long: %lf", newLoc.latitude, newLoc.longitude);
	if (adamGpsCallbacks != NULL) {
		adamGpsCallbacks->location_cb(&newLoc);
	}
	endRMC:
	free(info);
	free(NMEA2);
	free(arg);
}
コード例 #3
0
ファイル: BattleController.cpp プロジェクト: trarck/CCGE
//注意entityId和unitId是不同的.
//entityId是enitty的唯一标识.
//unit可能被几个entity使用。
//比如玩家队伍,同一个玩家可以拥有不同的unit,但entityId不同。
//比如怪物,不同关卡,出现的怪物可以是同一个unit,只是等级装备不同
GameEntity* BattleController::createSelfTroopEntity(int entityId,int index)
{
    
    int col=0;
    int row=0;
    int x=0;
    int y=0;
    
    //取得坐标.index转化成9宫格的坐标
    convertCoord(index, &col, &row, &x, &y);
    
    UnitService* unitService=ServiceFactory::getInstance()->getUnitService();
    
    //创建实体
    GameEntity* entity=EntityFactory::getInstance()->createEntity(entityId);
    
    //设置实体属性
    
    PlayerData* playerData=DataFactory::getInstance()->getPlayerData();
    
    Json::Value playerConfig=playerData->getDataById(entityId);
    
    int unitId=playerConfig[CCGE_PLAYER_UNIT_ID].asInt();
    float scale=playerConfig[CCGE_PLAYER_SCALE].asDouble();
    int level=playerConfig[CCGE_PLAYER_LEVEL].asInt();
    
    //取得配置
    UnitData* unitData=DataFactory::getInstance()->getUnitData();

    Json::Value unitConfig=unitData->getDataById(unitId);

    
    //设置单位属性
    UnitProperty* unitProperty=unitService->createUnitPropertyFromLevel(level, unitConfig);
    entity->addProperty(unitProperty, CCGE_PROPERTY_UNIT);
    entity->setUnitProperty(unitProperty);
    
    CCLOG("level:%d,damage:%f",level,unitProperty->getDamage());
    
    //设置战斗属性
    EntityFactory::getInstance()->getEntityPropertyFactory()->addBattleProperty(entity,col,row,kSelfSide,scale);
    
    //添加组件
    EntityFactory::getInstance()->addBattleComponents(entity);
    
    RendererComponent* rendererComponent=static_cast<RendererComponent*>(entity->getComponent("RendererComponent"));
    m_battleWorld->addChild(rendererComponent->getRenderer());
    
    
    addEntityToSelfTroops(entity, col, row);
    
    return entity;
}
コード例 #4
0
ファイル: exec1.c プロジェクト: FelipeCZ/UNIFESP
void desenhaCirculo(int x0,int y0,int radius){
    int x = 0;
    int y = radius;
    int delta = 2 - 2 * radius;
    int error = 0;

    while(y >= 0){
		pairf point = convertCoord(x0 + x, y0 + y,glutGet(GLUT_WINDOW_WIDTH),glutGet(GLUT_WINDOW_HEIGHT));
        glVertex2f(point.a, point.b);
        point = convertCoord(x0 - x, y0 + y,glutGet(GLUT_WINDOW_WIDTH),glutGet(GLUT_WINDOW_HEIGHT));
        glVertex2f(point.a, point.b);
        //glVertex2f(x0 - x, y0 + y);
        point = convertCoord(x0 + x, y0 - y,glutGet(GLUT_WINDOW_WIDTH),glutGet(GLUT_WINDOW_HEIGHT));
        glVertex2f(point.a, point.b);
        //glVertex2f(x0 + x, y0 - y);
        point = convertCoord(x0 - x, y0 - y,glutGet(GLUT_WINDOW_WIDTH),glutGet(GLUT_WINDOW_HEIGHT));
        glVertex2f(point.a, point.b);
        //glVertex2f(x0 - x, y0 - y);
        error = 2 * (delta + y) - 1;
        if(delta < 0 && error <= 0) { //faz os dois quadrantes
            ++x;
            delta += 2 * x + 1;
            continue;
        }
        
        error = 2 * (delta - x) - 1;
        
        if(delta > 0 && error > 0) {
            --y;
            delta += 1 - 2 * y;
            continue;
        }
        
        ++x;
        delta += 2 * (x - y);
        --y;
    }
}
コード例 #5
0
ファイル: exec1.c プロジェクト: FelipeCZ/UNIFESP
//converte uma coordenada x,y da janela para x,y do openGL e atualiza as variaveis globais
pairf glConvertCoord(int x, int y, int xSize, int ySize){
    pairf p = convertCoord(x,y,xSize,ySize);
    lastCoords=p;
    return p;
}
コード例 #6
0
//*************************************************************
//  Check if Mouse Position is within bounds of the sprite
bool Object::isTargeted(sf::RenderWindow &gWindow) {
	if (outOfPlay)
		return false;
	return sprite->getGlobalBounds().contains(convertCoord(gWindow));
}