void ChimicBlok::collidesWithItem(KGLPhysicsItem * item) { if ( item->objectName()=="CHIMIC_BLOCK") { explose(5,3); setRemove(true); } }
void PackageWidget::actOnPackages(QApt::Package::State action) { const QApt::PackageList packages = selectedPackages(); if (packages.isEmpty()) return; QApplication::setOverrideCursor(Qt::WaitCursor); saveState(); m_backend->setCompressEvents(true); m_stop = false; for (QApt::Package *package : packages) { if (m_stop) { m_backend->setCompressEvents(false); QApplication::restoreOverrideCursor(); break; } switch (action) { case QApt::Package::ToInstall: setInstall(package); break; case QApt::Package::ToRemove: setRemove(package); break; case QApt::Package::ToUpgrade: setUpgrade(package); break; case QApt::Package::ToReInstall: if (package->isInstalled()) setReInstall(package); break; case QApt::Package::ToKeep: setKeep(package); break; case QApt::Package::ToPurge: setPurge(package); break; default: break; } } emit packageChanged(); m_backend->setCompressEvents(false); QApplication::restoreOverrideCursor(); checkChanges(); }
void Explosion::update(float dt) { if(animation == nullptr) return; if(!first && !animation->isDelay()) { if(explosionLength > 0) { switch(directions) { case Directions::none: // -2 break; case Directions::allSite: // -1 for(int i = 0; i < 4; ++i) create(i); break; case Directions::right: // 0 create(0); break; case Directions::left: // 1 create(1); break; case Directions::top: // 2 create(2); break; case Directions::down: // 3 create(3); break; } } first = true; } if(!animation->isPlay()) setRemove(); }
void BlokItem::explose(float Radius, float Force) { setRemove(true); m_exploseSound->play(); float Xpos = body()->GetPosition().x; float Ypos = body()->GetPosition().y; b2AABB Sector; Sector.lowerBound.Set(Xpos-Radius, Ypos-Radius); Sector.upperBound.Set(Xpos+Radius, Ypos+Radius); const int32 k_bufferSize = 512; b2Shape *buffer[k_bufferSize]; int32 count = body()->GetWorld()->Query(Sector, buffer, k_bufferSize); b2Body* Body; b2Vec2 HitVector; b2Vec2 HitPoint; b2Vec2 BodyPos; float a; float b; float c; float HitForce; float Distance; for (int32 i = 0; i < count; ++i) { Body = buffer[i]->GetBody(); BodyPos = Body->GetWorldCenter(); Distance=sqrt(pow((BodyPos.x)-Xpos,2)+pow((BodyPos.y)-Ypos,2)); if ((Body->IsDynamic()) & (Distance<=Radius)) { HitForce=(Radius-Distance)*Force; a=BodyPos.x-Xpos; b=BodyPos.y-Ypos; c=sqrt(pow(a,2)+pow(b,2)); HitVector.Set(HitForce*(a/c), HitForce*(b/c)); HitPoint=Body->GetWorldCenter(); Body->ApplyImpulse(HitVector, HitPoint); }; } }
// What are the specified player's next possible moves LocationID *whereCanTheyGo(DracView currentView, int *numLocations, PlayerID player, int road, int rail, int sea) { // This will get ALL the connected locations. LocationID *arrConnected = connectedLocations(currentView->g, numLocations, getLocation(currentView->g, player), player, getRound(currentView->g), road, rail, sea); // The only trick is that Dracula must remove his trail. if (player == PLAYER_DRACULA) { Set setConnected = copyArrayToSet(arrConnected, *numLocations); LocationID pastSix[TRAIL_SIZE] = {0}; giveMeTheTrail(currentView, player, pastSix); for (int i = 0; i < TRAIL_SIZE; i++) { if (isElem(setConnected, pastSix[i])) { setRemove(setConnected, pastSix[i]); *numLocations -= 1; } } free(arrConnected); arrConnected = copySetToArray(setConnected); } return arrConnected; }
huReturn hookUp(const vector<SplitEdge> &g, int s, vector<SplitEdge> &bIn, int k, vector<vector<int>> &Y, historyIndex &h) { if (cG(s, g) != 0) { cout << "cG(s) problem in hookup" << endl; throw logic_error(""); } vector<SplitEdge> H = g; vector<SplitEdge> G1 = g; vector<SplitEdge> B = bIn; vector<SplitEdge> B1; vector<vector<int>> XS; int maxNodeInd = getMaxNodeInd(G1); for (int i = 0; i < maxNodeInd; i++) XS.push_back(vector<int>()); for (int i = 0; i < maxNodeInd; i++) XS[i].push_back(i); //cout << "About to enter while loop" << endl; while (getNumUsedNodes(H) >= 4) { vector<int> ma = maOrderingHeap(H, s); int v = ma[ma.size() - 2]; int w = ma[ma.size() - 1]; if (v == s || w == s) throw logic_error("SET WAS V - S, S FOUND"); vector<int> X1; H = combineVertices(H, v, w); H = compress(H); XS[v] = setUnion(XS[v], XS[w]); if (XS[w].size() == 0) { cout << "Error: W, " << w << " was merged twice. Quitting" << endl; throw logic_error(""); } XS[w] = vector<int>(); if (cG(v, H) < k) { int numToGet = (int)ceil(.5*(double(k) - double(cG(G1, XS[v])))); vector<SplitEdge> GX = inducedSubgraph(G1, XS[v]); vector<SplitEdge> delB; int added = 0; for (unsigned i = 0; i < GX.size(); i++) { SplitEdge e = SplitEdge(GX[i].end0, GX[i].end1, GX[i].weight, GX[i].orig0, GX[i].orig1); if (isMem(e, B)) { int bW = B[indexOfEdge(B, e.end0, e.end1)].weight; if (bW < e.weight) e.weight = bW; if (e.weight > (numToGet - added)) { e.weight = numToGet - added; } added += e.weight; delB.push_back(e); } if (added == numToGet) break; } if (added != numToGet) { cout << "Error: GX did not contain " << numToGet << " entries in B. Quitting." << endl; throw logic_error(""); } if (!isSubset(delB, B)) { cout << "ERROR: delB is not a subset of B." << endl; cout << "B:" << endl; output(B); cout << "delB:" << endl; output(delB); cout << "This was the GX to choose from:" << endl; output(GX); cout << "V: " << v << endl; cout << "W: " << w << endl; cout << "S: " << s << endl; throw logic_error(""); } B = setRemove(delB, B); B = removeZeroWeighted(B); B1 = setUnion(delB, B1); H = removeZeroWeighted(H); G1 = hookUpHelper(s, G1, delB, h); G1 = removeZeroWeighted(G1); H = removeZeroWeighted(H); bool addedFromXSinH = false; numToGet *= 2; for (unsigned i = 0; i < H.size(); i++) { SplitEdge tester = SplitEdge(s, v, 0, 0, 0); if (equals(tester, H[i])) { //cout << "Increasing weight in hookUp in H between " << H[i].end0 << " and " << H[i].end1 << "from " << H[i].weight << " to " << H[i].weight + numToGet << endl; H[i].weight += numToGet; addedFromXSinH = true; break; } } if (!addedFromXSinH && numToGet != 0) { //cout << "Creating edge in hookUp in H between " << s << " and " << v << " with weight " << numToGet << endl; SplitEdge e(s, v, numToGet, s, v); H.push_back(e); } vector<vector<int>> newY; for (unsigned i = 0; i < Y.size(); i++) { if (!isProperSubset(Y[i], XS[v])) newY.push_back(Y[i]); } bool foundX1inY = false; for (unsigned i = 0; i < newY.size(); i++) { if (setsEqual(newY[i], XS[v])) foundX1inY = true; } if (!foundX1inY) newY.push_back(XS[v]); Y = newY; } } huReturn ret; ret.BP = B1; ret.G1 = G1; ret.Y = Y; return ret; }