static bool hideSideBar(CubeID cid, Side s) { // If cid is showing a bar on side s, hide it and check if the // blicket detector should turn off. ASSERT(activeCubes.test(cid)); if (!vbuf[cid].sprites[s].isHidden()) { vbuf[cid].sprites[s].hide(); if (barSpriteCount(cid) == 0 && cid == 0) { vbuf[cid].bg0.image(vec(0,0), Backgrounds, 0); } else { vbuf[cid].bg0.image(vec(0,0), cond.get_condition(), cid - 1); } return true; } else { return false; } }
static bool showSideBar(CubeID cid, Side s) { // If cid is not showing a bar on side s, show it and check if the // blicket detector shold go off. ASSERT(activeCubes.test(cid)); if (vbuf[cid].sprites[s].isHidden()) { vbuf[cid].sprites[s].setImage(Bars[s]); vbuf[cid].sprites[s].move(getRestPosition(s)); if (barSpriteCount(cid) == 1 && cid == 0) { vbuf[cid].bg0.image(vec(0,0), Backgrounds, 1); } else { vbuf[cid].bg0.image(vec(0,0), cond.get_condition(), cid - 1); } return true; } else { return false; } }
static void activateCube(CubeID cid) { // Mark cube as active and render its canvas // activeCubes.mark(cid); vbuf[cid].initMode(BG0_SPR_BG1); if (cid == 0) { vbuf[cid].bg0.image(vec(0,0), Backgrounds, 0); } else { vbuf[cid].bg0.image(vec(0,0), cond.get_condition(), cid - 1); } auto neighbors = vbuf[cid].physicalNeighbors(); for(int side=0; side<4; ++side) { if (neighbors.hasNeighborAt(Side(side))) { showSideBar(cid, Side(side)); } else { hideSideBar(cid, Side(side)); } } }