void controlBar::setup(bGroup * bG, sbGroup * sbG) { blocks=bG; sideBar=sbG; serChk.setup(); report().setup(); clearBut.setup(cfg().clearMsg, cfg().buttonFontSize); if(cfg().saveNotUndo){ redoBut.setup(50, OF_VERT, "images/load.png"); undoBut.setup(50, OF_VERT, "images/save.png"); setAvailableButtons(); } else{ redoBut.setup(64, OF_VERT, "images/redo.png","images/redo_active.png"); undoBut.setup(64, OF_VERT, "images/undo.png","images/undo_active.png"); } demo.setup(cfg().demoMsg, cfg().buttonFontSize); skipBut.setup(300, 100, "images/skipBut.png"); anim.setup(blocks, sideBar); subtitle.loadFont("fonts/DinC.ttf"); subtitle.setSize(22); subtitle.setMode(OF_FONT_TOP); subBar.height=subtitle.stringHeight("Kjhg")*1.5; subBar.width=ofGetWidth(); //ROOT_DIR=config("robots/config.cfg"); cout << cfg().robotRoot << " is the root" << endl; sets.load(cfg().robotRoot); cout << sets.size() << " sets" << endl; loadBlocks(sets[0]); sets[0].choice.setAvailable(false); upload.setup(blocks,&serChk); if(cfg().test) test().setup(&blocks->base); barSpacing(); loadBlocks(sets[0]); setAvailableButtons(); create.setup(cfg().createMsg, 35); edit.setup(cfg().editMsg,35); int maxW=max(create.w,edit.w); create.w=edit.w=maxW; bChooseLevel=bPluginChoice=false; }
void TetrisScreen::init() { blocks.clear(); board = TreadmillBoard(); //board = TreadmillBoard(); //board = TetrisBoard(); drop_time = DEFAULT_DROP_TIME; drop_delta = DEFAULT_DROP_DIFF; frr = FrameRateRegulator(); drop_timer = Timer(); drop_timer.start(); loadBlocks(); blocksize = blocks.at(0)->w; //get the block size from one of the blocks... ghost_surface = SDL_CreateRGBSurface(SDL_SRCALPHA, 4*blocksize, 4*blocksize, 32,0,0,0,0); SDL_SetAlpha(ghost_surface, SDL_SRCALPHA, 128); ghost_mask = SDL_MapRGB(ghost_surface->format, 255, 0 , 255); SDL_SetColorKey(ghost_surface, SDL_SRCCOLORKEY, ghost_mask); font = new BitmapFont("resources/bluebluewithlayout.png"); }
//checks for changes in the parameter manipulation channels and recreates terrain if necessary. void blockManager::update(void) { bool new_terrain_required=false; for(int i=0; i<num_params; i++) { if(control_signals[i] != 0) { new_terrain_required=true; *control_variables[i]+= (control_signals[i]*control_increments[i]); if(*control_variables[i] > control_bounds[(i*2)+1]) { *control_variables[i]= control_bounds[(i*2)+1]; } else if(*control_variables[i] < control_bounds[i*2]) { *control_variables[i]= control_bounds[i*2]; } } } if(new_terrain_required) { blocks.clear(); loadBlocks(center, radius); blocks[0].printInfo(); } }
void blockManager::preset(int preset_index) { for(int i=0; i<num_params; i++) { *control_variables[i]=presets[preset_index][i]; } blocks.clear(); loadBlocks(center, radius); blocks[0].printInfo(); }
void controlBar::beginLevelChoice(){ if(sets.size()>1) bChooseLevel=true; else if(sets.size()==1){ if(sets.clickDown(sets[0].choice.x,sets[0].choice.y)&&!anim.isPlaying()){ if(bChooseLevel){ bChooseLevel=false; } if(cfg().demoAvailable) anim.startPrompt(); if(sets.getSelected()) loadBlocks((*sets.getSelected())); } if(cfg().demoAvailable) anim.startPrompt(); } }
int doInit(Uint32 vidFlags, int doWipe) { int i; BrInitError error; if(br_init(&error, "kuri2d") == 0 && error != BR_INIT_ERROR_DISABLED) { printf("Warning: BinReloc failed to initialize (error code %d)\n", error); printf("Will fallback to hardcoded default path.\n"); } if(SDL_Init((Uint32)(SDL_INIT_VIDEO | SDL_INIT_AUDIO))) { printf("Unable to init SDL: %s\n", SDL_GetError()); return 0; } (void)atexit(SDL_Quit); (void)atexit(TTF_Quit); /* malloc some defaults - they *should* be reloaded later */ level = (KuriLevel *)malloc(sizeof(KuriLevel)); startState = malloc(sizeof(State)); state = malloc(sizeof(State)); strcpy(state->name, "Player"); state->level = (Uint8)0; state->score = (Uint8)0; state->lives = (Uint8)3; for(i=0; i<MAX_HISCORES; i++) { strcpy(hiscores[i].name, "nobody"); hiscores[i].score = 0; hiscores[i].level = 0; } if(level && startState && state && (doWipe ? 1 : loadHiScores()) && loadBackgrounds() && loadBlocks() && loadLevels() && loadSounds() && loadFonts() && loadTexts() && openFrame(vidFlags)) { return 1; } return 0; }
int main() { int restoreState = 1; if (restoreState == 0) { generateVertical(""); printf("LeftBlock count: %d\n",leftBlock.size()); printf("RightBlock count: %d\n",rightBlock.size()); printf("MidBlock count: %d\n",midBlock.size()); for (int i=0; i<2; i++) { printf("Running iteration %d...\n",i); combiner(LEFT); combiner(RIGHT); combiner(MIDDLE); } printf("sorting...\n"); std::sort(leftBlock.begin(), leftBlock.end()); std::sort(rightBlock.begin(), rightBlock.end()); std::sort(midBlock.begin(), midBlock.end()); // Output blocks to file to speed up startup saveBlocks(); } else { // Load blocks from last run loadBlocks(); // Load last iteration loadRootIt(); } printf("\nLeftBlock count: %d\n",leftBlock.size()); printf("RightBlock count: %d\n",rightBlock.size()); printf("MidBlock count: %d\n",midBlock.size()); printf("L: %d M: %d R: %d\n",leftWidth,midWidth,rightWidth); maxLevel = (puzzleWidth-leftWidth-rightWidth)/midWidth + 2; printf("Max Level: %d\n",maxLevel); solver("",0); // Close solutions file outFile.close(); return 0; }
bool controlBar::clickDown(int _x, int _y, int button) { bool ret=false; if(!mouseLockout(button)){ timeOut.set(cfg().timeout); timeOut.run(); if (clearBut.clickDown(_x, _y)) { blocks->clearAndReset(); upload.uploadInBG(); ret=true; } //if(demo.clickDown(_x, _y)){ // anim.play(); //} //--------- if we press the undo button, roll back the state of the blockGroup if (undoBut.clickDown(_x, _y)) { if(!cfg().saveNotUndo) blocks->undoState(); else blocks->saveState(),setAvailableButtons(); ret=true; } //--------- if we press the redo button, push the state forward if (redoBut.clickDown(_x, _y)) { if(!cfg().saveNotUndo) blocks->redoState(); else blocks->loadState(); ret=true; } if(cfg().newUser.clickDown(_x,_y)){ if(cfg().savePrograms) bPluginChoice=true; else if(sets.size()!=1) bChooseLevel=true; else bChooseLevel=false,anim.startPrompt(); blocks->clearAndReset(); blocks->loadFile(ofToDataPath("programs/newUserProgram.xml")); } if(cfg().test) test().clickDown(_x, _y); } //--------- if we press the skip button while the anim is running, stop anim if(anim.isPlaying()&&skipBut.clickDown(_x, _y)&&button!=VMOUSE_BUTTON){ anim.stop(); ret=true; } if(anim.isPrompting()&&!bChooseLevel){ if(anim.clickDown(_x, _y)) blocks->recordState(); ret=true; } if(cfg().test){ if ((!mouseLockout(button)||test().mouseLockout())||(anim.isPlaying()&&button==VMOUSE_BUTTON)) { test().clickDown(_x, _y); } } if(bChooseLevel||!mouseLockout(button)){ timeOut.set(cfg().timeout); if(sets.clickDown(_x,_y)&&!anim.isPlaying()){ ret=true; if(bChooseLevel){ bChooseLevel=false; //anim.play(); if(cfg().demoAvailable) anim.startPrompt(); } if(cfg().demoAvailable) anim.startPrompt(); if(sets.getSelected()) loadBlocks((*sets.getSelected())); } } if((!mouseLockout(button)||(mouseLockout(button)&&test().isTesting()))&&upload.clickDown(_x, _y)){ cout << "saving " << cfg().programDir+serChk.deviceNumber()+".xml" << endl; blocks->saveXML(cfg().programDir+serChk.deviceNumber()+".xml"); if(cfg().test){ test().resetTurtle(); test().stopTesting(); } ret=true; } if(cfg().savePrograms&&bPluginChoice){ if(create.clickDown(_x,_y)){ bPluginChoice=false; bChooseLevel=true; blocks->clearAndReset(); blocks->recordState(); ret=true; } if(edit.clickDown(_x,_y)){ bPluginChoice=false; sysCall.run("dir \""+cfg().programDir+"\""); while(sysCall.isRunning()); anim.clearPrompt(); for(unsigned int i=0; i<sysCall.outputLines(); i++){ vector<string>spl=ofSplitString(sysCall[i]," "); if(spl.size()>=5){ if(spl[4]==serChk.deviceNumber()+".xml") blocks->loadFile(cfg().programDir+serChk.deviceNumber()+".xml"); } } bChooseLevel=false; } } return ret; }