void SettingsMassTaxesChangeController::setModel() { basePrice = Price::NET; view->getGoodGroup()->addItem("WSZYSTKIE"); fillBox(view->getGoodGroup(),goodsGroupModel->getGoodsGroups()); fillBox(view->getActualTax(),taxModel->getTaxes(true)); fillBox(view->getNewTax(),taxModel->getTaxes(true)); }
static void eraseOldScore(Player playerNum, int value) { gwp->setFont(SCORE_FONT + "-" + integerToString(SCORE_FONT_SIZE)); string str = integerToString(value); fillBox(gState.scoreBox[playerNum].x + gState.scoreBox[playerNum].w - gwp->getStringWidth(str), gState.scoreBox[playerNum].y + LABEL_DY - SCORE_FONT_SIZE, gwp->getStringWidth(str), SCORE_FONT_SIZE, "White"); }
DocumentFMController::DocumentFMController(QWidget* parent, QString symbol, bool edit) { this->edition = edit; this->symbol = symbol; this->view = new DocumentFMView(parent,this); this->invoiceService = new InvoiceService(); this->validator = new DocumentValidator(view,symbol); this->manager= new DocumentFMManager(); this->mopModel = new MOPModel(); fillBox(view->getWayToPay(),mopModel->getMethodsOfPayment()); changingContractor=false; restoreTableState(); }
ThemeDialog::ThemeDialog(QWidget* parent,const char* name,bool modal,WFlags f) :QDialog(parent,name,modal,f) { setCaption("Theme Dialog"); QLabel* labelname=new QLabel("name",this); labelname->setGeometry(0,5,40,20); lineName=new QLineEdit("user",this); lineName->setGeometry(40,5,195,20); QLabel* labelboard=new QLabel("board",this); labelboard->setGeometry(0,30,40,20); boxboard=new QComboBox(this,""); boxboard->setGeometry(40,30,195,20); fillBox("boards",boxboard); QLabel* labelpiecesA=new QLabel("pieces1",this); labelpiecesA->setGeometry(0,70,40,20); boxpiecesA=new QComboBox(this); boxpiecesA->setGeometry(40,70,195,20); fillBox("pieces",boxpiecesA); QLabel* labelpiecesB=new QLabel("pieces2",this); labelpiecesB->setGeometry(0,95,40,20); boxpiecesB=new QComboBox(this); boxpiecesB->setGeometry(40,95,195,20); fillBox("pieces",boxpiecesB); QLabel* labeldiceA=new QLabel("dice1",this); labeldiceA->setGeometry(0,135,40,20); boxdiceA=new QComboBox(this); boxdiceA->setGeometry(40,135,195,20); fillBox("dice",boxdiceA); QLabel* labeldiceB=new QLabel("dice2",this); labeldiceB->setGeometry(0,160,40,20); boxdiceB=new QComboBox(this); boxdiceB->setGeometry(40,160,195,20); fillBox("dice",boxdiceB); QLabel* labelodds=new QLabel("odds",this); labelodds->setGeometry(0,200,40,20); boxodds=new QComboBox(this); boxodds->setGeometry(40,200,195,20); fillBox("odds",boxodds); boxodds->setEnabled(false); QLabel* labeltable=new QLabel("table",this); labeltable->setGeometry(0,225,40,20); boxtable=new QComboBox(this); boxtable->setGeometry(40,225,195,20); fillBox("table",boxtable); QPEApplication::showDialog( this ); }
MoveDialog::MoveDialog(QWidget *parent, const QString& curYear, const QString &curLetter) : QDialog(parent), ui(new Ui::MoveDialog), cy(curYear), cl(curLetter), _db(QSqlDatabase::database("schmgr")) { ui->setupUi(this); setWindowFlags(Qt::Dialog); fillBox(); for (int i = 0; i<= ui->cbYear->count() -1; i++) { ui->cbYear->setCurrentIndex(i); if (ui->cbYear->currentText() == cy) break; } fillLetter(ui->cbYear->currentText()); }
/* * Function: drawBoard * ------------------- * Exported function to draw a new board. Sets up named colors, draws the * yellow border, draws the empty cubes, the labels on the scoreboard, and * resets scores to zero and words lists to empty. */ void drawBoard(int numRows, int numCols) { if (numRows < 0 || numRows > MAX_DIMENSION || numCols < 0 || numCols > MAX_DIMENSION) { error("drawBoard called with invalid dimensions."); } gwp->clear(); gwp->setWindowTitle("Welcome to Boggle!"); calculateGeometry(numRows, numCols); // Draws a filled rect underneath cubes in the oh-so-familiar yellow color fillBox(gState.board.x, gState.board.y, gState.board.w, gState.board.h, BOARD_COLOR); drawEmptyCubes(); drawPlayerLabel(HUMAN, "Me"); drawPlayerLabel(COMPUTER, "Computer"); }
DocumentFKController::DocumentFKController(QWidget* parent,bool edit) { this->edition = edit; this->symbol = "FK"; this->view = new DocumentFKView(parent,this); this->invoiceService = new InvoiceService(); this->fkService = new DocumentFKService(); this->smodel = new SettingsModel(); this->mopModel = new MOPModel(); this->validator = new DocumentValidator(view,symbol); this->managerFK = new DocumentFKManager(); this->tableStateManager = new TableStateManager(); fillBox(view->getBoxWayToPay(),mopModel->getMethodsOfPayment()); first=false; totalFromBase=false; restoreTableState(); }
// ---------------------------------------------------------------------- // draws help so the user knows what to press void drawButtonHelp( void ) { // draw non-changing buttons unsigned char x1, y1, x2, y2; x1=0x05; y1=0x03; x2=0x06; y2=0x04; fillBox( &x1, &y1, &x2, &y2, &BLUE ); x1=0x09; x2=0x0A; fillBox( &x1, &y1, &x2, &y2, &BLUE ); y1=0x05; y2=0x06; fillBox( &x1, &y1, &x2, &y2, &BLUE ); // draw changing buttons x1=0x07; y1=0x01; x2=0x08; y2=0x02; if( StartUpScreen.toggle ) fillBox( &x1, &y1, &x2, &y2, &BLUE ); else fillBox( &x1, &y1, &x2, &y2, &YELLOW ); y1=0x03; y2=0x04; if( StartUpScreen.toggle ) fillBox( &x1, &y1, &x2, &y2, &BLUE ); else fillBox( &x1, &y1, &x2, &y2, &YELLOW ); x1=0x09; x2=0x0A; if( StartUpScreen.toggle ) fillBox( &x1, &y1, &x2, &y2, &BLUE ); else fillBox( &x1, &y1, &x2, &y2, &YELLOW ); }
void DTViewClass::load() //---------------------- { WVList dataMembers; WVList methods; WVList friends; int i; WString str; ClassType * cls = (ClassType *) _symbol; Symbol * s; _members->clearAndDestroy(); cls->dataMembers( dataMembers ); cls->memberFunctions( methods ); cls->friendFunctions( friends ); for( i = 0; i < friends.count(); i += 1 ) { s = (Symbol *) friends[ i ]; str.printf( " friend %s;", s->scopedName( FALSE ) ); _members->insert( new ClassMember( s, str.gets() ) ); } for( i = 0; i < dataMembers.count(); i += 1 ) { s = (Symbol *) dataMembers[ i ]; str.printf( " %s;", s->scopedName( FALSE ) ); _members->insert( new ClassMember( s, str.gets() ) ); } for( i = 0; i < methods.count(); i += 1 ) { s = (Symbol *) methods[ i ]; str.printf( " %s;", s->scopedName( FALSE ) ); _members->insert( new ClassMember( s, str.gets() ) ); } addDescriptions(); fillBox(); }
void draw_jiki() { draw_line(jiki.p.x, jiki.p.y, tail.p.x,tail.p.y, 0x00); fillBox(jiki.p.x, jiki.p.y, jiki.p.x+1, jiki.p.y+1, 0x30); fillBox(tail.p.x, tail.p.y, tail.p.x+1, tail.p.y+1, 0x0c); }
void fbClass::fillScreen(int color) { fillBox(0, 0, vinfo.xres, vinfo.yres, color); }
/* * Fills the entire screen with a specified color *----------------------------------------------------------------------------*/ void ImageWriter::fill( int r, int g, int b, int a ) { fillBox( 0, 0, mWidth, mHeight, (char)r, (char)g, (char)b, (char)a ); }
UserViewConfig::UserViewConfig(QWidget *parent) : UserViewConfigBase(parent) { chkDblClick->setChecked(CorePlugin::m_plugin->getUseDblClick()); chkSysColors->setChecked(CorePlugin::m_plugin->getUseSysColors()); btnOnline->setColor(CorePlugin::m_plugin->getColorOnline()); btnOffline->setColor(CorePlugin::m_plugin->getColorOffline()); btnAway->setColor(CorePlugin::m_plugin->getColorAway()); btnNA->setColor(CorePlugin::m_plugin->getColorNA()); btnDND->setColor(CorePlugin::m_plugin->getColorDND()); btnGroup->setColor(CorePlugin::m_plugin->getColorGroup()); chkGroupSeparator->setChecked(CorePlugin::m_plugin->getGroupSeparator()); chkSmallFont->setChecked(CorePlugin::m_plugin->getSmallGroupFont()); chkScroll->setChecked(CorePlugin::m_plugin->getNoScroller()); connect(chkSysColors, SIGNAL(toggled(bool)), this, SLOT(colorsToggled(bool))); colorsToggled(chkSysColors->isChecked()); fillBox(cmbSort1); fillBox(cmbSort2); fillBox(cmbSort3); setSortMode(CorePlugin::m_plugin->getSortMode()); connect(cmbSort1, SIGNAL(activated(int)), this, SLOT(sortChanged(int))); connect(cmbSort2, SIGNAL(activated(int)), this, SLOT(sortChanged(int))); connect(cmbSort3, SIGNAL(activated(int)), this, SLOT(sortChanged(int))); btnAuth1->setPixmap(Pict("text_strike")); btnAuth2->setPixmap(Pict("text_italic")); btnAuth3->setPixmap(Pict("text_under")); btnVisible1->setPixmap(Pict("text_strike")); btnVisible2->setPixmap(Pict("text_italic")); btnVisible3->setPixmap(Pict("text_under")); btnInvisible1->setPixmap(Pict("text_strike")); btnInvisible2->setPixmap(Pict("text_italic")); btnInvisible3->setPixmap(Pict("text_under")); btnAuth1->setToggleButton(true); btnAuth2->setToggleButton(true); btnAuth3->setToggleButton(true); btnVisible1->setToggleButton(true); btnVisible2->setToggleButton(true); btnVisible3->setToggleButton(true); btnInvisible1->setToggleButton(true); btnInvisible2->setToggleButton(true); btnInvisible3->setToggleButton(true); connect(btnAuth1, SIGNAL(toggled(bool)), this, SLOT(setFonts(bool))); connect(btnAuth2, SIGNAL(toggled(bool)), this, SLOT(setFonts(bool))); connect(btnAuth3, SIGNAL(toggled(bool)), this, SLOT(setFonts(bool))); connect(btnVisible1, SIGNAL(toggled(bool)), this, SLOT(setFonts(bool))); connect(btnVisible2, SIGNAL(toggled(bool)), this, SLOT(setFonts(bool))); connect(btnVisible3, SIGNAL(toggled(bool)), this, SLOT(setFonts(bool))); connect(btnInvisible1, SIGNAL(toggled(bool)), this, SLOT(setFonts(bool))); connect(btnInvisible2, SIGNAL(toggled(bool)), this, SLOT(setFonts(bool))); connect(btnInvisible3, SIGNAL(toggled(bool)), this, SLOT(setFonts(bool))); btnAuth1->setOn((CorePlugin::m_plugin->getAuthStyle() & STYLE_STRIKE) != 0); btnAuth2->setOn((CorePlugin::m_plugin->getAuthStyle() & STYLE_ITALIC) != 0); btnAuth3->setOn((CorePlugin::m_plugin->getAuthStyle() & STYLE_UNDER) != 0); btnVisible1->setOn((CorePlugin::m_plugin->getVisibleStyle() & STYLE_STRIKE) != 0); btnVisible2->setOn((CorePlugin::m_plugin->getVisibleStyle() & STYLE_ITALIC) != 0); btnVisible3->setOn((CorePlugin::m_plugin->getVisibleStyle() & STYLE_UNDER) != 0); btnInvisible1->setOn((CorePlugin::m_plugin->getInvisibleStyle() & STYLE_STRIKE) != 0); btnInvisible2->setOn((CorePlugin::m_plugin->getInvisibleStyle() & STYLE_ITALIC) != 0); btnInvisible3->setOn((CorePlugin::m_plugin->getInvisibleStyle() & STYLE_UNDER) != 0); setFonts(true); }
void fbClass::runCommand(std::string command_string) { std::string command; std::istringstream iss(command_string); std::getline(iss, command, ' '); int values_int[10]; std::string value; //printf("Command (fb): %s\n", command_string.c_str()); if (command == "FILLBOX") { int i = 0; while (std::getline(iss, value, ' ')) { values_int[i++] = atoi(value.c_str()); } if (i >= 4) { fillBox(values_int[0], values_int[1], values_int[2], values_int[3], values_int[4]); } } else if (command == "SETFADE") { int i = 0; while (std::getline(iss, value, ' ')) { values_int[i++] = atoi(value.c_str()); } if (i >= 7) { setFade(values_int[0], values_int[1], values_int[2], values_int[3], values_int[4], values_int[5], values_int[6]); } } else if (command == "PUTTEXT") // x y color max_size(-1) alignment(=0) text { for (int i = 0; i < 5; i++) { std::getline(iss, value, ' '); values_int[i] = atoi(value.c_str()); } std::getline(iss, value, '\n'); /*float size; sscanf(value.c_str(), "%f", &size);*/ std::getline(iss, value, '\n'); if (vars->isavailable(value)) value = vars->getvalue(value); /*if (size != factor) setTextSize(size);*/ putText(values_int[0], values_int[1], values_int[2], value, values_int[3], values_int[4]); } else if (command == "CLEARSCREEN") { //printf("ClearScreen\n"); clearScreen(); } else if (command == "SETTEXTSIZE") { std::getline(iss, value, ' '); float val; sscanf(value.c_str(), "%f", &val); //std::cout << "Value: " << val << std::endl; setTextSize(val); } }
/* * ======== main ======== */ Int main(Void) { Mailbox_Params mboxParams; /* Task_Params grlibTaskParams; Task_Params consoleTaskParams; Task_Handle grlibTaskHandle; Task_Handle consoleTaskHandle;*/ Error_Block eb; /* Init board-specific functions. */ Board_initGeneral(); Board_initGPIO(); Board_initUART(); Board_initUSB(Board_USBDEVICE); /* Turn on user LED */ // GPIO_write(DK_TM4C123G_LED, DK_TM4C123G_LED_ON); add_device("UART", _MSA, UARTUtils_deviceopen, UARTUtils_deviceclose, UARTUtils_deviceread, UARTUtils_devicewrite, UARTUtils_devicelseek, UARTUtils_deviceunlink, UARTUtils_devicerename); /* Open UART0 for writing to stdout and set buffer */ freopen("UART:0", "w", stdout); setvbuf(stdout, NULL, _IOLBF, 128); /* Open UART0 for reading from stdin and set buffer */ freopen("UART:0", "r", stdin); setvbuf(stdin, NULL, _IOLBF, 128); /* * Initialize UART port 0 used by SysCallback. This and other SysCallback * UART functions are implemented in UARTUtils.c. Calls to System_printf * will go to UART0, the same as printf. */ UARTUtils_systemInit(0); /* Init LCD and USBCDC */ LCD_init(); // USBCDCD_init(); TouchScreenInit(); TouchScreenCallbackSet(grlibTouchTaskFxn); Bounder_set(); LED_OFF(); /* Init and enable interrupts */ GPIO_setupCallbacks(&EK_TM4C123GXL_gpioPortFCallbacks); GPIO_enableInt(EK_TM4C123GXL_SW1, GPIO_INT_RISING); GPIO_enableInt(EK_TM4C123GXL_SW2, GPIO_INT_RISING); /* SYS/BIOS Mailbox create */ Error_init(&eb); Mailbox_Params_init(&mboxParams); mailboxHandle = Mailbox_create(sizeof(DrawMessage), 2, &mboxParams, &eb); if (mailboxHandle == NULL) { System_abort("Mailbox create failed\nAborting..."); } /* Console task create */ /* Error_init(&eb); Task_Params_init(&consoleTaskParams); consoleTaskParams.instance->name = "consoleTask"; consoleTaskParams.stackSize = 1024; consoleTaskParams.priority = 2; consoleTaskHandle = Task_create(consoleTaskFxn, &consoleTaskParams, &eb); if (consoleTaskHandle == NULL) { System_abort("Console task was not created\nAborting..."); } Grlib task create Error_init(&eb); Task_Params_init(&grlibTaskParams); grlibTaskParams.instance->name = "grlibTask"; grlibTaskParams.stackSize = 2048; grlibTaskParams.priority = 1; grlibTaskHandle = Task_create(grlibTaskFxn, &grlibTaskParams, &eb); if (grlibTaskHandle == NULL) { System_abort("Grlib task was not created\nAborting..."); }*/ System_printf("Starting the example\n%s, %s", "System provider is set to SysMin", "halt the target and use ROV to view output.\n"); /* SysMin will only print to the console when you call flush or exit */ System_flush(); USBCDCD_init();//?????? why not working fillBox(4); fillBox(4); output(4,Array2048); /* Start BIOS. Will not return from this call. */ BIOS_start(); return (0); }
int main(){ int i,j; bool mark; int n =8; fillBox(n); fillBox(n); output(n); printf("%d\n",myrandom() % n); printf("%d\n",myrandom() % n); printf("%d\n",myrandom() % n); printf("%d\n",myrandom() % n); printf("%d\n",myrandom() % n); printf("%d\n",myrandom() % n); printf("%d\n",myrandom() % n); printf("%d\n",myrandom() % n); while (true){ char ch; scanf("%c%*c", &ch); if (ch == 'a'){ // mark = left(n); left_remove_blank(n); left(n); } else if (ch == 'd'){ // mark = right(n); right_remove_blank(n); right(n); } else if (ch == 'w'){ // mark = up(n); up_remove_blank(n); up(n); } else if (ch == 's'){ // mark = down(n); down_remove_blank(n); down(n); } else{ continue; } system("clear"); //printf("Move:\n"); //output(); // if (!mark){ // continue; // } fillBox(n); printf("Fill:\n"); output(n); if (isOver(n)){ printf("\n\nGame Over!\n\n"); break; } if (isWin(n)) { printf("\n\n Wow You Win!\n\n"); break; /* code */ } } return 0; }
/* * ======== consoleTaskFxn ======== * Console task * * This task listens to the key pressed in the keyboard through USBCDC. * The string ended with return character '\n' will trigger the task * to send this string to the mailbox. * For example, when the user enter "ls\n", this task will scan all the * files in the root of SD card and send the file list to the mailbox to * inform the drawing task to display on the screen. * The up/down arrow can be used to scroll up/down to display more files * in the SD card. */ Void consoleTaskFxn (UArg arg0, UArg arg1) { unsigned int count; unsigned int cpuLoad; char input[128]; UInt key; DrawMessage drawMsg; count = 1; /* printf goes to the UART com port */ printf("\f======== Welcome to the Console ========\n"); printf("Enter a command followed by return.\n" "Type help for a list of commands.\n\n"); printf("%d %% ", count++); fflush(stdout); /* Loop forever receiving commands */ while(true) { /* Get the user's input */ scanf("%s", input); /* Flush the remaining characters from stdin since they are not used. */ fflush(stdin); if (!strcmp(input, "a")) { /* Print the CPU load */ cpuLoad = Load_getCPULoad(); printf("CPU Load: %d\n", cpuLoad); drawMsg.drawCommand = KeyBoadCOMMAND; up_remove_blank(4); up(4); // copy the data to message key = Gate_enterSystem(); copyFrom2048ArrayToDrawMessage(4,drawMsg.draw2048 , Array2048); Gate_leaveSystem(key); Mailbox_post(mailboxHandle, &drawMsg, BIOS_WAIT_FOREVER); } else if (!strcmp(input, "d")) { /* Print the CPU load */ cpuLoad = Load_getCPULoad(); printf("CPU Load: %d\n", cpuLoad); drawMsg.drawCommand = KeyBoadCOMMAND; down_remove_blank(4); down(4); // copy the data to message key = Gate_enterSystem(); copyFrom2048ArrayToDrawMessage(4,drawMsg.draw2048 , Array2048); Gate_leaveSystem(key); Mailbox_post(mailboxHandle, &drawMsg, BIOS_WAIT_FOREVER); } else if (!strcmp(input, "w")) { /* Print the CPU load */ cpuLoad = Load_getCPULoad(); printf("CPU Load: %d\n", cpuLoad); drawMsg.drawCommand = KeyBoadCOMMAND; left_remove_blank(4); left(4); // copy the data to message key = Gate_enterSystem(); copyFrom2048ArrayToDrawMessage(4,drawMsg.draw2048 , Array2048); Gate_leaveSystem(key); Mailbox_post(mailboxHandle, &drawMsg, BIOS_WAIT_FOREVER); } else if (!strcmp(input, "s")) { /* Print the CPU load */ cpuLoad = Load_getCPULoad(); printf("CPU Load: %d\n", cpuLoad); drawMsg.drawCommand = KeyBoadCOMMAND; right_remove_blank(4); right(4); // copy the data to message key = Gate_enterSystem(); copyFrom2048ArrayToDrawMessage(4,drawMsg.draw2048 , Array2048); Gate_leaveSystem(key); Mailbox_post(mailboxHandle, &drawMsg, BIOS_WAIT_FOREVER); } else if (!strcmp(input, "exit")) { /* Exit the console task */ printf("Are you sure you want to exit the console? Y/N: "); fflush(stdout); scanf("%s", input); fflush(stdin); if ((input[0] == 'y' || input[0] == 'Y') && input[1] == 0x00) { printf("Exiting console, goodbye.\n"); Task_exit(); } } else { /* Print a list of valid commands. */ printf("Valid commands:\n" "- w: move up.\n" "- a: move left.\n" "- s: move down.\n" "- a: move right.\n" "- exit: Exit the console task.\n"); } fillBox(4); // printf("%d %% ", count++); fflush(stdout); } }
void draw_back() { fillBox(0, 0, H_SIZE, V_SIZE, 0xff); }
void fbClass::clearScreen() { fillBox(0, 0, vinfo.xres, vinfo.yres, -1); }
/* * ======== grlibTaskFxn ======== * Drawing task * * It is pending for the message either from console task or from button ISR. * Once the messages received, it draws to the screen based on information * contained in the message. */ Void grlibTaskFxn(UArg arg0, UArg arg1) { DrawMessage curMsg; const UChar *pucCurImage; UInt key; UInt fontHeight = GrStringHeightGet(&context); while (TRUE) { Mailbox_pend(mailboxHandle, &curMsg, BIOS_WAIT_FOREVER); fillBox(4); /* Clear screen before drawing */ clearDisplay(); /* Parse the message and draw */ switch (curMsg.drawCommand) { case IMAGE: pucCurImage = image_Gallery[curMsg.drawImageIndex]; /* Draw image at (0,0) */ GrImageDraw(&context, pucCurImage, 0, 0); break; case KeyBoadCOMMAND: switch(curMsg.MoveCommand){ case UP: // copy the data to message key = Gate_enterSystem(); up_remove_blank(4); up(4); copyFrom2048ArrayToDrawMessage(4,curMsg.draw2048 , Array2048); Gate_leaveSystem(key); break; case DOWN: // copy the data to message key = Gate_enterSystem(); down_remove_blank(4); down(4); copyFrom2048ArrayToDrawMessage(4,curMsg.draw2048 , Array2048); Gate_leaveSystem(key); break; case LEFT: // copy the data to message key = Gate_enterSystem(); left_remove_blank(4); left(4); copyFrom2048ArrayToDrawMessage(4,curMsg.draw2048 , Array2048); Gate_leaveSystem(key); break; case RIGHT: // copy the data to message key = Gate_enterSystem(); right_remove_blank(4); right(4); copyFrom2048ArrayToDrawMessage(4,curMsg.draw2048 , Array2048); Gate_leaveSystem(key); break; default: break; } output(4,curMsg.draw2048); break; case ScreenCOMMAND: // copy the data to message key = Gate_enterSystem(); fillBox(4); Gate_leaveSystem(key); output(4,curMsg.draw2048); System_printf("here\n"); // printf("data X %d , data Y %d /n",curMsg.touchPosition[0],curMsg.touchPosition[1]); break; default: break; } } }
void GameEngine::generateLevel() { //Clear out the last level for (vector<Actor*>::iterator it = monsters.begin(); it != monsters.end(); ++it) delete (*it); monsters.clear(); for (vector<Pickup*>::iterator it = pickups.begin(); it != pickups.end(); ++it) delete (*it); pickups.clear(); map.clear(); playableMap.clear(); //Set tile graphics for curr floor if (currLevel == 1) { wallTile = 0x103; floorTile = 0x100; } else if (currLevel > 1) { wallTile = 0x14D; floorTile = 0x13E; delete boss; } //Initialize the outer map vector for (int i = 0; i < worldSize; i++) { vector<Cell> v; map.push_back(v); } //Generate the map boundaries lib.loop_portion(Point(0, 0), Point(worldSize, worldSize), [&](Point p) { Cell c(p, 2, wallTile, 0); map[p.x()].push_back(c); }); //Generate the random rooms for (int i = 0; i < rand() % 130 + 100; i++) { Point pStart((rand() % 55 + 1), (rand() % 55 + 1)); Point pEnd(pStart.x() + (rand() % 6 + 3), pStart.y() + (rand() % 6 + 3)); fillBox(pStart, pEnd); } //Flood fill to connect the world int currZone = 0; vector<int> zoneSize; lib.loop_portion(Point(0, 0), Point(worldSize, worldSize), [&](Point p) { if (map[p.x()][p.y()].getCellType() != 2 && map[p.x()][p.y()].getZone() == 0) { currZone++; int size = floodFill(map[p.x()][p.y()].getLoc(), currZone, 0); zoneSize.push_back(size); } }); //Get biggest zone in array int max = zoneSize[0]; int largestZone = 0; for (unsigned int i = 1; i < zoneSize.size(); i++) { if (zoneSize[i] > max) { largestZone = i; max = zoneSize[i]; } } largestZone++; //Offset for vector index //Get rid of everything but largest zone int end = worldSize - 1; lib.loop_portion(Point(0, 0), Point(worldSize, worldSize), [&](Point p) { Cell& c = map[p.x()][p.y()]; if (c.getZone() != largestZone) { if ((p.x() + 1 < end && map[p.x() + 1][p.y()].getZone() == largestZone) || (p.x() - 1 > 0 && map[p.x() - 1][p.y()].getZone() == largestZone) || (p.y() + 1 < end && map[p.x()][p.y() + 1].getZone() == largestZone) || (p.y() - 1 > 0 && map[p.x()][p.y() - 1].getZone() == largestZone) || (p.x() - 1 > 0 && p.y() - 1 > 0 && map[p.x() - 1][p.y() - 1].getZone() == largestZone) || (p.x() - 1 > 0 && p.y() + 1 < end && map[p.x() - 1][p.y() + 1].getZone() == largestZone) || (p.x() + 1 < end && p.y() - 1 > 0 && map[p.x() + 1][p.y() - 1].getZone() == largestZone) || (p.x() + 1 < end && p.y() + 1 < end && map[p.x() + 1][p.y() + 1].getZone() == largestZone)) { c.setTile(wallTile); c.setTileType(2); } else { c.setTile(0); c.setTileType(2); } } else if (c.getLoc().x() == end) c.setTile(0); }); //Set player starting position lib.loop_portion(Point(0, 0), Point(worldSize - 1, worldSize - 1), [&](Point p) { if (map[p.x()][p.y()].getZone() != 0 && map[p.x()][p.y()].getCellType() != 2) playableMap.push_back(map[p.x()][p.y()].getLoc()); }); //Add monsters for (unsigned int i = 0; i < playableMap.size(); i++) { int chance = rand() % 30; if (chance == 15) { //Make the monster ActorDef def = pickfromtable<ActorDef>(actordefs); monsters.push_back(new Actor(def, playableMap[i], false, false)); map[playableMap[i].x()][playableMap[i].y()].setActor(monsters.back()); //Give chance to spawn with item chance = rand() % 5 + 1; //Give 10% chance to spawn if (chance == 3) { PickupDef def = pickfromtable<PickupDef>(pickupdefs); pickups.push_back(new Pickup(def, playableMap[i])); map[playableMap[i].x()][playableMap[i].y()].setPickup(pickups.back()); } } } //Set starting pos Point heroLoc = getRandomLoc(); screenOrientation = heroLoc; hero->setLoc(screenOrientation); //Add stairs, shop, boss stairLoc = addToRandomLoc(Cell(Point(), 5, 0x1A0, -1)); shop = Shop(addToRandomLoc(Cell(Point(), 6, 0x0C0, -1)), currLevel, pickupdefs, &lib, hero, &log, &invLog); bossLoc = addToRandomLoc(Cell(Point(), 7, 0x1AB, -1)); bossInRoomLoc = Point(5, 2); //Instantiate the boss map for (int i = 0; i < bossMapSize; i++) { vector<Cell> row; for (int j = 0; j < bossMapSize; j++) { if (i == 0 || i == bossMapSize - 1 || j == 0 || j == bossMapSize - 1) row.push_back(Cell(Point(i, j), 2, 0x14B, 1)); else row.push_back(Cell(Point(i, j), 1, 0x122, 1)); } bossMap.push_back(row); } //Add the boss to its location in the boss map int which = rand() % bossdefs.size(); boss = new Actor(bossdefs[which], bossInRoomLoc, false, true); bossMap[bossInRoomLoc.x()][bossInRoomLoc.y()].setActor(boss); }