void Frog::killed() { setLife(getLife() - 1); setPositionXXs(3.0); setPositionYYs(-13.0); setPositionZZs(-2.0); }
void CPlayerBase::update(float elapsed) { PROFILE_FUNCTION("update base"); if (camera.isValid()) { if (onCinematic) { UpdateCinematic(elapsed); } else if (controlEnabled || only_sense) { bool alive = !checkDead(); if (alive && inputEnabled) { energy_decrease = energy_default_decrease; // Default if nobody change that this frame UpdateSenseVision(); if (!only_sense) { UpdateMoves(); UpdateInputActions(); } setLife(getLife() - getDeltaTime() * energy_decrease); } Recalc(); if (alive) { //UpdateMoves(); myUpdate(); update_msgs(); } } //UpdateAnimation(); } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QObject::connect(ui->SFMLWidget, SIGNAL(rotationChanged(int)), this, SLOT(setRotation(int))); QObject::connect(ui->SFMLWidget, SIGNAL(rangeChanged(int)), this, SLOT(setRange(int))); QObject::connect(ui->SFMLWidget, SIGNAL(colorChanged(uint8_t,uint8_t,uint8_t)), this, SLOT(setColor(uint8_t,uint8_t,uint8_t))); QObject::connect(ui->SFMLWidget, SIGNAL(amountChanged(int)), this, SLOT(setAmount(int))); QObject::connect(ui->SFMLWidget, SIGNAL(speedChanged(int)), this, SLOT(setSpeed(int))); QObject::connect(ui->SFMLWidget, SIGNAL(lifeChanged(int)), this, SLOT(setLife(int))); // validators CODE_VALIDATOR_LINE_SLIDER(lineEditRange, sliderRange); CODE_VALIDATOR_LINE_SLIDER(lineEditRotation, sliderRotation); CODE_VALIDATOR_LINE_SLIDER(lineEditAmount, sliderAmount); CODE_VALIDATOR_LINE_SLIDER(lineEditSpeed, sliderSpeed); CODE_VALIDATOR_LINE_SLIDER(lineEditLife, sliderLife); // standard values setRange(360); setRotation(0); setAmount(200); setSpeed(100); setLife(3); setColor(255, 0, 0); }
void EspadachinIA::Recovery() { if(getLife()<100){ setLife(getLife()+1); } }
IntervalLayer::IntervalLayer() { _time0 = _time1 = _time2 = _time3 = _time4 = 0.0f; auto s = Director::getInstance()->getWinSize(); // sun auto sun = ParticleSun::create(); sun->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); sun->setPosition( Point(VisibleRect::rightTop().x-32,VisibleRect::rightTop().y-32) ); sun->setTotalParticles(130); sun->setLife(0.6f); this->addChild(sun); // timers _label0 = LabelBMFont::create("0", "fonts/bitmapFontTest4.fnt"); _label1 = LabelBMFont::create("0", "fonts/bitmapFontTest4.fnt"); _label2 = LabelBMFont::create("0", "fonts/bitmapFontTest4.fnt"); _label3 = LabelBMFont::create("0", "fonts/bitmapFontTest4.fnt"); _label4 = LabelBMFont::create("0", "fonts/bitmapFontTest4.fnt"); scheduleUpdate(); schedule(schedule_selector(IntervalLayer::step1)); schedule(schedule_selector(IntervalLayer::step2), 0); schedule(schedule_selector(IntervalLayer::step3), 1.0f); schedule(schedule_selector(IntervalLayer::step4), 2.0f); _label0->setPosition(Point(s.width*1/6, s.height/2)); _label1->setPosition(Point(s.width*2/6, s.height/2)); _label2->setPosition(Point(s.width*3/6, s.height/2)); _label3->setPosition(Point(s.width*4/6, s.height/2)); _label4->setPosition(Point(s.width*5/6, s.height/2)); addChild(_label0); addChild(_label1); addChild(_label2); addChild(_label3); addChild(_label4); // Sprite auto sprite = Sprite::create(s_pathGrossini); sprite->setPosition( Point(VisibleRect::left().x + 40, VisibleRect::bottom().y + 50) ); auto jump = JumpBy::create(3, Point(s.width-80,0), 50, 4); addChild(sprite); sprite->runAction( RepeatForever::create(Sequence::create(jump, jump->reverse(), NULL) )); // pause button auto item1 = MenuItemFont::create("Pause", [&](Ref* sender) { if(Director::getInstance()->isPaused()) Director::getInstance()->resume(); else Director::getInstance()->pause(); }); auto menu = Menu::create(item1, NULL); menu->setPosition( Point(s.width/2, s.height-50) ); addChild( menu ); }
void Tutorial::Crash()// draws the animation for a crash and pasticles that fly out from there { //animation code auto spritecache = SpriteFrameCache::getInstance(); spritecache->addSpriteFramesWithFile("GameScreen/explosion.plist"); cocos2d::SpriteFrame* spriteFrame = spritecache->getSpriteFrameByName("explosion0.png"); cocos2d::Vector<cocos2d::Sprite *> m_aiSprites; cocos2d::Vector<cocos2d::SpriteFrame*> m_animFrames; for (int i = 0; i < 23; i++) { // Get a SpriteFrame using a name from the spritesheet .plist file. m_animFrames.pushBack(spritecache->getSpriteFrameByName("explosion" + std::to_string(i) + ".png")); } // Create the animation out of the frames. Animation* animation = Animation::createWithSpriteFrames(m_animFrames, 0.065); Animate* animate = Animate::create(animation); // Create a sprite using any one of the SpriteFrames // This is so we get a sprite of the correct dimensions. auto sprite = Sprite::createWithSpriteFrame(m_animFrames.at(0)); // Run and repeat the animation. sprite->setScale(3.0f); sprite->runAction(RepeatForever::create(animate)); sprite->setPosition(Vec2(player->getPosition().x, player->getPosition().y - 5)); this->addChild(sprite, 10); m_aiSprites.pushBack(sprite); //code for the particles that will be coloured orange auto size = Director::getInstance()->getWinSize(); auto m_emitter = ParticleExplosion::createWithTotalParticles(900); m_emitter->setDuration(-1); m_emitter->setGravity(Point(0, -240)); m_emitter->setAngle(0); m_emitter->setAngleVar(180); m_emitter->setRadialAccel(25); m_emitter->setRadialAccelVar(0); m_emitter->setTangentialAccel(10); m_emitter->setTangentialAccelVar(0); m_emitter->setPosVar(Point(1, 0)); m_emitter->setLife(0.25); m_emitter->setLifeVar(0.50); m_emitter->setStartSpin(0); m_emitter->setStartSpinVar(0); m_emitter->setEndSpin(0); m_emitter->setEndSpinVar(0); m_emitter->setStartColor(Color4F(212, 73, 0, 1)); m_emitter->setStartColorVar(Color4F(0, 0, 0, 0)); m_emitter->setEndColor(Color4F(212, 73, 0, 1)); m_emitter->setEndColorVar(Color4F(0, 0, 0, 0)); m_emitter->setStartSize(20.0f); m_emitter->setStartSizeVar(0); m_emitter->setEndSize(15.0f); m_emitter->setEndSizeVar(0); m_emitter->setEmissionRate(275); m_emitter->setPosition(Vec2(player->getPosition().x, player->getPosition().y - 15)); addChild(m_emitter, 10); }
void ParticlePerformTest4::doTest() { auto s = Director::getInstance()->getWinSize(); auto particleSystem = (ParticleSystem*) getChildByTag(kTagParticleSystem); // duration particleSystem->setDuration(-1); // gravity particleSystem->setGravity(Vec2(0,-90)); // angle particleSystem->setAngle(90); particleSystem->setAngleVar(0); // radial particleSystem->setRadialAccel(0); particleSystem->setRadialAccelVar(0); // speed of particles particleSystem->setSpeed(180); particleSystem->setSpeedVar(50); // emitter position particleSystem->setPosition(Vec2(s.width/2, 100)); particleSystem->setPosVar(Vec2(s.width/2,0)); // life of particles particleSystem->setLife(2.0f); particleSystem->setLifeVar(1); // emits per frame particleSystem->setEmissionRate(particleSystem->getTotalParticles() / particleSystem->getLife()); // color of particles Color4F startColor(0.5f, 0.5f, 0.5f, 1.0f); particleSystem->setStartColor(startColor); Color4F startColorVar(0.5f, 0.5f, 0.5f, 1.0f); particleSystem->setStartColorVar(startColorVar); Color4F endColor(0.1f, 0.1f, 0.1f, 0.2f); particleSystem->setEndColor(endColor); Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f); particleSystem->setEndColorVar(endColorVar); // size, in pixels particleSystem->setEndSize(64.0f); particleSystem->setStartSize(64.0f); particleSystem->setEndSizeVar(0); particleSystem->setStartSizeVar(0); // additive particleSystem->setBlendAdditive(false); }
void PlayStage::boomAnime(Point position) { auto particleStars = ParticleSystemQuad::create("star_boom_ver18.plist"); particleStars->setAutoRemoveOnFinish(true); particleStars->setBlendAdditive(true); particleStars->setScale(0.5f+chains*.1f); particleStars->setLife(0.2f + chains*0.02f); particleStars->setSpeed(400.0f + chains*20.0f); particleStars->setPosition(position); ballSheet->addChild(particleStars, 300); }
Aldeano::~Aldeano() { cout << "DestruirAldeano" << endl; setLife(0); vision_range = 0; attack_range = 0; current_sprite = 0; TTexture = NULL; attack_value = 0; delay_sprite = 0; }
Arquero::Arquero(int x, int y) : Unidades(x,y) { cout << "ConstruirArquero" << endl; setLife(100); vision_range = 5; attack_range = 2; attack_value = 1; current_sprite = 0; sprite_Width = 57; sprite_Height = 51; delay_sprite = 0; }
Aldeano::Aldeano() { cout << "ConstruirAldeano" << endl; setLife(100); vision_range = 3; attack_range = 1; current_sprite = 0; sprite_Width = 57; sprite_Height = 51; attack_value = 1; delay_sprite = 0; }
EspadachinIA::EspadachinIA() { cout << "ConstruirEspadachinIA" << endl; setLife(100); vision_range = 3; attack_range = 1; attack_value = 1; current_sprite = 0; sprite_Width = 57; sprite_Height = 51; delay_sprite = 0; }
ArqueroIA::ArqueroIA() { cout << "ConstruirArqueroIA" << endl; setLife(100); vision_range = 5; attack_range = 2; attack_value = 1; current_sprite = 0; sprite_Width = 57; sprite_Height = 51; delay_sprite = 0; }
Ally::Ally() :max_life(1) { setLife(max_life); setPower(1); setSpeed(15.0f); setEffectiveArea(Director::getInstance()->getWinSize()); setTag(kTagAlly); setZOrder(kZOrderMovableSprite); setStatus(Ally::Status::Normal); setSpecialEffect(BattleManager::SpecialEffect::Nothing); }
ArqueroIA::~ArqueroIA() { cout << "DestroirArqueroIA" << endl; setLife(0); vision_range = 0; attack_range = 0; attack_value = 1; current_sprite = 0; sprite_Width = 0; sprite_Height = 0; delay_sprite = 0; }
EspadachinIA::~EspadachinIA() { cout << "DestruirEspadachinIA" << endl; setLife(0); vision_range = 0; attack_range = 0; attack_value = 0; current_sprite = 0; sprite_Width = 0; sprite_Height = 0; delay_sprite = 0; }
void Player::reset() { setLife(life_max); lifegi = 0; setComboState(0); combo = CMB_NULL; #ifdef __USE_OPENAL__ if (type != COMPUTER) updateALListener(); #endif }
Player::Player( World * world ) : ACreature( world ) { setLife( 100 ); setState( SPAWNING ); mArmor = 25; mForwardPressed = false; mLeftPressed = false; mBackwardPressed = false; mRightPressed = false; mUpPressed = false; mDownPressed = false; mSpeedPressed = false; mUsePressed = false; mGodMode = true; mOnGround = false; mUnderWater = false; mVelocityY = 0.0f; mHeightAboveGround = 2.0f; mAxisRotationX = 0.0f; mAxisRotationY = 0.0f; mSpeedCounter = 0.0f; mSpeedCooldown = 0.0f; mTarget = QVector3D(0,0,0); mDragTeapot = false; mCurrentWeapon = QSharedPointer<AWeapon>(); giveWeapon( QSharedPointer<AWeapon>( new Fliegenklatsche( world ) ) ); mTorch = QSharedPointer<Torch>( new Torch( world ) ); mTorch->setPositionY( world->landscape()->terrain()->getHeight( QPointF(0,0) ) ); mPoints = 0; mKillTimer = 0.0f; mTorchTimer = 0.0f; mAliveTimer = 0.0f; mUsageText = ""; mTextMessage = ""; mTextZoom = 0.0f; mTextFade = 0; mTextTime = 0.0f; scene()->addKeyListener( this ); scene()->addMouseListener( this ); }
void Player::updateSelf( const double & delta ) { mAliveTimer += delta; mKillTimer += delta; mTorchTimer += delta; mUsageText = ""; if( mTextTime > 0.0f && !mTextMessage.isEmpty() ) { mTextZoom += delta*10; mTextFade -= delta*50; mTextTime -= delta; } else { mTextFade = 0.0f; } if( mGodMode ) { setState( ALIVE ); setLife( 100 ); } switch( state() ) { case SPAWNING: setState( ALIVE ); break; case ALIVE: updateRotation( delta ); updatePosition( delta ); updateTarget( delta ); updateTorch( delta ); if( mCurrentWeapon ) { mCurrentWeapon->setPosition( QVector3D(-0.5f,-0.5f-0.1*QVector3D::dotProduct(QVector3D(0,1,0),direction()), 0.5f ) ); } break; case DYING: setState( DEAD ); drawMessage( "GAME OVER!" ); break; case DEAD: break; } }
bool SimpleArmer::init() { ArmerSprite::init(); visibleSize = Director::getInstance()->getVisibleSize(); setStartPoint(Point(visibleSize.width/2, visibleSize.height + this->getContentSize().height/2)); this->setScale(visibleSize.width/this->getContentSize().width/5); setLife(5); setScore(800); setAction(); return true; }
void Player::receiveDamage( int damage, const QVector3D * position, const QVector3D * direction ) { if( !mGodMode ) { if( mArmor >= damage ) { mArmor -= damage; } else { int admg = damage - mArmor; mArmor -= (damage - admg); setLife( life() - admg ); if( life() <= 0 ) { if( state() == ALIVE ) setState( DYING ); setLife( 0 ); } } } }
Player::Player(Device* dev, SceneManager* scn, SceneNode* parent, std::string const& name, std::string const& shader, std::string const& path) :Entity(scn, parent, name, shader, path), dev(dev) { LOG(L_DEBUG, "Creating Player..."); setHp(9); setLife(3); setAttack(3); if (!static_cast<event::EventPlayer*>(this->dev->getEventManager()->getEventFromName("EventPlayer"))->getPlayer()) static_cast<event::EventPlayer*>(this->dev->getEventManager()->getEventFromName("EventPlayer"))->setPlayer(this); LOG(L_DEBUG, "Player has been created."); }
void Dummy::updateSelf( const double & delta ) { switch( state() ) { case SPAWNING: { setPosition( randomPointOnWorld( world() ) + QVector3D(0,10,0) ); setState( ALIVE ); setLife( 100 ); mHeightAboveGround = 6.0f; break; } case ALIVE: { mTarget = world()->teapot()->worldPosition(); QVector3D directionToTarget = ( mTarget - worldPosition() ).normalized(); QQuaternion targetRotation = Quaternion::lookAt( directionToTarget, QVector3D(0,1,0) ); setRotation( QQuaternion::slerp( rotation(), targetRotation, 0.05 ) ); setPosition( position() + direction()*delta*10.0 ); if( life() <= 0 ) setState( DYING ); break; } case DYING: setState( DEAD ); mHeightAboveGround = 3.0f; break; case DEAD: break; } mVelocityY += -3.0f * delta; // apply some gravity setPositionY( position().y() + mVelocityY * delta ); float landscapeHeight; if( world()->landscape()->terrain()->getHeight( position(), landscapeHeight ) ) { if( landscapeHeight + mHeightAboveGround > position().y() ) { setPositionY( landscapeHeight + mHeightAboveGround ); if( mVelocityY < 0.0f ) mVelocityY = 0.0f; } } }
ParticleSystemNode::ParticleSystemNode(Scene *scene_) : Node(scene_) { type = NODE_PARTICLESYSTEM; timeToSpawn = 0; box = BBox(vec3(-0.5, -0.5, -0.5), vec3(0.5, 0.5, 0.5)); particleBox = box; sphere = BSphere(vec3(), 0.5); first_update = true; setSpawnRate(5.0f); setLife(5.0f, 0.0f); setSize(0.1f, 0.0f); setGrowth(1.0f, 0.0f); setEmitter(EMITTER_BOX); setColor(vec3(0.5f, 0.5f, 0.0f), vec3(1.0f, 0.0f, 0.0f)); setSpeed(0.1f, 0.0f, 0.0f); setGravity(0.0f); setName(getTypeName()); }
void ArqueroIA::Recovery() { setLife(getLife()+1); }
void Entity::restore(float value) { setLife(mLife + value); }
void Aldeano::Recovery() { setLife(getLife()+1); }
void Ingredient::onUpdate(float dt) { if (dsq->game->isPaused()) return; if (dsq->game->isWorldPaused()) return; Vector lastPosition = position; Entity::onUpdate(dt); if (dsq->game->collideCircleWithGrid(position, 24)) { position = lastPosition; /* if (velocity.x < velocity.y) velocity.x = -velocity.x; else velocity.y = -velocity.y; */ velocity = 0; } if (lifeSpan > 0) { lifeSpan -= dt; if (lifeSpan <= 0) { lifeSpan = 0; gone = true; this->scale.interpolateTo(Vector(0,0),1); setLife(1); setDecayRate(1); } } Vector diff = (dsq->game->avatar->position - position); if (diff.isLength2DIn(64)) { if (scale.x == 1) { // got safeKill(); dsq->continuity.pickupIngredient(data, 1); dsq->game->pickupIngredientEffects(data); dsq->spawnParticleEffect("IngredientCollect", position); dsq->sound->playSfx("pickup-ingredient"); } } else { float len = 1024; if (dsq->game->avatar->isRolling() && diff.isLength2DIn(len)) { float maxSpeed = 1500; Vector maxV = diff; maxV.setLength2D(len); diff = maxV - diff; diff *= maxSpeed/len; velocity += diff * 1.5f * dt; } } velocity.capLength2D(1000); if (isRotKind() && !velocity.isZero()) { int mag = velocity.getLength2D(); if (velocity.x > 0) rotation.z += mag*0.01f; else rotation.z -= mag*0.01f; } Vector sub = velocity; if (!sub.isZero()) { sub.setLength2D(100*dt); velocity -= sub; } // collision? }
void TestScene::emit() { auto _emitter = ParticleSystemQuad::createWithTotalParticles(100); addChild(_emitter, 10); _emitter->setTexture(Director::getInstance()->getTextureCache()->addImage("images/test_lizi.png")); _emitter->setDuration(1.f); // gravity _emitter->setGravity(Vec2::ZERO); // angle _emitter->setAngle(90); _emitter->setAngleVar(0); // speed of particles _emitter->setSpeed(260); _emitter->setSpeedVar(0); // radial _emitter->setRadialAccel(-260); _emitter->setRadialAccelVar(0); // tagential _emitter->setTangentialAccel(00); _emitter->setTangentialAccelVar(0); // emitter position // _emitter->setPosition( Vec2(160,240) ); _emitter->setPosVar({2,10}); // life of particles _emitter->setLife(1); _emitter->setLifeVar(0); // spin of particles _emitter->setStartSpin(10000); _emitter->setStartSizeVar(360); _emitter->setEndSpin(0); _emitter->setEndSpinVar(360); // color of particles Color4F startColor(0.f, 0.5f, 0.f, 1.0f); _emitter->setStartColor(startColor); Color4F startColorVar(0.f, 0.1f, 0.f, 1.0f); _emitter->setStartColorVar(startColorVar); Color4F endColor(0.1f, 0.5f, 0.1f, 1.0f); _emitter->setEndColor(endColor); Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f); _emitter->setEndColorVar(endColorVar); // size, in pixels _emitter->setStartSize(5.0f); _emitter->setStartSizeVar(1.0f); _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE); // emits per second _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife()); // additive _emitter->setBlendAdditive(true); //addChild(_emitter); _emitter->setPosition(genPos({0.5,0.5})); // _emitter->runAction(RotateBy::create(10.f, 1000)); }
void Entity::inflige(float value) { setLife(mLife - value); }