void WeakRefArray::clear_non_marked( OopDesc** p ) { if( ObjectHeap::in_collection_area_unmarked( *p ) ) { *p = dead(); // object is not marked. It will be GC'ed } }
void Boss::update() { if (active) { animation.sprite.setPosition(getPosition().x, getPosition().y); shadow.sprite.setPosition(getPosition().x, getPosition().y + 10); animation.update(); shadow.update(); movementManager(); if (GameTime::Instance()->getElapsedTime().asMilliseconds() > startTime) { if (sprite.getPosition().y < 200 && !activeMovement) sprite.move(0, speed); else if (!inZone) inZone = true; else if (!activeDead) { // rect[0] = partie centrale // rect[1] = partie arrière // rect[2] = partie du bas gauche // rect[3] = partie du bas droite // rect[4] = canon gauche // rect[5] = canon droit scenario(stage); if (stage == 1) { rect[0] = IntRect((int) sprite.getPosition().x - (getSize().x / 2) - 20, (int) (sprite.getPosition().y - (getSize().y / 2)), (int) 175, (int) 50); rect[1] = IntRect((int) sprite.getPosition().x - (getSize().x / 2) - 20, (int) (sprite.getPosition().y - (getSize().y / 2) - 40), (int) 175, (int) 30); rect[2] = IntRect((int) sprite.getPosition().x - (getSize().x / 2) - 20, (int) sprite.getPosition().y + 15, (int) 64, (int) 50); rect[3] = IntRect((int) sprite.getPosition().x + 24, (int) sprite.getPosition().y + 15, (int) 64, (int) 50); rect[4] = IntRect((int) sprite.getPosition().x - (getSize().x / 2) - 60, (int) (sprite.getPosition().y - (getSize().y / 2) - 20), (int) 40, (int) 100); rect[5] = IntRect((int) sprite.getPosition().x + 88, (int) (sprite.getPosition().y - (getSize().y / 2) - 20), (int) 40, (int) 100); } else if (stage == 2) { rect[0] = IntRect((int) sprite.getPosition().x - 39, (int) sprite.getPosition().y - 70, (int) 80, (int) 130); rect[1] = IntRect((int) sprite.getPosition().x - 30, (int) sprite.getPosition().y + 60, (int) 60, (int) 10); rect[2] = IntRect((int) sprite.getPosition().x - 90, (int) sprite.getPosition().y - 55, (int) 60, (int) 70); rect[3] = IntRect((int) sprite.getPosition().x + 30, (int) sprite.getPosition().y - 55, (int) 60, (int) 70); rect[4] = IntRect((int) sprite.getPosition().x - 107, (int) sprite.getPosition().y - 20, (int) 45, (int) 80); rect[5] = IntRect((int) sprite.getPosition().x + 63, (int) sprite.getPosition().y - 20, (int) 45, (int) 80); } else if (stage == 3) { rect[0] = IntRect((int) sprite.getPosition().x - 150, (int) sprite.getPosition().y - 70, (int) 300, (int) 140); rect[1] = IntRect((int) sprite.getPosition().x - 5, (int) sprite.getPosition().y + 40, (int) 20, (int) 70); rect[2] = IntRect((int) sprite.getPosition().x - 180, (int) sprite.getPosition().y + 10, (int) 35, (int) 55); rect[3] = IntRect((int) sprite.getPosition().x + 150, (int) sprite.getPosition().y + 10, (int) 35, (int) 55); } else if (stage == 4) { } // Changement des couleurs selon la collision for (unsigned char i = 0; i < 6; i++) { if (collision[i] == 1) { if (lastCollision == 0) lastCollision = GameTime::Instance()->getElapsedTime().asMilliseconds(); if (i < 4) sprite.setColor(color[1]); else if (i > 3) sprite.setColor(color[2]); if (GameTime::Instance()->getElapsedTime().asMilliseconds() - lastCollision > 100) { sprite.setColor(color[0]); collision[i] = 0; lastCollision = 0; } } } if (stage == 1 || stage == 2) { for (unsigned char i = 0; i < 3; i++) { if (health[i] < 0) { health[i] = 0; } } if (!activeCanonA) { if (lastTimeA == 0) lastTimeA = GameTime::Instance()->getElapsedTime().asMilliseconds(); else if (GameTime::Instance()->getElapsedTime().asMilliseconds() - lastTimeA > 10000) { if (gameDifficulty == 2) health[1] = 1000; else if (gameDifficulty == 1) health[1] = 2000; else if (gameDifficulty == 2) health[1] = 3000; activeCanonA = true; lastTimeA = 0; } } if (!activeCanonB) { if (lastTimeB == 0) lastTimeB = GameTime::Instance()->getElapsedTime().asMilliseconds(); else if (GameTime::Instance()->getElapsedTime().asMilliseconds() - lastTimeB > 10000) { if (gameDifficulty == 2) health[2] = 1000; else if (gameDifficulty == 1) health[2] = 2000; else if (gameDifficulty == 2) health[2] = 3000; activeCanonB = true; lastTimeB = 0; } } } #ifdef _DEBUG if (showRectangle) for (unsigned char i = 0; i < 6; i++) { rectShape[i].setPosition(rect[i].left, rect[i].top); rectShape[i].setSize(Vector2f(rect[i].width, rect[i].height)); } rectOrigin.setPosition(getPosition()); #endif } } if (health[0] <= 0) dead(); else { portionEnergy = (health[0] * 100) / energyfix; portionEnergy = portionEnergy / 10; if (portionEnergy < 1) portionEnergy = 1; } } redShape.update(); animation.sprite.setColor(sprite.getColor()); }
//============================================================================================================= void Avatar::Update() { // robbanáskor mi történjen if( state & Exploded ) { // lehetne az életet is nézni, de akkor eggyel elöbb hal bool alive = ((state & Invincible) == Invincible); // lejárt-e a várakozási idö if( flashticks > (unsigned)(alive ? 5 : 20) ) { // nincs több élet, meghalt if( !alive ) { dead(); } // van még élet, egy kis idöre halhatatlan lesz else { flashticks = 0; power = 0; empowerticks = 0; Position = InitialPosition; DisableControls(false); state = Invincible; } } else ++flashticks; } else { // halhatatlan modban vagyunk if( state & Invincible ) { // lejárt-e az idö if( flashticks > 25 ) { flashticks = 0; state &= (~Invincible); } else { ++flashticks; // villogtatjuk if( flashticks % 4 == 0 ) drawornot = !drawornot; } } // felvett egy powerupot if( state & Empowered ) { if( empowerticks > (size_t)power.count() + 1 ) state &= (~Empowered); else { ++empowerticks; power.step(); } } // találat érte, de a pajzs felfogta if( shieldticks <= shield.count() + 1 ) { shield.step(); ++shieldticks; } } // minden mennyiséget a felbontáshoz kell igazitani float maxvel = GameVariables::CorrelateH(Speed); float accel = GameVariables::CorrelateH(Acceleration); float resist = GameVariables::CorrelateH(Resistance); float length; direction.x = direction.y = 0; if( state & Forward ) direction.x = (state & Backward ? 0.0f : 1.0f); else if( state & Backward ) direction.x = -1; if( state & Up ) direction.y = (state & Down ? 0.0f : -1.0f); else if( state & Down ) direction.y = 1; D3DXVec2Normalize(&direction, &direction); velocity += direction * accel; D3DXVec2Normalize(&resistance, &velocity); length = D3DXVec2Length(&velocity); // max sebesség if( length > maxvel ) velocity = resistance * maxvel; // légellenállás if( length > resist ) velocity -= resistance * resist; else velocity.x = velocity.y = 0; // fix idöközönként lehet löni if( state & Shoot ) { if( cooldown == 0 ) { shoot(); cooldown = WeaponCooldown; } } Position.extend(velocity); // ne menjen ki a képernyöröl if( DummyFramework::CHelper::Clamp2<float>(Position.current.x, Bounds.x, Bounds.z - Image->Size.x) ) velocity.x = 0; if( DummyFramework::CHelper::Clamp2<float>(Position.current.y, Bounds.y, Bounds.w - Image->Size.y) ) velocity.y = 0; if( cooldown > 0 ) --cooldown; }
void Rabbit::tick() { ++age; if (mood == &Rabbit::dead) { dead(); return; } // Health cannot be higher than weight if (health > weight) health = weight; if (age % 10 == 0) { if (pregnant > 0) { ++pregnant; --stomach; // It's fifty-fifty to give birth this second // expected time of pregnancy is 20 + 0.25 + 2*0.125 + 3*0.0775 + ... = if (pregnant > 20 && rand() & 1) { // Give birth bool boy = rand() & 1; Rabbit *child = new Rabbit(get_x(), get_y(), boy); child->weight = pregnant; world->add_entity(child); pregnant = 0; if (boy) printf("a cute little rabbit boy was born\n"); else printf("a cute little rabbit girl was born\n"); } } // Calm down if (fear > 0) --fear; } if (age % 20 == 0) { // Digest food if (stomach > 0) { --stomach; ++health; } else { --health; } } if (health <= 0) { mood = &Rabbit::dead; return; } // Can't do anything if picked up if (parent != 0) return; // Panic if fear is high if (fear >= 20) mood = &Rabbit::panic; (this->*mood)(); }
void startGame() { gc_InitGraph(); gc_DrawBuffer(); gc_SetTextColor(0xFF00); gc_FillScrn(0xFF); gc_SwapDraw(); srand(*(unsigned long*)0xF30044); clearTile(&buffer1); clearTile(&buffer2); clearTile(&buffer3); setRandomTile(&buffer1); setRandomTile(&buffer2); setRandomTile(&buffer3); buffer1Active = true; buffer2Active = true; buffer3Active = true; currentBufferInUse = 1; exitSection = false; movesRemaining = true; boardx = 3; boardy = 18; selectx = 0; selecty = 0; score = 0; drawBoardStart(); canDrawTileBool = true; while (exitSection == false) { checkBuf(); drawBoardRF(); gc_SetTextXY(275, 5); gc_PrintInt(score, 5); if (currentBufferInUse == 1) { drawTileHover(buffer1, selectx, selecty); } if (currentBufferInUse == 2) { drawTileHover(buffer2, selectx, selecty); } if (currentBufferInUse == 3) { drawTileHover(buffer3, selectx, selecty); } /*if (canDrawTileBool == true) { gc_SetColorIndex(0x47); gc_NoClipRectangleOutline(selectx * 21 + boardx, selecty * 21 + boardy, 21, 21); } else { gc_SetColorIndex(0xE0); gc_NoClipRectangleOutline(selectx * 21 + boardx, selecty * 21 + boardy, 21, 21); }*/ drawBuffers(); gc_SwapDraw(); if (!darkMode) { gc_SetColor(0xFF, gc_RGBTo1555(255, 255, 255)); } else { gc_SetColor(0xFF, gc_RGBTo1555(26, 26, 26)); } gc_FillScrn(0xFF); key = kb_ScanGroup(kb_group_7); if (key & kb_Down) { if (currentBufferInUse == 1) { inBounds(buffer1, selectx, selecty+1); } if (currentBufferInUse == 2) { inBounds(buffer2, selectx, selecty+1); } if (currentBufferInUse == 3) { inBounds(buffer3, selectx, selecty+1); } if (selecty < 9 && canDrawTileBool) { selecty++; if (currentBufferInUse == 1) { canDrawTile(buffer1, selectx, selecty); } if (currentBufferInUse == 2) { canDrawTile(buffer2, selectx, selecty); } if (currentBufferInUse == 3) { canDrawTile(buffer3, selectx, selecty); } } } if (key & kb_Up) { if (currentBufferInUse == 1) { inBounds(buffer1, selectx, selecty-1); } if (currentBufferInUse == 2) { inBounds(buffer2, selectx, selecty-1); } if (currentBufferInUse == 3) { inBounds(buffer3, selectx, selecty-1); } if (selecty > 0 && canDrawTileBool) { selecty--; if (currentBufferInUse == 1) { canDrawTile(buffer1, selectx, selecty); } if (currentBufferInUse == 2) { canDrawTile(buffer2, selectx, selecty); } if (currentBufferInUse == 3) { canDrawTile(buffer3, selectx, selecty); } } } if (key & kb_Left) { if (currentBufferInUse == 1) { inBounds(buffer1, selectx-1, selecty); } if (currentBufferInUse == 2) { inBounds(buffer2, selectx-1, selecty); } if (currentBufferInUse == 3) { inBounds(buffer3, selectx-1, selecty); } if (selectx > 0 && canDrawTileBool) { selectx--; if (currentBufferInUse == 1) { canDrawTile(buffer1, selectx, selecty); } if (currentBufferInUse == 2) { canDrawTile(buffer2, selectx, selecty); } if (currentBufferInUse == 3) { canDrawTile(buffer3, selectx, selecty); } } } if (key & kb_Right) { if (currentBufferInUse == 1) { inBounds(buffer1, selectx+1, selecty); } if (currentBufferInUse == 2) { inBounds(buffer2, selectx+1, selecty); } if (currentBufferInUse == 3) { inBounds(buffer3, selectx+1, selecty); } if (selectx < 9 && canDrawTileBool) { selectx++; if (currentBufferInUse == 1) { canDrawTile(buffer1, selectx, selecty); } if (currentBufferInUse == 2) { canDrawTile(buffer2, selectx, selecty); } if (currentBufferInUse == 3) { canDrawTile(buffer3, selectx, selecty); } } } if (selectx > 9 || selectx < 0) { selectx = 0; } if (selecty > 9 || selecty < 0) { selecty = 0; } key = kb_ScanGroup(kb_group_6); if (key & kb_Clear) { exitSection = true; } key = kb_ScanGroup(kb_group_1); if (key & kb_2nd) { if (currentBufferInUse == 1) { canDrawTile(buffer1, selectx, selecty); } if (currentBufferInUse == 2) { canDrawTile(buffer2, selectx, selecty); } if (currentBufferInUse == 3) { canDrawTile(buffer3, selectx, selecty); } if (canDrawTileBool) { if (currentBufferInUse == 1) { drawTile(buffer1, selectx, selecty); } if (currentBufferInUse == 2) { drawTile(buffer2, selectx, selecty); } if (currentBufferInUse == 3) { drawTile(buffer3, selectx, selecty); } if (currentBufferInUse == 1) { buffer1Active = false; clearTile(&buffer1); } if (currentBufferInUse == 2) { buffer2Active = false; clearTile(&buffer2); } if (currentBufferInUse == 3) { buffer3Active = false; clearTile(&buffer3); } currentBufferInUse++; if (currentBufferInUse == 4) { currentBufferInUse = 1; } checkBuf(); checkForTileRows(); if (currentBufferInUse == 1) { canDrawTile(buffer1, selectx, selecty); } if (currentBufferInUse == 2) { canDrawTile(buffer2, selectx, selecty); } if (currentBufferInUse == 3) { canDrawTile(buffer3, selectx, selecty); } anyMovesLeft(); if (!movesRemaining) { exitSection = true; } } } if (key & kb_Mode) { darkMode = !darkMode; while (kb_AnyKey()) { } } key = kb_ScanGroup(kb_group_2); if (key & kb_Alpha) { currentBufferInUse++; if (currentBufferInUse == 4) { currentBufferInUse = 1; } checkBuf(); dbg_printf(dbgout, "cbiu %d", currentBufferInUse); while (kb_AnyKey()) { } } } saveNewHS(score); dead(); }
UINT GjThreadProc(LPVOID lpParamter) { DWORD isSelectGw = 0; DWORD gwPoint,one; int gwId =0; int hp = 0; int jnID; float rwgwjl;//人物与怪物的距离 BYTE isUsejn;//技能是否能使用 float gwx,gwy; while (isGjFlag) { ReadProcessMemory(PID, (LPCVOID)(rwBaseAddr + 0x254), &hp, 4, 0); if(hp == 0){ dead(); }else{ addHpMp(false); ReadProcessMemory(PID, (LPCVOID)(rwBaseAddr + 0x7b8), &isSelectGw, 4, 0); if (isSelectGw == 0) { if(dlxiaoDllDlg->IsDlgButtonChecked(IDC_CHECK_ISSELL)){ bagfull(); } Pick(); addHpMp(true); addfz(); dingdian(); gwPoint = getGwPoint(); if(gwPoint != 0){ ReadProcessMemory(PID,(LPCVOID)(gwPoint+8),&gwId,4,0); if (gwId != 0 ) { CallSelectGw(gwId); } } } else { CallNormal(); readRwXY(); ReadProcessMemory(PID, (LPCVOID)(gwPoint + 0x4), &one, 4, 0); ReadProcessMemory(PID, (LPCVOID)(one + 0x3C), &gwx, sizeof(FLOAT), 0); ReadProcessMemory(PID, (LPCVOID)(one + 0x44), &gwy, sizeof(FLOAT), 0); rwgwjl = sqrtf(powf((rwX - gwx), 2) + powf((rwY - gwy), 2)); if(dlxiaoDllDlg->IsDlgButtonChecked(IDC_CHECK_ISUSERJN) && (rwgwjl <= 3) && usejnidx > -1){ ReadProcessMemory(PID, (LPCVOID)(jnPointerArray.GetAt(usejnidx) + 0x8), &jnID, 4, 0); if(jnID){ ReadProcessMemory(PID, (LPCVOID)(jnPointerArray.GetAt(usejnidx) + 0xC), &isUsejn, 1, 0); if(isUsejn == 0){ CallUserSkill(jnID,gwId); } } } Sleep(500); } } } return (0); }
//---------------------------------------------- void ttChar::update(){ float x = 20; float scale = 10; if (charNum == 0) { if (accFroce->x > -0.15) { if (control->bTouch[0]&&control->bTouch[1]) { bDouPressed =true; }else if (control->bTouch[0] && !control->bTouch[1]) { character.addForce(ofPoint(-x,0), scale); bDouPressed =false; mirrorLeft = false; }else if (control->bTouch[1] && !control->bTouch[0]) { character.addForce(ofPoint(x,0), scale); bDouPressed =false; mirrorLeft = true; }else if(!control->bTouch[0] && !control->bTouch[1] && !bInSky){ // character.setVelocity(0, character.getVelocity().y); } } if (character.getVelocity().x > 10) { character.setVelocity(10, character.getVelocity().y); }else if(character.getVelocity().x < -10){ character.setVelocity(-10, character.getVelocity().y); } } if (charNum == 1) { if (accFroce->x < 0.15) { if (control->bTouch[2]&&control->bTouch[3]) { bDouPressed =true; }else if (control->bTouch[2]&&!control->bTouch[3]) { character.addForce(ofPoint(-x,0), scale); bDouPressed =false; mirrorLeft = true; }else if (control->bTouch[3]&& !control->bTouch[2]) { character.addForce(ofPoint(x,0), scale); bDouPressed =false; mirrorLeft = false; }else if(!control->bTouch[2]&&!control->bTouch[3]&&!bInSky){ // character.setVelocity(0, character.getVelocity().y); } } if (character.getVelocity().x > 10) { character.setVelocity(10, character.getVelocity().y); }else if(character.getVelocity().x < -10){ character.setVelocity(-10, character.getVelocity().y); } } dead(); destroyRect(); if (!bSwing) { getPos = character.getPosition(); } }
void Bug::hit(double dmg) { hp -= dmg - resist; if (hp <= 0) emit dead(this); }
constexpr int bad() { int &&n = dead(); n = 1; return n; } // expected-note {{assignment to temporary whose lifetime has ended}}
bool Npc::update(long dt) { if (!Entity::update(dt)) return false; _ai->getCharacter()->setSpeed(_attribs.getCurrent(attrib::Types::SPEED)); return !dead(); }
Player::Player(tmx::MapLoader& map, Coins& coins, EnemiesManager& enemyManager, Star& star) : mSpriteSize(48,48) , mIsJumping(false) , mFrictionStart(0.95) , mFrictionStop(0.8) , mFrictionVertical(5) , mIsMovingLeft(false) , mIsMovingRight(false) , mCollisionLeft(false) , mCollisionRight(false) , mCollisionUp(false) , mCollisionDown(false) , mPlayerDead(false) , mLevelCompleted(false) , mCollMarg(6) , mAnimation() { mMap=↦ mCoins = &coins; mEnemyManager = &enemyManager; mStar = ☆ mFont.loadFromFile("Media/Fonts/Raleway.ttf"); mleftMargin = 8; mRightMargin = 8; mTopMargin = 0; mBottomMargin = 5; Animation right(sf::seconds(1.0f)); right.setMargins(mleftMargin,mRightMargin,mTopMargin,mBottomMargin); for(int i=0;i<7;i++) right.addFrame(sf::IntRect(mSpriteSize.y*i, mSpriteSize.y*5, mSpriteSize.x,mSpriteSize.y)); mAnimation.addAnimation("right",right); Animation stay(sf::seconds(3.0f)); stay.setMargins(mleftMargin,mRightMargin,mTopMargin,mBottomMargin); for(int i=0;i<4;i++) stay.addFrame(sf::IntRect(mSpriteSize.y*i, mSpriteSize.y*2, mSpriteSize.x,mSpriteSize.y)); mAnimation.addAnimation("stay",stay); Animation jump(sf::seconds(1.0f)); jump.setMargins(mleftMargin,mRightMargin,mTopMargin,mBottomMargin); for(int i=0;i<6;i++) jump.addFrame(sf::IntRect(mSpriteSize.y*i, mSpriteSize.y*7, mSpriteSize.x,mSpriteSize.y)); jump.isRepeatable(false); mAnimation.addAnimation("jump",jump); Animation fall(sf::seconds(1.0f)); fall.setMargins(mleftMargin,mRightMargin,mTopMargin,mBottomMargin); for(int i=3;i<6;i++) fall.addFrame(sf::IntRect(mSpriteSize.y*i, mSpriteSize.y*7, mSpriteSize.x,mSpriteSize.y)); fall.isRepeatable(false); mAnimation.addAnimation("fall",fall); Animation dead(sf::seconds(1.0f)); dead.setMargins(mleftMargin,mRightMargin,mTopMargin,mBottomMargin+7); for(int i=0;i<3;i++) dead.addFrame(sf::IntRect(mSpriteSize.y*i, mSpriteSize.y*8, mSpriteSize.x,mSpriteSize.y)); mAnimation.addAnimation("dead",dead); mAnimation.playAnimation("stay"); }
//---------------------------------------------- void ttChar::update() { float x =20; float scale = 1000; float smallMove; float smallMoveSale = 1.2; if (charNum == 0) { if (bFixedMove==true) { control_A->bSmallLeft = false; control_A->bSmallRight = false; control_A->bLeft = false; control_A->bRight = false; if (bReset) { character.setVelocity(0, 0); bReset = false; } } else { bReset = true; if (control_A->diff.x>1||control_A->diff.x<-1) { smallMove = control_A->diff.x*smallMoveSale; } else { smallMove = 0; } if (control_A->bLeft == true && character.getVelocity().x< 15) { character.addForce(ofVec2f(x,0), scale); control_A->bLeft = false; mirrorLeft = true; } else if(control_A->bRight == true && character.getVelocity().x> -15) { character.addForce(ofVec2f(-x,0), scale); control_A->bRight = false; mirrorLeft = false; } else if (control_A->bSmallLeft == true) { character.setVelocity(smallMove, 0); control_A->bSmallLeft = false; mirrorLeft = true; } else if(control_A->bSmallRight == true) { character.setVelocity(smallMove, 0); control_A->bSmallRight = false; mirrorLeft = false; } } } if(charNum == 1) { if (bFixedMove == true) { control_B->bSmallLeft = false; control_B->bSmallRight = false; control_B->bLeft = false; control_B->bRight = false; if (bReset) { character.setVelocity(0, 0); bReset = false; } } else { bReset = true; if (control_B->diff.x>1||control_B->diff.x<-1) { smallMove = control_B->diff.x*smallMoveSale; } else { smallMove = 0; } if (control_B->bLeft == true && character.getVelocity().x>-15) { character.addForce(ofVec2f(-x,0), scale); control_B->bLeft = false; mirrorLeft = true; } else if(control_B->bRight == true && character.getVelocity().x<15) { character.addForce(ofVec2f(x,0), scale); control_B->bRight = false; mirrorLeft = false; } else if (control_B->bSmallLeft == true) { character.setVelocity(smallMove, 0); control_B->bSmallLeft = false; mirrorLeft = true; } else if(control_B->bSmallRight == true) { character.setVelocity(smallMove, 0); control_B->bSmallRight = false; mirrorLeft = false; } } } if (bSwing) { swing(); } else { getPos = character.getPosition(); bHookIt = false; } dead(); if (joints.empty()&&!rects.empty()) { alpha-=5; } if (alpha<=100) { destroyRect(); alpha = 255; bDestroyRect = false; } }
void Character::die() { emit(dead()); }
template <> void funcToSpecialize<int>() { halt(); dead(); // expected-warning {{will never be executed}} }
Hero::~Hero() { dead(); }
void test2() { int i; switch (live()) { case 1: halt(), dead(); // expected-warning {{will never be executed}} case 2: live(), halt(), dead(); // expected-warning {{will never be executed}} case 3: live() + // expected-warning {{will never be executed}} halt(); dead(); case 4: a4: live(), halt(); goto a4; // expected-warning {{will never be executed}} case 5: goto a5; c5: dead(); // expected-warning {{will never be executed}} goto b5; a5: live(), halt(); b5: goto c5; case 6: if (live()) goto e6; live(), halt(); d6: dead(); // expected-warning {{will never be executed}} goto b6; c6: dead(); goto b6; e6: live(), halt(); b6: goto c6; case 7: halt() + dead(); // expected-warning {{will never be executed}} - // expected-warning {{will never be executed}} halt(); case 8: i += // expected-warning {{will never be executed}} halt(); case 9: halt() ? // expected-warning {{will never be executed}} dead() : dead(); case 10: ( // expected-warning {{will never be executed}} float)halt(); case 11: { int a[5]; live(), a[halt() ]; // expected-warning {{will never be executed}} } } }
//---------------------------------------------- void ttChar::update(){ float x =20; float scale = 1000; float smallMove; float smallMoveSale = 1.2; if (charNum == 0) { if (bFixedMove==true){ control_A->bSmallLeft = false; control_A->bSmallRight = false; control_A->bLeft = false; control_A->bRight = false; if (bReset) { character.setVelocity(0, 0); bReset = false; } }else{ bReset = true; if (control_A->diff.x>1||control_A->diff.x<-1) { smallMove = control_A->diff.x*smallMoveSale; } else { smallMove = 0; } if (control_A->bLeft == true && character.getVelocity().x< 15) { character.addForce(ofVec2f(x,0), scale); control_A->bLeft = false; mirrorLeft = true; } else if(control_A->bRight == true && character.getVelocity().x> -15) { character.addForce(ofVec2f(-x,0), scale); control_A->bRight = false; mirrorLeft = false; }else if (control_A->bSmallLeft == true) { character.setVelocity(smallMove, 0); control_A->bSmallLeft = false; mirrorLeft = true; } else if(control_A->bSmallRight == true) { character.setVelocity(smallMove, 0); control_A->bSmallRight = false; mirrorLeft = false; } } } if(charNum == 1){ if (bFixedMove == true) { control_B->bSmallLeft = false; control_B->bSmallRight = false; control_B->bLeft = false; control_B->bRight = false; if (bReset) { character.setVelocity(0, 0); bReset = false; } } else { bReset = true; if (control_B->diff.x>1||control_B->diff.x<-1) { smallMove = control_B->diff.x*smallMoveSale; }else{ smallMove = 0; } if (control_B->bLeft == true && character.getVelocity().x>-15) { character.addForce(ofVec2f(-x,0), scale); control_B->bLeft = false; mirrorLeft = true; } else if(control_B->bRight == true && character.getVelocity().x<15) { character.addForce(ofVec2f(x,0), scale); control_B->bRight = false; mirrorLeft = false; }else if (control_B->bSmallLeft == true) { character.setVelocity(smallMove, 0); control_B->bSmallLeft = false; mirrorLeft = true; } else if(control_B->bSmallRight == true){ character.setVelocity(smallMove, 0); control_B->bSmallRight = false; mirrorLeft = false; } } } swing(); dead(); getPos = character.getPosition(); }
void enemy::update (float elapsed) { if (firstFrame) { //to ensure that larger AI creatures don't start in walls move(1, 0.01f); move(-1, 0.01f); jump(0.01f); firstFrame = false; } //keep track of position, for animation purposes if (!isParalyzed()) lastX = x; if (AItype == 5 || isParalyzed() || summonEffectActive()) { //just stop here; the chest AI doesn't do anything, literally //and paralyzed AIs dont either creature::update(elapsed); return; } //clean up targets if (target != NULL && target != this) { if (target->dead() || target->invisible()) target = NULL; else { float xDif = target->getX() + target->getMaskWidth() / 2 - getX() - getMaskWidth() / 2; float yDif = target->getY() + target->getMaskHeight() / 2 - getY() - getMaskHeight() / 2; float dif = sqrt(xDif * xDif + yDif * yDif); if (dif > FORGETRANGE) target = NULL; //they got too far away; forget them } } if (!dead()) { //general AI behavior if (teleportMagic && healthFraction() <= 0.5f && magic != DATA_NONE && target != NULL) { //use the magic global_map->magic(this, magic, TYPE_PLAYER); //halts your attack animation, if necessary setAttackAnim(-1); //teleport to behind him facingX = target->getFacingX(); x = target->getX() - facingX * (weaponReach() + getMaskWidth() / 2); y = target->getY(); //you can only do this once, so forget your magic magic = DATA_NONE; teleportMagic = false; } else if (defenseHops && hopDir == 0 && target != NULL && target->hopCue(this)) { if (target->getX() + target->getMaskWidth() / 2 > getX() + getMaskWidth() / 2) hopDir = -1; else hopDir = 1; jump(HOP); } else if (retreatMagic && healthFraction() < RETREATPOINT && retreatPhase == -1) { retreatPhase = 0; retreatTimer = RETREATDUR; } if (retreatPhase == 0) { //run away retreatTimer -= elapsed; if (retreatTimer <= 0 || target == NULL) { retreatPhase = 1; retreatTimer = RETREATMAGICTIMER; } else { int retreatDir; if (target->getX() + target->getMaskWidth() / 2 > getX() + getMaskWidth() / 2) retreatDir = -1; else retreatDir = 1; move(retreatDir, elapsed * RETREATSPEEDBONUS); if (!isOnscreen()) { //you don't want to quite get offscreen, so go back move(-retreatDir, elapsed * RETREATSPEEDBONUS); retreatTimer = 0; } } } else if (retreatPhase == 1) { if (target != NULL) { if (target->getX() + target->getMaskWidth() / 2 > getX() + getMaskWidth() / 2) facingX = 1; else facingX = -1; } retreatTimer -= elapsed; if (retreatTimer <= 0) { retreatTimer = RETREATMAGICTIMER; global_map->magic(this, magic, TYPE_PLAYER); } if (target != NULL && abs(target->getX() + target->getMaskWidth() / 2 - getX() - getMaskWidth() / 2) < STOPRETREATDIS) retreatPhase = 2; //retreating is now disabled if (healthFraction() == 1.0f) retreatPhase = -1; //stop retreating } else if (hopDir != 0) { move(hopDir, elapsed); if (grounded()) hopDir = 0; } else switch(AItype) { case 0: basicAI(elapsed); break; case 1: archerAI(elapsed); break; case 2: manhackAI(elapsed); break; case 3: flowerAI(elapsed); break; case 4: animalAI(elapsed); break; case 5: //chest ai break; case 6: bigWolfAI(elapsed); break; case 7: wolfMakerAI(elapsed); break; case 8: wolfMadeAI(elapsed); break; case 9: neoRollerAI(elapsed); break; case 10: copterAI(elapsed); break; case 11: wprinAI(elapsed); break; case 12: kingAI(elapsed); break; } } creature::update(elapsed); }