void DiscountPage::setupItemAnimations() { QState *smallState = new QState(); QState *bigState = new QState(); for (int i = 0; i < this->m_itemList.size(); i++) { smallState->assignProperty(this->m_itemList[i],"scale", 0); bigState->assignProperty(this->m_itemList[i],"scale",1); } QSequentialAnimationGroup *showItemGroup = new QSequentialAnimationGroup(this); for (int i = 0; i < this->m_itemList.size(); i++) { QPropertyAnimation *anim = new QPropertyAnimation(this->m_itemList[i], "scale", this); anim->setDuration(300); anim->setEasingCurve(QEasingCurve::OutBack); showItemGroup->addAnimation(anim); } QSignalTransition *trans = smallState->addTransition(this, SIGNAL(start()), bigState); trans->addAnimation(showItemGroup); connect(showItemGroup,SIGNAL(finished()),this,SLOT(startSelect())); trans = bigState->addTransition(this,SIGNAL(quitPage()),smallState); connect(smallState,SIGNAL(entered()),this,SLOT(closeSelect())); QStateMachine *states = new QStateMachine(this); states->addState(smallState); states->addState(bigState); states->setInitialState(smallState); states->start(); }
bool human::event(const sf::Event *ev) { if (m_btnAttacker.insertEvent(ev)) {return false;} if (m_btnCollector.insertEvent(ev)) {return false;} if (ev->Type == sf::Event::MouseWheelMoved) { if (m_btnAttacker.hover()) { m_numNewAttacker+=ev->MouseWheel.Delta; if (m_numNewAttacker<1) m_numNewAttacker=1; if (m_numNewAttacker>100) m_numNewAttacker=100; updateButtonCaption(); return false; } if (m_btnCollector.hover()) { m_numNewCollector+=ev->MouseWheel.Delta; if (m_numNewCollector<1) m_numNewCollector=1; if (m_numNewCollector>100) m_numNewCollector=100; updateButtonCaption(); return false; } } if (ev->Type == sf::Event::MouseButtonPressed) if (ev->MouseButton.Button==sf::Mouse::Left) startSelect(); if (ev->Type == sf::Event::MouseButtonReleased) { if (ev->MouseButton.Button==sf::Mouse::Left) stopSelect(); if (ev->MouseButton.Button==sf::Mouse::Right) sendSelected(); } if (ev->Type == sf::Event::KeyReleased) if (ev->Key.Code == 'c') newCollector(); if (ev->Type == sf::Event::KeyReleased) if (ev->Key.Code == 'a') newAttacker(); return true; }
task main() { selectTime(); startSelect(); while(true) { counter(); if(programCounter == 1) { nxtDisplayCenteredTextLine(2, "Regular Autonomous"); if(nNxtButtonPressed == 3) { PlaySound(soundBlip); if(waitSelected){waitForStart();} wait1Msec(waitTime*1000); Auto_Encoder(); wait1Msec(500); } } else if(programCounter == 2) { nxtDisplayCenteredTextLine(2, "FA to FR"); if(nNxtButtonPressed == 3) { PlaySound(soundBlip); if(waitSelected){waitForStart();} wait1Msec(waitTime*1000); Auto_Front_Ramp(); wait1Msec(500); } } else if(programCounter == 3) { nxtDisplayCenteredTextLine(2, "FA to BR"); if(nNxtButtonPressed == 3) { PlaySound(soundBlip); if(waitSelected){waitForStart();} wait1Msec(waitTime*1000); Auto_Back_Ramp(); wait1Msec(500); } } else if(programCounter == 4) { nxtDisplayCenteredTextLine(2, "Hardcoded Autonomous()"); if(nNxtButtonPressed == 3) { PlaySound(soundBlip); Hardcoded_Autonomous(); if(waitSelected){waitForStart();} wait1Msec(waitTime*1000); wait1Msec(500); } } else if(programCounter == 5) { nxtDisplayCenteredTextLine(2, "Hardcoded Reverse"); if(nNxtButtonPressed == 3) { PlaySound(soundBlip); if(waitSelected){waitForStart();} wait1Msec(waitTime * 1000); Hardcoded_Reverse(); wait1Msec(500); } } //else if(programCounter == 5) //{ // nxtDisplayCenteredTextLine(2, "Reverse Autonomous"); // if(nNxtButtonPressed == 3) // { // PlaySound(soundBlip); // if(waitSelected){waitForStart();} // wait1Msec(waitTime*1000); // Reverse_Autonomous(); // wait1Msec(500); // } //} //else if(programCounter == 6) //{ // nxtDisplayCenteredTextLine(2, "RA to FR"); // if(nNxtButtonPressed == 3) // { // PlaySound(soundBlip); // if(waitSelected){waitForStart();} // wait1Msec(waitTime*1000); // Reverse_Auto_Front_Ramp(); // wait1Msec(500); // } //} //else if(programCounter == 7) //{ // nxtDisplayCenteredTextLine(2, "RA to BR"); // if(nNxtButtonPressed == 3) // { // PlaySound(soundBlip); // if(waitSelected) {waitForStart();} // wait1Msec(waitTime * 1000); // Reverse_Auto_Back_Ramp(); // wait1Msec(500); // } //} } }
// the starting point of the program task main() { // prompt the user for a delay at the start of autonomous selectTime(); // prompt whether the robot should wait for FCS to start // They can disable it when testing the program at practice. startSelect(); // wait for FCS to start if the user has chosen to if(waitSelected) { waitForStart(); } // perform the aforementioned delay wait1Msec(1000*waitTime); //holds which beacon the robot is at int beacon = 0; //holds the IR sensor value int i = 0; //loops until the sensor finds the beacon or until it gets to the final beacon. while(i != 5 && beacon < 4) { i=0; //this section prevents the reading of random IR values and makes sure the value is constant. //when the value is the constant we want, the beacon is in front of the sensor. for(int a = 0; a <100; a++) { if(a == 0) { //gets original ir value i = SensorValue[IR]; } else { int b = SensorValue[IR]; if(b != i) { //if a different value is sensed, then the original value was not constant; thus, we restart the checking //to try and gete a constant value. i = 0; a = 0; } } } if(i != 5) { if(beacon == 0) { //the distance to get to the first beacon ModForward(2200,35); motor[Right] = 0; motor[Left] = 0; wait1Msec(1000); } else if(beacon == 1) { //the distance to get to the second beacon ModForward(900,35); motor[Right] = 0; motor[Left] = 0; wait1Msec(1000); } else if(beacon == 2) { //the distance to get to the third beacon ModForward(1600,35); motor[Right] = 0; motor[Left] = 0; wait1Msec(1000); } else if(beacon == 3) { //the distance to get to the fourth beacon ModForward(1000,35); motor[Right] = 0; motor[Left] = 0; wait1Msec(1000); } beacon++; } } //code that runs after we stop in front of a beacon. servo[AutoHook] = 255; //dispenses the cube wait1Msec(900); servo[AutoHook] = 0; wait1Msec(1000); //pick where to go based on beacon #. //if the robot is at rings 1 or 4, it turns, goes back, then turns to face the ramp. //if the robots is at rings 2 or 3, it goes backwards, turns, goes backwards again, and then turns to face the ramp. if(beacon == 1) //beacon was on first box { //goes forward from the box ModForward(5200,50); motor[Right] = 0; motor[Left] = 0; wait1Msec(500); //turns to be parallel to the ramp ModTurn(2040, 100, right); motor[Right] = 0; motor[Left] = 0; wait1Msec(500); //goes backwards and towards the ramp ModBackward(4000,50); motor[Right] = 0; motor[Left] = 0; wait1Msec(500); //turns towards the ramp ModTurn(2100,100,left); motor[Right] = 0; motor[Left] = 0; wait1Msec(500); //goes onto the ramp ModBackward(4500,80); } else if (beacon == 2) //beacon was on second box { //goes forward from the box ModForward(4300,50); motor[Right] = 0; motor[Left] = 0; wait1Msec(500); //turns to be parallel to the ramp ModTurn(2040, 100, right); motor[Right] = 0; motor[Left] = 0; wait1Msec(500); //goes backwards and towards the ramp ModBackward(4000,50); motor[Right] = 0; motor[Left] = 0; wait1Msec(500); //turns towards the ramp ModTurn(2100,100,left); motor[Right] = 0; motor[Left] = 0; wait1Msec(500); //goes onto the ramp ModBackward(4500,80); } else if (beacon == 3) //beacon was on third box { //goes forward from the box ModForward(2700,50); motor[Right] = 0; motor[Left] = 0; wait1Msec(500); //turns to be parallel to the ramp ModTurn(2040, 100, right); motor[Right] = 0; motor[Left] = 0; wait1Msec(500); //goes backwards and towards the ramp ModBackward(4000,50); motor[Right] = 0; motor[Left] = 0; wait1Msec(500); //turns towards the ramp ModTurn(2100,100,left); motor[Right] = 0; motor[Left] = 0; wait1Msec(500); //goes onto the ramp ModBackward(4500,80); } else if (beacon == 4) //beacon was on fourth ring { //goes forward from the box ModForward(1560,50); motor[Right] = 0; motor[Left] = 0; wait1Msec(500); //turns to be parallel to the ramp ModTurn(1940, 100, right); motor[Right] = 0; motor[Left] = 0; wait1Msec(500); //goes backwards and towards the ramp ModBackward(4000,50); motor[Right] = 0; motor[Left] = 0; wait1Msec(500); //turns towards the ramp ModTurn(2100,100,left); motor[Right] = 0; motor[Left] = 0; wait1Msec(500); //goes onto the ramp ModBackward(4500,100); } }
void TEditor::handleEvent( TEvent& event ) { TView::handleEvent( event ); convertEvent( event ); Boolean centerCursor = Boolean(!cursorVisible()); uchar selectMode = 0; if( selecting == True || (getShiftState() & 0x03) != 0 ) selectMode = smExtend; switch( event.what ) { case evMouseDown: if( event.mouse.doubleClick == True ) selectMode |= smDouble; do { lock(); if( event.what == evMouseAuto ) { TPoint mouse = makeLocal( event.mouse.where ); TPoint d = delta; if( mouse.x < 0 ) d.x--; if( mouse.x >= size.x ) d.x++; if( mouse.y < 0 ) d.y--; if( mouse.y >= size.y ) d.y++; scrollTo(d.x, d.y); } setCurPtr(getMousePtr(event.mouse.where), selectMode); selectMode |= smExtend; unlock(); } while( mouseEvent(event, evMouseMove + evMouseAuto) ); break; case evKeyDown: if( event.keyDown.charScan.charCode == 9 || ( event.keyDown.charScan.charCode >= 32 && event.keyDown.charScan.charCode < 255 ) ) { lock(); if( overwrite == True && hasSelection() == False ) if( curPtr != lineEnd(curPtr) ) selEnd = nextChar(curPtr); insertText( &event.keyDown.charScan.charCode, 1, False); trackCursor(centerCursor); unlock(); } else return; break; case evCommand: switch( event.message.command ) { case cmFind: find(); break; case cmReplace: replace(); break; case cmSearchAgain: doSearchReplace(); break; default: lock(); switch( event.message.command ) { case cmCut: clipCut(); break; case cmCopy: clipCopy(); // hideSelect(); // JS 12.4.94 break; case cmPaste: clipPaste(); break; case cmUndo: undo(); break; case cmClear: deleteSelect(); break; case cmCharLeft: setCurPtr(prevChar(curPtr), selectMode); break; case cmCharRight: setCurPtr(nextChar(curPtr), selectMode); break; case cmWordLeft: setCurPtr(prevWord(curPtr), selectMode); break; case cmWordRight: setCurPtr(nextWord(curPtr), selectMode); break; case cmLineStart: setCurPtr(lineStart(curPtr), selectMode); break; case cmLineEnd: setCurPtr(lineEnd(curPtr), selectMode); break; case cmLineUp: setCurPtr(lineMove(curPtr, -1), selectMode); break; case cmLineDown: setCurPtr(lineMove(curPtr, 1), selectMode); break; case cmPageUp: setCurPtr(lineMove(curPtr, -(size.y-1)), selectMode); break; case cmPageDown: setCurPtr(lineMove(curPtr, size.y-1), selectMode); break; case cmTextStart: setCurPtr(0, selectMode); break; case cmTextEnd: setCurPtr(bufLen, selectMode); break; case cmNewLine: newLine(); break; case cmBackSpace: deleteRange(prevChar(curPtr), curPtr, True); break; case cmDelChar: deleteRange(curPtr, nextChar(curPtr), True); break; case cmDelWord: deleteRange(curPtr, nextWord(curPtr), False); break; case cmDelStart: deleteRange(lineStart(curPtr), curPtr, False); break; case cmDelEnd: deleteRange(curPtr, lineEnd(curPtr), False); break; case cmDelLine: deleteRange(lineStart(curPtr), nextLine(curPtr), False); break; case cmInsMode: toggleInsMode(); break; case cmStartSelect: startSelect(); break; case cmHideSelect: hideSelect(); break; case cmIndentMode: autoIndent = Boolean(!autoIndent); break; default: unlock(); return; } trackCursor(centerCursor); unlock(); break; } case evBroadcast: switch( event.message.command ) { case cmScrollBarChanged: checkScrollBar( event, hScrollBar, delta.x ); checkScrollBar( event, vScrollBar, delta.y ); break; default: return; } } clearEvent(event); }