//------------------------------------------------------------------------------ // Setup the list of BasicGL::Graphic objects for the initial blocks // Returns the number of blocks //------------------------------------------------------------------------------ unsigned int Board::setupBlockGraphics() { clearGraphics(); if (puzzle != nullptr && templates != nullptr) { const State* s = puzzle->getInitState(); if (s != nullptr) { bool finished = false; for (unsigned int i = 0; i < MAX_BLOCKS && !finished; i++) { const Block* b = s->getBlock(i+1); if (b != nullptr) { unsigned int typeId = b->getTypeId(); const Basic::Pair* pair = templates->getPosition(typeId); if (pair != nullptr) { const BasicGL::Graphic* g = dynamic_cast<const BasicGL::Graphic*>( pair->object() ); if (g != nullptr) { // Ok, we've found a BasicGL::Graphic to draw this block! blocks[nblocks] = g->clone(); blocks[nblocks]->container(this); blockId[nblocks] = b->getReferenceID(); xp[nblocks] = static_cast<LCreal>(b->getX()); yp[nblocks] = static_cast<LCreal>(b->getY()); xd[nblocks] = 0; yd[nblocks] = 0; nblocks++; } } } else finished = true; } } } return nblocks; }
static void updateOnceEveryFrame() { if (gKeyPressed) { ++gKeyPressTime; } if ((gTimeTick%(TIME_FRAMES_PER_SEC/SCREEN_AND_SENSOR_UPDATES_PER_SEC) == 0)) { updateSensorsAndScreen(); } #ifdef TIME_ENABLED updateTime(); #endif //TIMEENABLED #ifdef TEXT_ENABLED for (uint8_t i = 0; i < TEXT_LINES; ++i) { clearText(i); updateText(i); } #endif //TEXT_ENABLED #ifdef GRAPICSENABLED clearGraphics(); updateGrapics(); #endif //GRAPICSENABLED }
//------------------------------------------------------------------------------ //deleteData() -- delete member data //------------------------------------------------------------------------------ void Board::deleteData() { setSlotPuzzle(nullptr); setSlotTemplates(nullptr); clearGraphics(); }
Console::~Console() { clearGraphics(); delete[] keys; }