int Approximator::run(int numSteps, double stepsize){ recordState(); for(int ii = 0; ii < numSteps && !errno; ii++){ step(stepsize); recordState(); } return errno; }
bool bGroup::newClickUp(int _x, int _y) { for (unsigned int i=0; i<blocks.size(); i++) { blocks[i].newClickUp(x,y); resetInsertSpace(blocks[i]); } base.newClickUp(x, y); bool ret=0; if(held.bGrabbed){ held.newClickUp(_x,_y); if(!(held.x<x||held.x>x+w||held.y<y||held.y>y+h)){ if(processBlockDrop(held, base)) ret=true,bChanged=true; for (unsigned int i=0; i<blocks.size()&&!ret; i++){ ret=processBlockDrop(held, blocks[i]); if(!ret && (ret=processBlockDrop(blocks[i],held,true))) blocks.erase(blocks.begin()+i),i--; } if(!ret) pushBlocks(held, blocks, blocks.size(),true); } recordState(); } bGrabbed=inHand=false; if(base.newHeightOn()+base.h+200!=bar.getFullSize()){ float perc=bar.getScrollPercent(); bar.setup(60, h, OF_VERT); bar.registerArea(h,base.newHeightOn()+base.h+200); bar.changePadding(); bar.setScrollPercent(perc); } if(base.widthOn()+base.butArea.x!=base.w){ //base.w=base.widthOn()+base.butArea.x; } bar.clickUp(); return ret; }
bool SolitairChess::movePiece(const int fromX, const int fromY, const int toX, const int toY) { bool retval = false; Piece* p = _g.getTile(fromX, fromY); if (p) { // if can move. if (p->move( toX - fromX, toY - fromY )) { // If there is already a piece at (toX, toY), kill it. Piece* pKill = _g.getTile(toX, toY); if (pKill) pKill->kill(); // update (toX, toY) and (fromX, fromY). _g.setTile(toX, toY, p); _g.setTile(fromX, fromY, 0); retval = true; } } // Superclass history tracking. if (retval) { recordState(); } return retval; }
int Approximator::run(double precision, double stepsize) { if(precision <= 0) return 1; int numverts = Triangulation::vertexTable.size(); double curvs[2][numverts]; double radii[2][numverts]; int prev = 0; int curr; recordState(); getLatest(radii[prev], curvs[prev]); do{ step(stepsize); recordState(); curr = (prev + 1)%2; getLatest(radii[curr], curvs[curr]); prev = curr; } while(! (isPrecise(precision, curvs[0], curvs[1]) || errno) ); return errno; }
int Approximator::run(double precision, int maxNumSteps, double stepsize) { if(precision <= 0) return 1; int numverts = Triangulation::vertexTable.size(); double curvs[2][numverts]; double radii[2][numverts]; int prev = 0; int curr; recordState(); getLatest(radii[prev], curvs[prev]); for(int ii = 0; ii < maxNumSteps && !errno; ii++){ step(stepsize); recordState(); curr = (prev + 1)%2; getLatest(radii[curr], curvs[curr]); prev = curr; if( isPrecise(precision, curvs[0], curvs[1]) ) { return errno; } } return errno; }