void ProcessingElement::txProcess() { if (reset.read()) { req_tx.write(0); current_level_tx = 0; transmittedAtPreviousCycle = false; } else { Packet packet; if (canShot(packet)) { packet_queue.push(packet); transmittedAtPreviousCycle = true; } else { transmittedAtPreviousCycle = false; } if (ack_tx.read() == current_level_tx) { if (!packet_queue.empty()) { Flit flit = nextFlit(); // Generate a new flit flit_tx->write(flit); // Send the generated flit current_level_tx = 1 - current_level_tx; // Negate the old value for Alternating Bit Protocol (ABP) req_tx.write(current_level_tx); } } else { //std::cout << "Oops, pe[" << local_id << "] tx encoutered ABP error" << endl; } } }
void NoximProcessingElement::txProcess() { if (reset.read()) { req_tx.write(0); current_level_tx = 0; transmittedAtPreviousCycle = false; } else { NoximPacket packet; if (canShot(packet)) { packet_queue.push(packet); transmittedAtPreviousCycle = true; } else transmittedAtPreviousCycle = false; if (ack_tx.read() == current_level_tx) { if (!packet_queue.empty()) { NoximFlit flit = nextFlit(); // Generate a new flit if (NoximGlobalParams::verbose_mode > VERBOSE_OFF) { cout << sc_time_stamp().to_double() / 1000 << ": ProcessingElement[" << local_id << "] SENDING " << flit << endl; } flit_tx->write(flit); // Send the generated flit current_level_tx = 1 - current_level_tx; // Negate the old value for Alternating Bit Protocol (ABP) req_tx.write(current_level_tx); } } } }
void Player::shoot(unsigned int shotOriginVertexIndex) { if (canShot() == true) { _weapons[_weaponIndex].setType(Ammunition::friendlyShot); GameEngine& engine = GameEngine::instanciate(); Ammunition* shot = new Ammunition(_weapons[_weaponIndex]); shot->setPosition(getPosition() + _shotVertexes[shotOriginVertexIndex % _shotVertexes.size()]); shot->setTargetPosition(Vf(WIN_W * 2, getPosition().y + getGlobalBounds().height / 2)); engine.addAmmo(shot); SoundSystem::instanciate().pushEffect("speedBonus.wav"); // SoundSystem::instanciate().playEffect("speedBonus.wav"); isReloading(); if (_weapons[_weaponIndex].getCurrentAnimation().getAnimationName() == "plasmaBullet") engine.addFX("loadingShot", "r-typesheet1.gif", sf::Vector2f(getPosition().x + _shotVertexes[shotOriginVertexIndex].x, getPosition().y + _shotVertexes[shotOriginVertexIndex].y - engine.getAnimation("loadingShot").getFrameDimensions().y / 2), sf::Color::Black); else engine.addFX("fireshot", "fire.png", sf::Vector2f(getPosition().x + _shotVertexes[shotOriginVertexIndex].x, getPosition().y + _shotVertexes[shotOriginVertexIndex].y - engine.getAnimation("fireshot").getFrameDimensions().y / 2), sf::Color::White); } }
/** * função que lida com os eventos básicos do megaman * * @author: Cantídio Oliveira Fontes * @since: 18/06/2008 * @final: 03/07/2008 * @param: megaman *, ponteiro para o megaman * @param: background *, ponteiro para o cenário * @param: gorgonAudio *, ponteiro para o sistema sonoro * @return: int */ int megamanNormalEvents(megaman *mega,background *bg) { if(mega->control) { if(key[mega->controlDef.jump] && key[mega->controlDef.down] && backgroundCollision((int)mega->x-5,(int)mega->y, 10,2,bg)) { mega->control=0; megamanChangAnimationIfChange(mega,animSlide,0,0); } else if(key[mega->controlDef.shot] && canShot(&mega->weapons)) { gorgonPlaySound(mega->sound[soundShot],&mega->audio,3); megamanShot(mega); } else if(key[mega->controlDef.jump] && backgroundCollision((int)mega->x-5,(int)mega->y, 10,2,bg)) { megamanJump(mega); } else if(key[mega->controlDef.right]) { mega->direction=NORMAL; if(mega->lastShot==0 && backgroundCollision((int)mega->x-5,(int)mega->y-2, 10,2,bg)) { if(mega->animationPlaying!=animShotWalking) megamanChangAnimationIfChange(mega,animWalk,0,0); else megamanChangAnimationIfChange(mega,animWalk,mega->animationPack.animation[mega->animationPlaying].frameOn,mega->animationPack.animation[mega->animationPlaying].timeOn); } if(mega->xPulse<mega->xPulseMax) { mega->xPulse+=mega->xPulseValue; } } else if(key[mega->controlDef.left]) { mega->direction=H_FLIP; if(mega->lastShot==0 && backgroundCollision((int)mega->x-5,(int)mega->y-2, 10,2,bg)) { if(mega->animationPlaying!=animShotWalking) megamanChangAnimationIfChange(mega,animWalk,0,0); else megamanChangAnimationIfChange(mega,animWalk,mega->animationPack.animation[mega->animationPlaying].frameOn,mega->animationPack.animation[mega->animationPlaying].timeOn); } if(mega->xPulse>-mega->xPulseMax) { mega->xPulse-=mega->xPulseValue; } } else if(!key[mega->controlDef.right] && mega->xPulse>0) { megamanChangAnimationIfChange(mega,animStand,0,0); mega->xPulse-=mega->xPulseValue; if(mega->xPulse<0) mega->xPulse=0; } else if(!key[mega->controlDef.left] && mega->xPulse<0) { megamanChangAnimationIfChange(mega,animStand,0,0); mega->xPulse+=mega->xPulseValue; if(mega->xPulse>0) mega->xPulse=0; } if(key[mega->controlDef.weaponF]) { nextWeapon(&mega->weapons); key[mega->controlDef.weaponF]=0; } else if(key[mega->controlDef.weaponB]) { previousWeapon(&mega->weapons); key[mega->controlDef.weaponB]=0; } } if(mega->lastShot>0) mega->lastShot--; if(mega->imortal>0) mega->imortal--; megamanAnimationFinishedEvents(mega); megamanAnimationRunnigEvents(mega); megamanMoveX(mega,bg); megamanMoveY(mega,bg); }