// Shifts Gear void DriveTrain::ShiftSpeed() { if(mPosition == kLow) { ShiftUp(); //mPosition = kHigh; } else { ShiftDown(); //mPosition = kLow; } }
void AnimateVertical(uint8_t prev, uint8_t gear) { //convert to ASCII codes prev += SYMBOL_GEAR_NUMBER; gear += SYMBOL_GEAR_NUMBER; for(uint8_t i=0;i<8;i++) { if( gear < prev ) ShiftUp(i, (PGM_P)FONTTAB+gear*8, (PGM_P)FONTTAB+prev*8 ); else ShiftDown(8-i, (PGM_P)FONTTAB+prev*8, (PGM_P)FONTTAB+gear*8 ); _delay_ms(GEAR_ANIM_DELAY); } ledPutc(gear); }
/** * \brief Scrolls test upwards. * \param szText Text to scroll. NULL at the end is not required. * \param Len Length of \a szText * \param[in,out] pOffset Offset in pixels. * \return New offset value. * * \sa ScrollDown() ScrollLLeft() ScrollRight() */ int ScrollUp( const char* szText, int Len, int* pOffset ) { int c = *pOffset / 8; int bit = *pOffset % 8; if( c >= Len ) { *pOffset = 0; return *pOffset; } char c1 = szText[c++]; char c2 = c <= Len-1 ? szText[c] : ' '/*extra space at the end*/; ShiftUp( bit, pCurrentFont+c2*8, pCurrentFont+c1*8 ); (*pOffset)++; return *pOffset; }
void PlayGame() { char userChoice = 'k'; printf("Going to start game. Use AD for left, right. WS for up, down.\n"); printf("k to kill game.\n"); InitTiles(); NextStep(); do{ if(!NextStep()){ break; } PrintTiles(); refresh(); // printing on screen - via ncurses. userChoice = getch(); // if(userChoice=='\n') userChoice = getchar(); switch(userChoice){ case 'a': case 'A': MergeLeft(); ShiftLeft(); break; case 'd': case 'D': MergeRight(); ShiftRight(); break; case 'w': case 'W': MergeUp(); ShiftUp(); break; case 's': case 'S': MergeDown(); ShiftDown(); break; } clear(); } while(SpaceAvailable() && userChoice != 'k'); printf("\nGame over.\n"); }
void Particles<ParticleTraits>::performDestroy(PatchID_t pid, bool renum) { PatchID_t i, npatch = attributeLayout_m.sizeLocal(); if (pid < 0) { for (i = 0; i < npatch; ++i) { // skip this patch if there are no destroy requests for it. if (destroyList(i).domain().empty()) continue; // do the destroys on this patch if (destroyMethod_m == DynamicEvents::backfill) { attributeLayout_m.destroy(IndirectionList<int>(destroyList(i)), i, BackFill()); } else if (destroyMethod_m == DynamicEvents::shiftup) { attributeLayout_m.destroy(IndirectionList<int>(destroyList(i)), i, ShiftUp()); } else { PInsist(false, "Unknown destroy method in Particles::destroy!"); } // clear the destroy list for this patch destroyList(i).destroy(destroyList(i).domain()); } } else { // Just destroy for the given patch PAssert(pid < npatch); i = pid; // Do the destroy if we have something to do if (!destroyList(i).domain().empty()) { if (destroyMethod_m == DynamicEvents::backfill) { attributeLayout_m.destroy(IndirectionList<int>(destroyList(i)), i, BackFill()); } else if (destroyMethod_m == DynamicEvents::shiftup) { attributeLayout_m.destroy(IndirectionList<int>(destroyList(i)), i, ShiftUp()); } else { PInsist(false, "Unknown destroy method in Particles::destroy!"); } // clear the destroy list for this patch destroyList(i).destroy(destroyList(i).domain()); } } // if requested, recompute the global domain of the Attributes if (renum) renumber(); }
// 删除堆中第i个元素 void Del(int a[], int &n, int i) { a[i] = a[n--]; if(i>1 && a[i]>a[i/2]) ShiftUp(a, i); else ShiftDown(a, n, i); }
// 向堆中插入元素x void Insert(int a[], int &n, int x) { a[++n] = x; ShiftUp(a, n); }