bool LensDistortOverlayInteract::draw( const OFX::DrawArgs& args ) { typedef boost::gil::point2<Scalar> Point2; static const float lineWidth = 2.0; bool displaySomething = false; // debug drawing if( _plugin->_debugDisplayRoi->getValue() ) { glLineWidth( lineWidth ); displaySomething = true; glColor3f( 1.0f, 0.0f, 0.0f ); overlay::displayRect( _plugin->_dstRoi, -1 ); glColor3f( 0.0f, 1.0f, 0.0f ); overlay::displayRect( _plugin->_srcRoi, 1 ); glColor3f( 0.0f, 0.0f, 1.0f ); overlay::displayRect( _plugin->_srcRealRoi, 1 ); } displaySomething |= _interactScene.draw( args ); // drawing if( _plugin->_gridOverlay->getValue() && _plugin->_clipSrc->isConnected() ) { displaySomething = true; static const unsigned int steps = 10; // get the project size OfxRectD srcRod = _plugin->_clipSrc->getCanonicalRod( args.time ); if( _plugin->_srcRefClip->isConnected() ) srcRod = _plugin->_srcRefClip->getCanonicalRod( args.time ); const Point2 imgSize( srcRod.x2 - srcRod.x1, srcRod.y2 - srcRod.y1 ); const OfxRectD outputRod = _plugin->_clipDst->getCanonicalRod( args.time ); //parameters const Point2 gridCenter( ofxToGil( _plugin->_gridCenter->getValue() ) ); const Point2 gridScale( ofxToGil( _plugin->_gridScale->getValue() ) ); std::vector<std::vector<Point2> > grid = createGrid( srcRod, steps, gridScale, gridCenter ); if( !_plugin->_displaySource->getValue() ) { LensDistortProcessParams<Scalar> params; static const double pixelAspectRatio = 1.0; // here the pixel aspect ratio is 1.0 because we work in canonical coordinates params = _plugin->getProcessParams( srcRod, srcRod, pixelAspectRatio, true ); // work in output clip coordinates transformValuesApply( _plugin->getLensType(), params, grid ); } Point2 rodCorner( srcRod.x1, srcRod.y1 ); shiftGrid( grid, rodCorner ); // to move in RoW coordinates glLineWidth( lineWidth ); glColor3f( 1.0f, 1.0f, 0.0f ); overlay::drawCurves( grid ); } return displaySomething; }
void Board_AB::storeSmart(char score, num loc, char alphaOrig, char beta){ BitstringKey minKey = MAXKEY; Bitstring state = 0; bool mirrored = false; num shift = 0; for(num x = 0; x < n; x++){ shiftGrid(); Bitstring mirroredState = 0; Bitstring mirroredZ = 0; Bitstring s = 0; Bitstring z = 0; for(int i = n-1; i > -1; i--){ if (grid[i] != '.') { pair<Bitstring,Bitstring>& aZ = assignmentZ[n-i-1]; pair<Bitstring,Bitstring>& aG = assignmentG[n-i-1]; mirroredZ ^= (grid[i]=='R'?aZ.first:aZ.second); mirroredState |= (grid[i]=='R'?aG.first:aG.second); z ^= (grid[i]=='R'?assignmentZ[i].first:assignmentZ[i].second); s ^= (grid[i]=='R'?assignmentG[i].first:assignmentG[i].second); } } BitstringKey key = z % MAXKEY; BitstringKey mirroredKey = mirroredZ % MAXKEY; if (key < minKey || mirroredKey < minKey){ shift = x; if(key < mirroredKey) { state = s; minKey = key; } else { state = mirroredState; minKey = mirroredKey; mirrored = true; } } } if (mirrored) { loc = ((n-loc-1)+shift)%n; } else { loc = (loc+shift)%n; } store(minKey, state, score, loc, alphaOrig, beta); /* Bitstring mirroredState = 0; Bitstring mirroredZ = 0; for(int i = n-1; i > -1; i--){ if (grid[i] != '.') { pair<Bitstring,Bitstring>& aZ = assignmentZ[n-i-1]; pair<Bitstring,Bitstring>& aG = assignmentG[n-i-1]; mirroredZ ^= (grid[i]=='R'?aZ.first:aZ.second); mirroredState |= (grid[i]=='R'?aG.first:aG.second); } } BitstringKey mirroredKey = mirroredZ % MAXKEY; BitstringKey key = zobrist % MAXKEY; if (mirroredKey < key) { store(mirroredKey,mirroredState,score, n-loc-1, alphaOrig, beta);} else { store(key,gamestate,score, loc, alphaOrig, beta);} */ }
// Main Function void _main( void ){ //Create or load savefile SAVE gameState; if(readSave(&gameState)) makeSave(&gameState); writeSave(&gameState); /*just to test whether writing is possible here so the player doesn't spend a long time and lose their progress*/ //Buffer for the text at the bottom of the scoreString = (char*)malloc(60*sizeof(char)); if(scoreString == NULL) exit(ER_MEMORY); //Pause menu pauseMenu = PopupNew(strConv[11], 50); if(pauseMenu == H_NULL) memkill(4, ER_MEMORY); PopupAddText(pauseMenu, -1, "New Game", 1); PopupAddText(pauseMenu, 0, "Options", 2); PopupAddText(pauseMenu,2,"Toggle Animations",5); PopupAddText(pauseMenu,2,"Reset Save Data",6); PopupAddText(pauseMenu, -1, "Exit", 3); PopupAddText(pauseMenu, -1, "About", 4); //Hiscore Name Entry nameBox = DialogNewSimple(140,35); if(nameBox == H_NULL) memkill(3, ER_MEMORY); DialogAddTitle(nameBox,"NEW HISCORE!",BT_OK,BT_NONE); DialogAddRequest(nameBox,3,14,"Name:", 0, 10, 14); //Game Over Entry gameOver = PopupNew("GAME OVER!", 40); if(gameOver == H_NULL) memkill(2, ER_MEMORY); PopupAddText(gameOver,-1,"Try Again",1); PopupAddText(gameOver,-1,"Exit",2); //About Dialouge aboutBox = DialogNewSimple(140,80); if(aboutBox == H_NULL) memkill(1, ER_MEMORY); DialogAddTitle(aboutBox,"ABOUT",BT_OK,BT_NONE); DialogAddText(aboutBox, 3, 13, "2048: A sliding tile puzzle"); DialogAddText(aboutBox, 3, 21, "Ti68k port by Harrison Cook"); DialogAddText(aboutBox, 3, 29, "Original game by Gabriele Cirulli"); DialogAddText(aboutBox, 3, 37, "\"Based on\" 1024 by Veewo Studio"); DialogAddText(aboutBox, 3, 45, "\"Conceptually Similar to\":"); DialogAddText(aboutBox, 3, 52, "Threes by Asher Vollmer"); DialogAddText(aboutBox, 3, 59, "Built using TIGCC"); ClrScr(); FontSetSys(F_8x10); randomize(); short int key; for(;;){ ClrScr(); drawGrid(gameState.grid); sprintf(scoreString, "Score: %lu Hiscore: %lu by %s", gameState.score, gameState.bscore, gameState.name); if(!isGridAvailable(gameState.grid)){ if(gameState.score > gameState.bscore){ DialogDo(nameBox,CENTER,CENTER, gameState.name,NULL); gameState.bscore = gameState.score; FontSetSys(F_8x10); } gameState.score = 0; initGrid(gameState.grid); switch(PopupDo(gameOver,CENTER,CENTER,0)){ case 1: continue; break; default: goto endGame; } } ST_helpMsg(scoreString); nodraw: ST_busy(ST_IDLE); key = ngetchx(); ST_busy(ST_BUSY); ST_helpMsg(scoreString); char move = 4; if(key == KEY_UP) move = UP; else if(key == KEY_RIGHT) move = RIGHT; else if(key == KEY_DOWN) move = DOWN; else if(key == KEY_LEFT) move = LEFT; else if(key == KEY_OFF || key==KEY_ON) //Turn the calculator off during a game. Resume it later off(); else if(key == KEY_ESC){ //Brings up the pause menu switch (PopupDo(pauseMenu,CENTER,CENTER,0)){ case 1: //1. New Game gameState.score = 0; initGrid(gameState.grid); break; //case 2: //2. Options //this is a submenu case 3: //3: Exit endGame: writeSave(&gameState); memkill(0,0); break; case 4: //4: About DialogDo(aboutBox,CENTER,CENTER,NULL,NULL); //Dialog sets the font weirdly, set it back FontSetSys(F_8x10); break; case 5: //1. Toggle Animations gameState.animations = !gameState.animations; break; case 6: //2. Reset Saved Data makeSave(&gameState); break; } } else goto nodraw; if(move < 4){ if(isDirectionAvailable(gameState.grid, move)){ shiftGrid(gameState.grid,move,&gameState.score, gameState.animations); pushNewTile(gameState.grid); } else goto nodraw; } } }