Beispiel #1
0
void Roam::rotateCenter(CPoint nowPt, CPoint prePt) {
    changeAngle(nowPt, prePt, false);
    //¶¯center
    centerX = eyeX - tRadius * cos(tVerticalAng) * cos(tHorizonAng);
    centerY = eyeY - tRadius * sin(tVerticalAng);
    centerZ = eyeZ - tRadius * cos(tVerticalAng) * sin(tHorizonAng);
}
Beispiel #2
0
void Bow::update() {

	if (bow_status == BowStatus::DRAW)
	{
		animation_count = std::min(10, ++animation_count);
		index = animation_count / 5;
	}
	else if (bow_status == BowStatus::SHOOT)
	{
		++animation_count;
		index = animation_count / 5;

		if (animation_count > 19)
		{
			animation_count = 0;
			index = 0;
			bow_status = BowStatus::NOMAL;
		}
	}

	if (env.isPullKey('P'))
	{
		if (index == 2)
			bow_status = BowStatus::SHOOT;
		else
		{
			animation_count = 0;
			index = 0;
			bow_status = BowStatus::NOMAL;
		}
	}

	drawTheBow();
	changeAngle();
}
Beispiel #3
0
void Roam::rotateEye(CPoint nowPt, CPoint prePt) {
    if (display.isInMaze()) return; //ÃÔ¹¬×´Ì¬½ûÖ¹
    changeAngle(nowPt, prePt, true);
    //¶¯eye
    eyeX = tRadius * cos(tVerticalAng) * cos(tHorizonAng) + centerX;
    eyeY = tRadius * sin(tVerticalAng) + centerY;
    eyeZ = tRadius * cos(tVerticalAng) * sin(tHorizonAng) + centerZ;
}
void JoyStickPanel::setTouchDotPosition(Vec2 vec1,Vec2 vec2)
{
	_touchDot->setPosition(vec2);
	if( _failradius>0 )
	{
		if( vec1.getLength() < _failradius )
		{
			resetState();
			return;
		}
	}
	changeAngle(vec1);
}
int CockpitGrid::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QFrame::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: changeSpeed(); break;
        case 1: changeGradient(); break;
        case 2: changeAngle(); break;
        default: ;
        }
        _id -= 3;
    }
    return _id;
}
bool JoyStickPanel::onTouchBegan(Touch* touch,Event* event)
{
	Vec2 locationInNode = this->convertToNodeSpace(touch->getLocation());
	if( isAutoPosition )
	{
		this->setPosition(touch->getLocation());
		return true;
	}
	if( isAutoPosition==false && isDieRadius )
	{
		if( locationInNode.getLength() > _radius )
		{
			return false;
		}
	}
	_touchDot->setPosition(locationInNode);
	if( locationInNode.getLength() > _failradius )
	{
		changeAngle(locationInNode);
	}
	return true;
}
Beispiel #7
0
QwtDial *CockpitGrid::createDial( int pos )
{
    QwtDial *dial = NULL;
    switch( pos )
    {
        case 0:
        {
            d_clock = new QwtAnalogClock( this );
#if 0
            // disable minor ticks
            d_clock->scaleDraw()->setTickLength( QwtScaleDiv::MinorTick, 0 );
#endif

            const QColor knobColor = QColor( Qt::gray ).light( 130 );

            for ( int i = 0; i < QwtAnalogClock::NHands; i++ )
            {
                QColor handColor = QColor( Qt::gray ).light( 150 );
                int width = 8;

                if ( i == QwtAnalogClock::SecondHand )
                {
                    handColor = Qt::gray;
                    width = 5;
                }

                QwtDialSimpleNeedle *hand = new QwtDialSimpleNeedle(
                    QwtDialSimpleNeedle::Arrow, true, handColor, knobColor );
                hand->setWidth( width );

                d_clock->setHand( static_cast<QwtAnalogClock::Hand>( i ), hand );
            }

            QTimer *timer = new QTimer( d_clock );
            timer->connect( timer, SIGNAL( timeout() ),
                d_clock, SLOT( setCurrentTime() ) );
            timer->start( 1000 );

            dial = d_clock;
            break;
        }
        case 1:
        {
            d_speedo = new SpeedoMeter( this );
            d_speedo->setScaleStepSize( 20.0 );
            d_speedo->setScale( 0.0, 240.0 );
            d_speedo->scaleDraw()->setPenWidth( 2 );

            QTimer *timer = new QTimer( d_speedo );
            timer->connect( timer, SIGNAL( timeout() ),
                this, SLOT( changeSpeed() ) );
            timer->start( 50 );

            dial = d_speedo;
            break;
        }
        case 2:
        {
            d_ai = new AttitudeIndicator( this );
            d_ai->scaleDraw()->setPenWidth( 3 );

            QTimer *gradientTimer = new QTimer( d_ai );
            gradientTimer->connect( gradientTimer, SIGNAL( timeout() ),
                this, SLOT( changeGradient() ) );
            gradientTimer->start( 100 );

            QTimer *angleTimer = new QTimer( d_ai );
            angleTimer->connect( angleTimer, SIGNAL( timeout() ),
                this, SLOT( changeAngle() ) );
            angleTimer->start( 100 );

            dial = d_ai;
            break;
        }

    }

    if ( dial )
    {
        dial->setReadOnly( true );
        dial->setLineWidth( 4 );
        dial->setFrameShadow( QwtDial::Sunken );
    }
    return dial;
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    if(initalized==false){
        QPalette Pal(palette());
        initalized=true;
        Pal.setColor(QPalette::Background, defaultcolor);
        ui->color_display->setAutoFillBackground(true);
        ui->color_display->setPalette(Pal);
    }

    //connect

    //display to control
    //QObject::connect(ui->AngleInput,SIGNAL(textChanged(QString)),ui->openGLWidget,SLOT(changeAngle(QString)));
    QObject::connect(ui->openGLWidget,SIGNAL(axiomRead(QString)),ui->Axiom,SLOT(setText(QString)));
    QObject::connect(ui->openGLWidget,SIGNAL(angleRead(QString)),ui->AngleInput,SLOT(setText(QString)));
    QObject::connect(ui->openGLWidget,SIGNAL(RuleRead(QString)),ui->RuleDIsplay,SLOT(setPlainText(QString)));
    QObject::connect(ui->openGLWidget,SIGNAL(iterationRead(int)),ui->Iteration_spinBox,SLOT(setValue(int)));
    QObject::connect(ui->openGLWidget,SIGNAL(RuleCalculated(QString)),ui->L_systemResult,SLOT(setPlainText(QString)));
    //control to display
    QObject::connect(ui->Axiom,SIGNAL(textEdited(QString)),ui->openGLWidget,SLOT(changeAxiom(QString)));
    QObject::connect(ui->AngleInput,SIGNAL(textEdited(QString)),ui->openGLWidget,SLOT(changeAngle(QString)));
    QObject::connect(ui->Iteration_spinBox,SIGNAL(valueChanged(int)),ui->openGLWidget,SLOT(changeIteration(int)));
    QObject::connect(ui->foceUpdateButton,SIGNAL(pressed()),ui->openGLWidget,SLOT(UpdateL_system()));
    QObject::connect(ui->FileSelector,SIGNAL(currentTextChanged(QString)),ui->openGLWidget,SLOT(ChangeTemplate(QString)));
    QObject::connect(ui->foceUpdateButton,SIGNAL(pressed()),ui->openGLWidget,SLOT(setFocus()));
    QObject::connect(this,SIGNAL(ColorChange(QColor)),ui->openGLWidget,SLOT(getChangedColor(QColor)));
    //this->setAttribute(Qt::WA_TranslucentBackground, true);
}
Beispiel #9
0
void Hanger::doAction(float _f, GameControl * _gameControl)
{
	switch(status)
	{
	case HANGER_STATUS_SWAYING:
#ifdef							GOLDEN_MINER_2_VERSION_TIME
		if(tmpStatusTimeCount <= 0)
		{
			canThrow = true;
			//Global::getInstance()->setHangerCanThrow(canThrow);
		}
		else
		{
			tmpStatusTimeCount -= _f*SCHEDULE_TIMES;
		}
#else
		if(tmpStatusTimeCount == 0)
		{
			canThrow = true;
			//Global::getInstance()->setHangerCanThrow(canThrow);
		}
		else
		{
			tmpStatusTimeCount--;
		}
#endif
		// 钩子摇摆状态要改变角度 以及图片显示
		changeAngle();
		//setSwayPostion();
		break;
	case HANGER_STATUS_THROW:
		setMovePostion(_gameControl);
		intersectCheck(_gameControl);
		break;
	case HANGER_STATUS_PULL_HAVING:
#ifdef							GOLDEN_MINER_2_VERSION_TIME
		if(tmpStatusTimeCount <= 0)
		{
			setMovePostion(_gameControl);
		}
		else
		{
			tmpStatusTimeCount -= _f*SCHEDULE_TIMES;
			if((tmpStatusTimeCount <= HANGER_PULL_START) && ((tmpStatusTimeCount+_f*SCHEDULE_TIMES) >= HANGER_PULL_START))
			{
				// 换图
				rope->changeImageByStatus(ROPE_STATUS_PULL, this);
			}
			else if((tmpStatusTimeCount <= 0) && ((tmpStatusTimeCount+_f*SCHEDULE_TIMES) >= 0))
			{
				// 换图
				rope->changeImageByStatus(ROPE_STATUS_NORMAL, this);
			}
		}
#else
		if(tmpStatusTimeCount == 0)
		{
			setMovePostion(_gameControl);
		}
		else
		{
			tmpStatusTimeCount--;
			if(tmpStatusTimeCount == HANGER_PULL_START)
			{
				// 换图
				rope->changeImageByStatus(ROPE_STATUS_PULL, this);
			}
			else if(tmpStatusTimeCount == 0)
			{
				// 换图
				rope->changeImageByStatus(ROPE_STATUS_NORMAL, this);
			}
		}
#endif
		break;
	case HANGER_STATUS_PULL_UNHAVING:
		// 出钩子/收钩子 只有位置变化
		//CCLOG("Hanger doAction: status = %d", status);
#ifdef									GOLDEN_MINER_2_VERSION_TIME
		if(tmpStatusTimeCount < 0)
		{
			setMovePostion(_gameControl);
		}
		else
		{
			tmpStatusTimeCount -= _f*SCHEDULE_TIMES;
			if((tmpStatusTimeCount <= 0) && ((tmpStatusTimeCount+_f*SCHEDULE_TIMES) >= 0))
			{
				// 换图
				rope->changeImageByStatus(ROPE_STATUS_NORMAL, this);
			}
		}
#else
		if(tmpStatusTimeCount == 0)
		{
			setMovePostion(_gameControl);
		}
		else
		{
			tmpStatusTimeCount--;
			if(tmpStatusTimeCount == 0)
			{
				// 换图
				rope->changeImageByStatus(ROPE_STATUS_NORMAL, this);
			}
		}
#endif
		setMovePostion(_gameControl);
		break;
	case HANGER_STATUS_PAUSE:
		break;
	default:
		// 不能出现其他状态 有错误
		break;
	}

	rope->doAction(_f, this);
}
Beispiel #10
0
void AIControl::update()
{
    // don't do anything if we're paused
    if ( global::pause )
    {
        return;
    }

    m_reinforce += 0.0002F * omi::fpsManager.getTimeScale();
    if ( !m_doneReinforce && m_reinforce >= 1.0F )
    {
        m_doneReinforce = true;
        m_reinText->visible = true;

        for ( size_t i = 0; i < 6; ++i )
        {
            Artillery* a = new Artillery(
                    unit::PLAYER,
                    rand() % 50,
                    ( rand() % 25 ) + 6,
                    m_environment
            );
            m_player.push_back( a );
            addEntity( a );
        }

        for ( size_t i = 0; i < 6; ++i )
        {
            Artillery* a = new Artillery(
                    unit::ENEMY,
                    rand() % 50,
                    94 - ( ( rand() % 25 ) + 1 ),
                    m_environment
            );
            m_enemy.push_back( a );
            addEntity( a );
        }
    }
    else if ( m_doneReinforce )
    {
        m_reinTextTime += 0.002F * omi::fpsManager.getTimeScale();

        if ( m_reinTextTime >= 1.0F )
        {
            m_reinText->visible = false;
            m_doneReinforce = false;
            m_reinforce = 0.0F;
            m_reinTextTime = 0.0F;
        }
    }

    // check over player units
    std::vector< Artillery* >::iterator pit = m_player.begin();
    for( ; pit != m_player.end(); )
    {
        if ( ( *pit )->hp <= 0 )
        {
            ( *pit )->hardRemove();
            pit = m_player.erase( pit );
        }
        else
        {
            ++pit;
        }
    }

    std::vector< Artillery* >::iterator eit = m_enemy.begin();
    for( ; eit != m_enemy.end(); )
    {
        if ( ( *eit )->hp <= 0 )
        {
            ( *eit )->hardRemove();
            eit = m_enemy.erase( eit );
        }
        else
        {
            ++eit;
        }
    }


    // control enemies
    m_updateCounter += 0.005F * omi::fpsManager.getTimeScale();
    if ( m_updateCounter >= m_nextUpdateTime )
    {
        m_updateCounter = 0.0F;
        float r = ( static_cast< float >( rand() % 1000 ) / 1000.0F ) - 0.5F;
        r *= 0.1F;
        m_nextUpdateTime = 1.0F + r;

        // perform AI update
        if ( m_enemy.size() > 0 )
        {
            changeState();
            changeAngle();
        }
    }

    // update the text
    std::stringstream ssP;
    ssP << "Player: " << m_player.size();
    m_textP->setString( ssP.str() );

    std::stringstream ssE;
    ssE << "Enemy: " << m_enemy.size();
    m_textE->setString( ssE.str() );
}