uint8_t Spiral::animate(COLOUR *arrayP, uint8_t fadeIn, uint8_t fadeOut, BUCK startBuck){ if(fadeIn){ begin(); memset(arrayP, 0, SIZE3*sizeof(COLOUR)); colourPos = 0; } memset(arrayP, 0, SIZE3*sizeof(COLOUR)); //Calculate frame for(uint8_t z = bottom; z < top; z++){ for(uint8_t i = 0; i < 4; i++){ Y = myCos(phase + myMap(z, 0, SIZE-1, 0, 2*myPI) + i*myPI/8); X = mySin(phase + myMap(z, 0, SIZE-1, 0, 2*myPI) + i*myPI/8); Y = myMap(Y, -1.1, 0.9, narrow, (float)SIZE-1-narrow); X = myMap(X, -1.1, 0.9, narrow, (float)SIZE-1-narrow); arrayP[ar((uint8_t)X, (uint8_t)Y, z)] = colourWheel.get_colour(colourPos + 10*z); } } increment_colour_pos(2); //Count periods phase += myPI/5*speed; if(phase >= 2*myPI){ phase -= 2*myPI; //Fade out to the top if(fadeOut){ bottom<2?bottom++:bottom; top>5?top--:top; speed+=0.6; narrow+=0.5; if(narrow == 2){ endBuck.colour_pos = colourPos; fadeOutDone = 1; } } //Fade in from the bottom if(!fadeInDone){ top++; if(top >= SIZE){ fadeInDone = 1; } } } return fadeOutDone; }
VectorEpetraStructured:: VectorEpetraStructured ( const mapVector_type& mapVector, const mapType_type& mapType, const combineMode_Type combineMode ) : VectorEpetra ( mapType, combineMode ), M_blockStructure ( mapVector ) { ASSERT ( mapVector.nbMap() > 0 , "Map vector empty, impossible to construct a VectorBlockMonolithicEpetra!" ); map_Type myMap ( mapVector.totalMap() ); // Set the global map this->setMap ( myMap ); }
//======================================================================= //function :IsEqual //purpose : //======================================================================= Standard_Boolean NMTDS_PassKeyShape::IsEqual(const NMTDS_PassKeyShape& aOther) const { Standard_Boolean bRet; Standard_Integer i; // bRet=Standard_False; // if (myNbIds!=aOther.myNbIds) { return bRet; } for (i=1; i<=myNbIds; ++i) { const TopoDS_Shape& aS=myMap(i); if (!aOther.myMap.Contains(aS)) { return bRet; } } return !bRet; }
//======================================================================= //function :SetShapes //purpose : //======================================================================= void NMTDS_PassKeyShape::SetShapes(const TopTools_ListOfShape& aLS) { Standard_Integer i, aId, aIdN; TopTools_ListIteratorOfListOfShape aIt; // Clear(); aIt.Initialize(aLS); for (; aIt.More(); aIt.Next()) { const TopoDS_Shape& aS=aIt.Value(); myMap.Add(aS); } myNbIds=myMap.Extent(); for(i=1; i<=myNbIds; ++i) { const TopoDS_Shape& aS=myMap(i); aId=aS.HashCode(myUpper); aIdN=NormalizedId(aId, myNbIds); mySum+=aIdN; } }
//Sorts energies from largest to smallest vector<pair<int, double> > energySort(vector<pair<int, double> > shower) { std::vector<std::pair<double, int> > energy; for (VP_iterator=shower.begin(); VP_iterator!=shower.end(); VP_iterator++) { pair<double, int> flipped(VP_iterator->second, VP_iterator->first); energy.push_back(flipped); } std::map<double, int> myMap(energy.begin(), energy.end()); map<double, int>::iterator m; vector<pair<int, double> > sorted; for (m=myMap.end(); m!=myMap.begin(); --m) { pair<int, double> orderHit(m->second, m->first); sorted.push_back(orderHit); } sorted.erase(sorted.begin(), sorted.begin()+1); return sorted; }
int main() { Graphics myGraphics(20 * OBJ_WIDTH, 20 * OBJ_HEIGHT, 0, SDL_HWSURFACE, 100); Map myMap(&myGraphics); Game myGame(&myGraphics, &myMap); int ret = myGame.StartGame("level1.map"); bool bRunning = true; while (bRunning){ // begin next level if (ret == 1){ string next_filename = myGame.NextLevel(); myGame.StartGame(next_filename); } else if (ret == 0){ // re flush return 0; } } return 0; }
double parse(double note, double *whichScale, int elements) { double oct = floor(note); double pc = 100.0 * fmod(note,1.0); double frac = fmod(pc,1.0); double octaveSize = whichScale[elements]; double myDiap = diap / pow(octaveSize, octaveOffset); if (100.0-pc<=0.000001) { return pow(octaveSize,oct+1) * myDiap; // this is to sort out a nasty bug in RTcmix // that comes from a precision difference between double and float. } int basepitch = (int)floor(pc); while (basepitch>=elements) { oct+= 1.0; basepitch = basepitch - elements; } double pitchratio = whichScale[basepitch]; double nextratio = whichScale[basepitch+1]; double interp_ratio = myMap(frac,0.0,1.0,pitchratio,nextratio); double baseFreq = pow(octaveSize,oct) * myDiap; return baseFreq * interp_ratio; }