Exemplo n.º 1
0
VOID D1Sprite::update(AEHashedTable<AEPlatform>* platformTable) {
    if (ai) {
        ai->execute();
    }
    D1Animation* anim = (D1Animation*)(obj->getAnim(action));
    if (timeToLive == 0) {
        changeAction(anim->getNext());
    }
    if (timeToLive > 0) {
        timeToLive--;
    }
    time++;
    BOOLEAN isFrameChange = FALSE;
    if (time >= anim->getEndTime(frameNum)) {
        isFrameChange = TRUE;
        frameNum++;
        if (time >= anim->getEndTime(anim->getFrameCount() - 1)) {
            time = 0;
        }
        if (frameNum == anim->getFrameCount()) {
            frameNum = 0;
            if (!anim->isLoop()) {
                changeAction(anim->getNext());
            }
        }
        D1AnimOption_CreateSprite* sc = anim->getSpriteCreationOption(frameNum);
        if (sc != nullptr) {
            sc->descSprite.obj = ae_ObjectTable.getItem(sc->oid);
            sc->descSprite.team = this->team;
            sc->descSprite.cx = cx - getCurrentFrame()->getCenter().x + sc->x;
            sc->descSprite.cy = cy - getCurrentFrame()->getCenter().y + sc->y;
            D1Sprite* sprite = new D1Sprite(sc->descSprite);
            sprite->setVx(sc->vx);
            sprite->setVy(sc->vy);
            scene->addSprite(sprite);
        }
    }
    INT fac = (flip ? -1 : 1);
    FLOAT cx_old = cx, cy_old = cy;
    cx += (fac * vx);
    cy += vy;
    vx += ax;
    vy += ay;
    if (platformTable != nullptr) {
        platformCollisionCheck(cx_old, cy_old, platformTable);
    }
    if (isFrameChange) {
        isFrameChange = FALSE;
    }
    angle += (fac * vAngle);
    if (angle < -AENSMath::PI) angle += 2.0f * AENSMath::PI;
    if (angle >= AENSMath::PI) angle -= 2.0f * AENSMath::PI;
    angleDisplay += (fac * vAngleDisplay);
    if (angleDisplay < -AENSMath::PI) angleDisplay += 2.0f * AENSMath::PI;
    if (angleDisplay >= AENSMath::PI) angleDisplay -= 2.0f * AENSMath::PI;
}
Exemplo n.º 2
0
VOID D1PlayerFighter::update(AEHashedTable<AEPlatform>* platformTable) {
    
    if (!(isKeyPressed(D1Key::KEY_LEFT) && isKeyPressed(D1Key::KEY_RIGHT))) {
        FLOAT xSpeed = 0.0f;
        if (isKeyPressed(D1Key::KEY_LEFT)) {
            xSpeed = -1.0f;
        }
        else if (isKeyPressed(D1Key::KEY_RIGHT)) {
            xSpeed = 1.0f;
        }
        else {
            xSpeed = 0.0f;
        }
        setVx(xSpeed);
    }
    FLOAT ySpeed = (isKeyPressed(D1Key::KEY_UP) ? -1.0f : 0.0f) + (isKeyPressed(D1Key::KEY_DOWN) ? 1.0f : 0.0f);
    setVy(ySpeed);
    
    attackTimer--;
    if (attackTimer == 25 || attackTimer == 15 || attackTimer == 5) {
        shoot(8.0f);
        shoot(-8.0f);
    }

    if (hpValue <= 0 && action < D1PlayerFighter::ACTION_KILLED) {
        changeAction(D1PlayerFighter::ACTION_KILLED);
        AESpriteAttachment* attachedShadow = attachmentTable->getItem(0);
        if (attachedShadow) attachedShadow->getSprite()->remove();
    }
    
    D1Sprite::update(platformTable);

}
Exemplo n.º 3
0
VOID D1EnemyFighter::update(AEHashedTable<AEPlatform>* platformTable) {
    if (hpValue <= 0 && action < D1PlayerFighter::ACTION_KILLED) {
        changeAction(D1EnemyFighter::ACTION_KILLED);
        AESpriteAttachment* attachedShadow = attachmentTable->getItem(0);
        if (attachedShadow) attachedShadow->getSprite()->remove();
    }
    D1Sprite::update(platformTable);
}
Exemplo n.º 4
0
//---------------------------------------------------------------------
void TitleState::update()
{
    //---- 
    elapsed_action_frame++;

    //---- ACTION_CIRCLE_FADEIN
    if (now_action == TitleState::ACTION_CIRCLE_FADEIN) {
        alpha -= 10;
        if (alpha <= 0) {
            alpha = 0;
            changeAction(TitleState::ACTION_CIRCLE_DISP);
        }
    }
    //---- ACTION_CIRCLE_DISP
    else if (now_action == TitleState::ACTION_CIRCLE_DISP) {
        if (elapsed_action_frame >= 100) {
            changeAction(TitleState::ACTION_CIRCLE_FADEOUT);
        }
    }
    //---- ACTION_CIRCLE_FADEOUT
    else if (now_action == TitleState::ACTION_CIRCLE_FADEOUT) {
        alpha += 10;
        if (alpha >= 255) {
            alpha = 255;
            changeAction(TitleState::ACTION_TITLE_FADEIN);
        }
    }
    //---- ACTION_TITLE_FADEIN
    else if (now_action == TitleState::ACTION_TITLE_FADEIN) {
        alpha -= 10;
        if (alpha <= 0) {
            alpha = 0;
            changeAction(TitleState::ACTION_TITLE_DISP);
        }
    }
    //---- ACTION_TITLE_DISP
    else if (now_action == TitleState::ACTION_TITLE_DISP) {

    }
}
void Oh_Oh_Robot::writingRobot_runMode(){
  //readEPROM();
	int n=0;	
	for(int i=0;i<512;i+=2){
		if(EEPROM.read(i)==255){
			direction[n]=255;
			break;
		}else{
			direction[n]=EEPROM.read(i);
			timeSpan[n]=EEPROM.read(i+1)*10;
			n++;
		}
	}
	

  //startRun();
	for(int i=0;i<3;i++){
		digitalWrite(ledPin,HIGH);
		delay(1000);
		digitalWrite(ledPin,LOW);
		delay(1000);
	}



	runTimer=millis();
	arrayPoint=0;
	onOff(true);
	liftArm();
	runFlag=true;

	changeAction();
	while(runFlag){
		run();
		powerFactor;
		sizeFactor;
	}
}
Exemplo n.º 6
0
/*
	定时器接收函数
*/
void MainWindow::timerEvent(QTimerEvent *event)
{
	if (event->timerId() == timeid[0])
	{
		if (nowAction == 1)
		{
			image_id++;
			if (image_id > 5)
			{
				image_id = 1;
			}
			image.load(getImage(imageFile, image_id));
			update();
		}
		if (nowAction == 2 || nowAction == 3)
		{
			image_id++;
			if (image_id > 12)
			{
				image_id = 1;
			}
			image.load(getImage(imageFile, image_id));
			int x = pos().x() - 4;
			int y = pos().y();
			if (x < -width())
				x = QApplication::desktop()->width();
			move(QPoint(x, y));
			update();
		}
	}
	if (event->timerId() == timeid[1])
	{
		srand(unsigned(time(NULL)));
		nowAction = rand() % 3 + 1;
		changeAction();
	}
}