u8* Get(u16 addr, bool w) { u8 prev = 0xFF; u8 slot = _head; for (;;) { if (_addrs[slot] == addr) // LRU { _flags[slot] |= w; BringToFront(slot,prev); return PageData(slot); } if (_next[slot] == 0xFF) break; prev = slot; slot = _next[slot]; } if (!w) return Seek(addr); BringToFront(slot,prev); // keep return Miss(addr); }
// 버서크 상태의 처리 void Berserk( int num_shot, // 아군의 샷의 수 int num_enemy, // 적기의 갯수 int num_bullet // 탄(적기의 탄)의 갯수 ) { static STATE_TYPE state=NORMAL; // 메인 캐릭터의 상태(처음에는 보통 상태) static int energy=0; // 에너지 static int berserk_energy=100; // 버서크 상태가 되기 위해 // 필요한 에너지 static int time; // 버서크 효과의 잔여시간 // 메인 캐릭터의 상태에 따라 분기 switch (state) { // 보통 상태 case NORMAL: // 보통 공격: // 구체적인 처리는 NormalAttack 함수에서 수행하기로 함. NormalAttack(); // 탄이나 적기와 접촉 판정: // 부딪히면 피해를 받음. // 판정이나 결과의 구체적인 처리는 HitEnemy, // HitBullet, Miss 함수에서 각각 수행하기로 함. for (int i=0; i<num_enemy; i++) if (HitEnemy(i)) Miss(); for (int i=0; i<num_bullet; i++) if (HitBullet(i)) Miss(); // 아군 캐릭터가 쏜 샷과 접촉 판정: // 에너지를 모음. // 판정이나 결과의 구체적인 처리는 HitShot, // DeleteShot 함수에서 각각 수행하기로 함. for (int i=0; i<num_shot; i++) { if (HitShot(i)) { energy++; DeleteShot(i); } } // 에너지 양 판단: // 에너지가 충분히 모였으면 // 버서크 상태로 이동함. // 에너지는 시간이 지남에 따라 저절로 감소됨. if (energy>=berserk_energy) { state=BERSERK; time=300; } else { energy--; } break; // 버서크 상태 case BERSERK: // 특수 공격: // 구체적인 처리는 SpecialAttack 함수에서 수행하기로 함. SpecialAttack(); // 적기나 탄과 접촉 판정: // 적기에는 피해를 주고 탄은 제거함. // 결과의 구체적인 처리는 DamageEnemy, // DeleteBullet 함수에서 각각 수행하기로 함. for (int i=0; i<num_enemy; i++) if (HitEnemy(i)) DamageEnemy(i); for (int i=0; i<num_bullet; i++) if (HitBullet(i)) DeleteBullet(i); // 남은 시간이 다 되었다면 약한 상태로 이동함. time--; if (time<=0) { state=WEAK; time=200; } break; // 약한 상태 case WEAK: // 적기나 탄과 접촉 판정: // 맞으면 피해를 받음. for (int i=0; i<num_enemy; i++) if (HitEnemy(i)) Miss(); for (int i=0; i<num_bullet; i++) if (HitBullet(i)) Miss(); // 남은 시간이 다 되었다면 보통 상태로 이동함. time--; if (time<=0) { state=NORMAL; energy=0; } break; } }
void Scene::setbg_3(){ QString load; if(difficulty==4) load=":/pics/pics/bg_oni.png"; else if(difficulty==3) load=":/pics/pics/bg_hard.png"; else if(difficulty==2) load=":/pics/pics/bg_normal.png"; else load=":/pics/pics/bg_easy.png"; QImage bg; bg.load(load); bg = bg.scaled(770,400); this->setBackgroundBrush(bg); text1->setText(title[s]); text1->setPos(488,9); addItem(text1); Map.setSongPlay(title[s]); track = new QMediaPlayer(this); track->setMedia(QUrl::fromLocalFile(QDir::toNativeSeparators(Map.trackPath))); VOL=(Map.map["SONGVOL"]-Map.map["SEVOL"])>0?(Map.map["SONGVOL"]-Map.map["SEVOL"]+50):70; track->setVolume(VOL); BPM=Map.map["BPM"]; Map.getMap(title[s],Map.star[difficulty-1]); Map.convert(setRandom); if(setRandom==true){ QPixmap ran; ran.load(":/pics/pics/optionicon_random.png"); randomTag = new QGraphicsPixmapItem; randomTag->setPos(199,83); randomTag->setPixmap(ran); addItem(randomTag); } if(setAuto==true){ QPixmap au; au.load(":/pics/pics/optionicon_auto.png"); autoTag = new QGraphicsPixmapItem; autoTag->setPos(394,72); autoTag->setPixmap(au); addItem(autoTag); } if(set30secMode==true){ QPixmap ctd; ctd.load(":/pics/pics/optionicon_demo.png"); countdownTag = new QGraphicsPixmapItem; countdownTag->setPos(294,72); countdownTag->setPixmap(ctd); addItem(countdownTag); countdown = new QTimer(this); QObject::connect(countdown , SIGNAL(timeout()) , this , SLOT(secondsLeft())); } songMap=Map.songMap; foreach (QString i, songMap) { qDebug()<<i<<endl; } RD = new QTimer(this); LD = new QTimer(this); RK = new QTimer(this); LK = new QTimer(this); rdp = new QGraphicsPixmapItem;ldp = new QGraphicsPixmapItem; rkp = new QGraphicsPixmapItem;lkp = new QGraphicsPixmapItem; QPixmap res; res.load(":/pics/pics/rd.png"); rdp->setPixmap(res);rdp->setPos(147,123); res.load(":/pics/pics/ld.png"); ldp->setPixmap(res);ldp->setPos(106,123); res.load(":/pics/pics/rk.png"); rkp->setPixmap(res);rkp->setPos(147,124); res.load(":/pics/pics/lk.png"); lkp->setPixmap(res);lkp->setPos(105,124); for(int i=0;i<4;i++){ add[i]=false; } QObject::connect(this , SIGNAL(PlayRdong()) , this , SLOT(playRdong())); QObject::connect(this , SIGNAL(PlayLdong()) , this , SLOT(playLdong())); QObject::connect(this , SIGNAL(PlayRka()) , this , SLOT(playRka())); QObject::connect(this , SIGNAL(PlayLka()) , this , SLOT(playLka())); QObject::connect(RD , SIGNAL(timeout()) , this , SLOT(playRdong())); QObject::connect(LD , SIGNAL(timeout()) , this , SLOT(playLdong())); QObject::connect(RK , SIGNAL(timeout()) , this , SLOT(playRka())); QObject::connect(LK , SIGNAL(timeout()) , this , SLOT(playLka())); AniTimer1 = new QTimer(this); QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(moveJudgement())); QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(FlySoul())); QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(MidSoul())); QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(WalkSoul())); QObject::connect(this , SIGNAL(Great()) , this , SLOT(GenGreat())); QObject::connect(this , SIGNAL(Good()) , this , SLOT(GenGood())); QObject::connect(this , SIGNAL(Miss()) , this , SLOT(GenMiss())); QObject::connect(this , SIGNAL(Combo()) , this , SLOT(ShowCombo())); QObject::connect(this , SIGNAL(Score()) , this , SLOT(ShowScore())); QObject::connect(this , SIGNAL(Jump()) , this , SLOT(donJump())); QObject::connect(this , SIGNAL(SoulF()) , this , SLOT(GenFlySoul())); QObject::connect(this , SIGNAL(SoulM()) , this , SLOT(GenMidSoul())); QObject::connect(this , SIGNAL(SoulW()) , this , SLOT(GenWalkSoul())); ex1.load(":/pics/pics/explosion_s4.png"); AniTimer2 = new QTimer(this); QObject::connect(AniTimer2 , SIGNAL(timeout()) , this , SLOT(RemoveExplode())); QObject::connect(this , SIGNAL(Explode()) , this , SLOT(GenExplode())); AniTimer3 = new QTimer(this); QObject::connect(AniTimer3 , SIGNAL(timeout()) , this , SLOT(Jumper())); jumper = new QGraphicsPixmapItem; jumper->setPos(0,0); addItem(jumper); AniTimer4 = new QTimer(this); QObject::connect(AniTimer4 , SIGNAL(timeout()) , this , SLOT(Dance())); loadDancerPic(); createDanceItem(); great=0;good=0;miss=0; combo=0;maxcombo=0;soul=0,score=0; secLeft=30;jumpPicNum=1; msec=60000/BPM/4+2; test=60000/BPM/16; waitfor=109*test/2+Map.map["OFFSET"]*1000; for(int i=0;i<10;i++){ numberPic[i].load(":/pics/pics/number_"+QString::number(i)+".png"); } for(int i=0;i<10;i++){ ctdnumberPic[i].load(":/pics/pics/number_"+QString::number(i)+".png"); } for(int i=0;i<10;i++){ scorenumberPic[i].load(":/pics/pics/scorenumber_"+QString::number(i)+".png"); } for(int i=50;i<1000;i+=100){ QSound *so; QString c; c=QString::number(i); so = new QSound(":/sound/sound/voice_"+c+"combo.wav"); comTrack.push_back(so); if(i==50)i+=50; } for(int i=0;i<3;i++){ jumpPic[i].load(":/pics/pics/playerchar_normal"+QString::number(i+1)+".png"); jumpPic[i] = jumpPic[i].scaled(jumpPic[i].width()*1.48,jumpPic[i].height()*1.48); } //Etimer = new QElapsedTimer; //Etimer->start(); timer = new QTimer(this); QObject::connect(timer , SIGNAL(timeout()) , this , SLOT(stopWait())); timer1 = new QTimer(this); timer2 = new QTimer(this); timer3 = new QTimer(this); cout<<"msec: "<<msec<<endl; cout<<"waitfor: "<<waitfor<<endl; QObject::connect(timer2 , SIGNAL(timeout()) , this , SLOT(Generate())); if(setAuto==false) QObject::connect(timer1 , SIGNAL(timeout()) , this , SLOT(Move())); else QObject::connect(timer1 , SIGNAL(timeout()) , this , SLOT(Auto())); QObject::connect(timer3 , SIGNAL(timeout()) , this , SLOT(startWave())); if(waitfor<0){ track->play(); timer->start(-waitfor); waitfor=0; } else timer->start(0); }
void JESBDTVars::FillBranches(EventContainer * evtObj){ //Evaluate each distribution once per JES shift for (int i = 0; i < evtObj->jets[0].GetNumberOfJESCorrections(); i++){ //First let's clear the things we already have selectedJet.clear(); Jet2040.clear(); BJet.clear(); UntaggedJet.clear(); //And make a dummy variable here Jet tempJet; TLorentzVector tempjet(0,0,0,0); //Number of loose jets for (auto jet : evtObj->alljets){ tempJet = jet; TLorentzVector tempmet(0,0,0,0); tempJet.ShiftPtWithJESCorr(i,&tempmet); if (tempJet.Pt() > 20 && tempJet.Pt() < 40) Jet2040.push_back(tempJet); } for (auto jet : evtObj->jesShiftedJets[i]){ selectedJet.push_back(jet); if (jet.IsTagged()) BJet.push_back(jet); else UntaggedJet.push_back(jet); } //Now set up the lepton and met variables TLorentzVector Lepton(00,0,0,0); TLorentzVector Miss(00,0,0,0); TLorentzVector Wlv(0,0,0,0); Miss = evtObj->metVecsJESShifted[i]; if (evtObj->electronsToUsePtr->size() > 0){ // if this number is >0 we're in the electron channel. Otherwise use muons Lepton.SetPtEtaPhiE(evtObj->electronsToUsePtr->at(0).Pt(),evtObj->electronsToUsePtr->at(0).Eta(),evtObj->electronsToUsePtr->at(0).Phi(),evtObj->electronsToUsePtr->at(0).E()); } else{ Lepton.SetPtEtaPhiE(evtObj->muonsToUsePtr->at(0).Pt(),evtObj->muonsToUsePtr->at(0).Eta(),evtObj->muonsToUsePtr->at(0).Phi(),evtObj->muonsToUsePtr->at(0).E()); } Wlv = Lepton+Miss; TLorentzVector W(0,0,0,0), Top(0,0,0,0); for (auto jet : UntaggedJet){ W = W + jet; } TLorentzVector totalJets(0,0,0,0); for (auto jet : selectedJet){ totalJets += jet; } //That should be all of the things we need to make the BDT variables, so let's make the variables now. _floatVecVars["M_DeltaRBJetLepton_JESShifts"][i] = fabs(BJet[0].DeltaR(Lepton)); if (UntaggedJet.size() > 1) _floatVecVars["M_DeltaRlightjets_JESShifts"][i] = UntaggedJet.at(0).DeltaR(UntaggedJet.at(1)); if (BJet[0].DeltaR(Lepton) > BJet[0].DeltaR(W)){ _floatVecVars["M_topMass2_lep_JESShifts"][i] = -1; } else{ Top = W + BJet[0]; _floatVecVars["M_topMass2_lep_JESShifts"][i] = Top.M(); } _floatVecVars["M_Pt_Lepton_JESShifts"][i] = Lepton.Pt(); _floatVecVars["M_Pt_AllJetsLeptonMET_JESShifts"][i] = (Lepton + Miss + totalJets).Pt(); _floatVecVars["M_DeltaRLeptonJet1_JESShifts"][i] = fabs(selectedJet.at(0).DeltaR(Lepton)); if (selectedJet.size() > 2) _floatVecVars["M_Mass_Jet1Jet2Jet3LeptonMET_JESShifts"][i] = (selectedJet[0] + selectedJet[1] + selectedJet[2]).M(); _floatVecVars["M_hadronicWmass_JESShifts"][i] = W.M(); _floatVecVars["lightJet1CSV_JESShifts"][i] = UntaggedJet[0].GetbDiscriminator(); } }