Cube *ctrl_down(Cube *cube) { // cleanShape(cube); // if(cube->getBottom() + 1 < GRID_HEIGHT) { // if(g_GRID[cube->getX()][cube->getBottom() + 1].show == YES) { // setShape(cube); // free(cube); // COORD ref_coord = {4, 0}; // cube = new Cube(ref_coord, (COORD *)SHAPE_I_2); // setShape(cube); // return cube; // } // else { // cube->setCoord(cube->getX(), cube->getY() + 1); // } // } // setShape(cube); cleanShape(cube); COORD c; for(int i = 0; i < 4; i++) { c.X = cube->getCoord().X + cube->getShapes()[cube->cur_type][i].X; c.Y = cube->getCoord().Y + cube->getShapes()[cube->cur_type][i].Y + 1; if( // if reach blocks isInCube(c, cube) == false && g_GRID[cube->getCoord().X + cube->getShapes()[cube->cur_type][i].X][cube->getCoord().Y + 1 + cube->getShapes()[cube->cur_type][i].Y].show == 1 // if reach bottom || cube->getCoord().Y + 1 + cube->getShapes()[cube->cur_type][i].Y >= GRID_HEIGHT) { setShape(cube); // free(cube); COORD ref_coord = {4, 2}; // cube = new Cube(ref_coord, SHAPE_T.shape, SHAPE_T.types); cube = g_NEXT_CUBE; if(isValidShapePos(cube) == false) { gameOver(); } Shape *s = createShape(); g_NEXT_CUBE = new Cube(ref_coord, s->shape, s->types); // g_NEXT_CUBE = new Cube(ref_coord, SHAPE_T.shape, SHAPE_T.types); // int index = random(0, g_CubeGenerator->getLength()); // g_NEXT_CUBE = new Cube(ref_coord, g_CubeGenerator->getShapeList()[index].shape, g_CubeGenerator->getShapeList()[index].types); checkGrid(); setShape(cube); return cube; } } cube->setCoord(cube->getX(), cube->getY() + 1); checkGrid(); cube = ctrl_down(cube); setShape(cube); return cube; }
int readOneGrid(char *grid, int *check, bool start) { char buff[22]; int loop; int i; memset(buff, 0, 22); i = 0; loop = 0; while (loop < 11 && (*check = read(0, buff, 21)) > 0) { if (checkGrid(buff, i, loop)) return (1); if (i < 9 && fillGrid(buff, grid + 9 * i)) return (1); if (loop++ > 0) ++i; } if (loop == 11) { if (!start && printf("####################\n") < 0) return (1); return (2); } return (0); }
void autoMoveDown() { backupGrid(); cleanShape(g_CUR_CUBE); g_CUR_CUBE->moveDown(); if(isValidShapePos(g_CUR_CUBE) == false) { // move back && setShape g_CUR_CUBE->moveUp(); setShape(g_CUR_CUBE); // get next cube && draw it g_CUR_CUBE = g_NEXT_CUBE; if(isValidShapePos(g_CUR_CUBE) == false) { gameOver(); } Shape *s = createShape(); COORD ref_coord = {4, 2}; g_NEXT_CUBE = new Cube(ref_coord, s->shape, s->types); cleanNEXT(g_CUR_CUBE); drawNEXT(g_NEXT_CUBE); checkGrid(); } else { ; // do nothing } setShape(g_CUR_CUBE); drawGrid(); }
ossimGpt ossimNadconNarDatum::shift(const ossimGpt &aPt)const { const ossimDatum* datum = aPt.datum(); ossimString code = datum->code(); ossimString subCode(code.begin(), code.begin() + 3); if(subCode == "NAR") { return aPt; } else { if(subCode == "NAS") { checkGrid(aPt); if(!theLatGrid.getFileOkFlag()|| !theLonGrid.getFileOkFlag()) { return ossimThreeParamDatum::shift(aPt); } double shiftLat = theLatGrid.getShiftAtLatLon(aPt.latd(), aPt.lond()); double shiftLon = theLonGrid.getShiftAtLatLon(aPt.latd(), aPt.lond()); if( (ossim::isnan(shiftLat)) || (ossim::isnan(shiftLon)) ) { return ossimThreeParamDatum::shift(aPt); } else { // Note the shifts are stored in the file // as seconds. // // convert the seconds into decimal degrees. // shiftLat /= 3600.0; shiftLon /= 3600.0; return ossimGpt(aPt.latd() + shiftLat, aPt.lond() - shiftLon, aPt.height(), this); } } else { return ossimThreeParamDatum::shift(aPt); } } return ossimThreeParamDatum::shift(aPt); }