void GameScene::addEnemyTankGroup3() { addBarrier(Vec2(winsize.width/8*3,winsize.height)); addBarrier(Vec2(winsize.width/8*4,winsize.height)); addBarrier(Vec2(winsize.width/8*5,winsize.height)); addTower(Vec2(winsize.width/8*4,winsize.height+100)); }
void GameScene::addEnemyTankGroup4() { addBarrier(Vec2(winsize.width/8*1,winsize.height)); addBarrier(Vec2(winsize.width/8*2,winsize.height)); addBarrier(Vec2(winsize.width/8*3,winsize.height)); addTower(Vec2(winsize.width/16*3,winsize.height+100)); addEnemyTank2(Vec2(winsize.width/16*5,winsize.height+100)); addBarrier(Vec2(winsize.width/8*5,winsize.height)); addBarrier(Vec2(winsize.width/8*6,winsize.height)); addBarrier(Vec2(winsize.width/8*7,winsize.height)); addTower(Vec2(winsize.width/16*11,winsize.height+100)); addEnemyTank2(Vec2(winsize.width/16*13,winsize.height+100)); }
void GameScene::update( float dt ) { addBarrier(); addCloud(); position = character->getPosition(); if(gameState == 1) { dy = position.y + speed.y - visibleSize.height/2; if(dy > 0 && speed.y > 0) { bottomSprite->setPosition(bottomSprite->getPositionX(),bottomSprite->getPositionY()-dy); forestSprite->setPosition(forestSprite->getPositionX(),forestSprite->getPositionY()-dy); for(int i=0; i<barriers.size(); i++) { if(barriers.at(i)->isVisible()) { barriers.at(i)->setPositionY(barriers.at(i)->getPositionY()-dy); } else { delete barriers.at(i); barriers.erase(barriers.begin()+i); barrier++; } } for(int i=0; i<clouds.size(); i++) { if(clouds.at(i)->isVisible()) { clouds.at(i)->setPosition(Vect(clouds.at(i)->getPosition().x,clouds.at(i)->getPosition().y-dy)); } else { delete clouds.at(i); clouds.erase(clouds.begin()+i); } } if(position.x + speed.x > visibleSize.width) { character->setPosition(Vect(visibleSize.width,visibleSize.height/2)); } else if(position.x + speed.x < 0) { character->setPosition(Vect(0,visibleSize.height/2)); } else { character->setPosition(Vect(position.x+speed.x,visibleSize.height/2)); } } else { if(position.y + speed.y < character->getSize().height / 2 + bottomSprite->getPositionY() + bottomSprite->getContentSize().height / 2) { speed.x = 0; speed.y = 0; character->setPosition(Vect(position.x,character->getSize().height / 2 + bottomSprite->getPositionY() + bottomSprite->getContentSize().height / 2)); } else { if(position.x + speed.x > visibleSize.width) { character->setPosition(Vect(visibleSize.width,position.y+speed.y)); } else if(position.x + speed.x < 0) { character->setPosition(Vect(0,position.y+speed.y)); } else { character->setPosition(Vect(position.x+speed.x,position.y+speed.y)); } } } if(position.y - character->getSize().height / 2 < 0) { GameOver(); } if(position.y > barriers.at(score-barrier)->getPositionY()) { addScore(); } speed.y = speed.y - 1; } else if(gameState == 2) { if(position.y - character->getSize().height / 2 < 0) { GameOver(); } character->setPosition(Vect(position.x,position.y+speed.y)); speed.y = speed.y - 1; } }
ThresholdPressure::ThresholdPressure(const Deck& deck, const Eclipse3DProperties& eclipseProperties) { if( !Section::hasRUNSPEC( deck ) || !Section::hasSOLUTION( deck ) ) return; RUNSPECSection runspecSection( deck ); SOLUTIONSection solutionSection( deck ); bool thpresOption = false; const bool thpresKeyword = solutionSection.hasKeyword<ParserKeywords::THPRES>(); const bool hasEqlnumKeyword = eclipseProperties.hasDeckIntGridProperty( "EQLNUM" ); int maxEqlnum = 0; //Is THPRES option set? if( runspecSection.hasKeyword<ParserKeywords::EQLOPTS>() ) { const auto& eqlopts = runspecSection.getKeyword<ParserKeywords::EQLOPTS>( ); const auto& rec = eqlopts.getRecord(0); for( const auto& item : rec ) { if( !item.hasValue( 0 ) ) continue; const auto& opt = item.get< std::string >( 0 ); if( opt == "IRREVERS" ) throw std::runtime_error("Cannot use IRREVERS version of THPRES option, not implemented"); if( opt == "THPRES" ) thpresOption = true; } } if( thpresOption && !thpresKeyword ) { throw std::runtime_error("Invalid solution section; " "the EQLOPTS THPRES option is set in RUNSPEC, " "but no THPRES keyword is found in SOLUTION." ); } //Option is set and keyword is found if( thpresOption && thpresKeyword ) { if( !hasEqlnumKeyword ) throw std::runtime_error("Error when internalizing THPRES: EQLNUM keyword not found in deck"); //Find max of eqlnum const auto& eqlnumKeyword = eclipseProperties.getIntGridProperty( "EQLNUM" ); const auto& eqlnum = eqlnumKeyword.getData(); maxEqlnum = *std::max_element(eqlnum.begin(), eqlnum.end()); if (0 == maxEqlnum) { throw std::runtime_error("Error in EQLNUM data: all values are 0"); } // Fill threshold pressure table. const auto& thpres = solutionSection.getKeyword<ParserKeywords::THPRES>( ); for( const auto& rec : thpres ) { const auto& region1Item = rec.getItem<ParserKeywords::THPRES::REGION1>(); const auto& region2Item = rec.getItem<ParserKeywords::THPRES::REGION2>(); const auto& thpressItem = rec.getItem<ParserKeywords::THPRES::VALUE>(); if( !region1Item.hasValue( 0 ) || !region2Item.hasValue( 0 ) ) throw std::runtime_error("Missing region data for use of the THPRES keyword"); const int r1 = region1Item.get< int >(0); const int r2 = region2Item.get< int >(0); if (r1 > maxEqlnum || r2 > maxEqlnum) { throw std::runtime_error("Too high region numbers in THPRES keyword"); } if (thpressItem.hasValue(0)) { addBarrier( r1 , r2 , thpressItem.getSIDouble( 0 ) ); } else addBarrier( r1 , r2 ); } } }