void Game_Character::MoveRight() { if (turn_enabled) TurnRight(); if (IsPassable(x, y, RPG::EventPage::Direction_right)) { TurnRight(); x += 1; //IncreaseSteps(); move_failed = false; } else { CheckEventTriggerTouch(x + 1, y); move_failed = true; } }
/******************************************************************************** Yaw. You can add in a deadzone here. ********************************************************************************/ void Camera3::Yaw(const double dt) { if ( Application::camera_yaw > 0.0 ) TurnRight( Application::camera_yaw * dt ); else if ( Application::camera_yaw < 0.0 ) TurnLeft( Application::camera_yaw * dt ); }
void Game_Character::MoveUpRight() { if (!IsDirectionFixed()) { if (GetDirection() % 2) { TurnRight(); } else { TurnUp(); } } if (jumping) { jump_plus_x++; jump_plus_y--; return; } if ((IsPassable(GetX(), GetY(), RPG::EventPage::Direction_right) && IsPassable(GetX() + 1, GetY(), RPG::EventPage::Direction_up)) || (IsPassable(GetX(), GetY(), RPG::EventPage::Direction_up) && IsPassable(GetX(), GetY() - 1, RPG::EventPage::Direction_right))) { SetX(GetX() + 1); SetY(GetY() - 1); BeginMove(); stop_count = 0; move_failed = false; } }
static void handleScanCode( int key) { switch (key) { /* start of view position functions */ case KB_right: TurnRight(); break; case KB_left: TurnLeft(); break; case KB_down: TurnForwards(); break; case KB_up: TurnBackwards(); break; /* end of view postions functions */ /* start of miseclleneous functions */ case KB_pageUp: FireCannon(); break; case KB_home: Toggle(); break; /* end of miscelleneous functions */ } }
void testMovement() { int time = 0; int speed = 0; int test = 0; while(true) { test = random(5); speed = random(100); time = random(20); switch(test){ case 1: MoveForward(time,speed); break; case 2: MoveBackwards(time,speed); break; case 3: TurnLeft(time,speed); break; case 4: TurnRight(time,speed); break; case 5: Stop(time); break; default: break; } } }
void Snake::HandleInput(sf::Event & E) { //Implementacja interfejsu IControl. Zmienia stan wê¿a w zale¿noœci od rodzaju zda¿enia //przekazanego w argumencie, albo tworzy nowy pocisk zmierzaj¹cy do miejsca klikniêcia myszk¹. switch (E.type) { case sf::Event::KeyPressed: if (E.key.code == sf::Keyboard::W) TurnUp(); else if (E.key.code == sf::Keyboard::S) TurnDown(); else if (E.key.code == sf::Keyboard::D) TurnRight(); else if (E.key.code == sf::Keyboard::A) TurnLeft(); break; case sf::Event::MouseButtonPressed: if (E.mouseButton.button == sf::Mouse::Left) Shoot(E.mouseButton.x, E.mouseButton.y); break; default: break; } }
//************************************************** // NAME: TurnRight // DESCRIPTION: Robot turns over the right wheel // PARAMETERS: - speed->Left motor speed // - angle->Rotation angle //************************************************** void Motor::TurnRight(byte speed, int angle) { unsigned long time,timeout; byte count; byte encoder; ReduceInertia(); count = EncodeAngle(speed, angle); encoder = digitalRead(ENC_L); time=millis(); TurnRight(speed); while (count > 0) { while (encoder == digitalRead(ENC_L)) { timeout=millis(); if (timeout - time > MAX_TIMEOUT) { return; } } encoder=digitalRead(ENC_L); count--; time=millis(); } ReduceInertia(); }
void DriveToPegLeft (bool use_guided) { GoForward (125); TurnRight (45); if (use_guided) GuidedDriveForward (60); else GoForward (60); }
task autonomous() { switch(AutoSelect) { //AUTO SKILLS case 1: RedSkills(); break; // AUTO ROUTINES case 2: //BALL AUTO Balls(3500); break; case 3: Park(); break; case 4: WalloB(); break; case 5: WalloR(); break; case 6: FrontMiddleL(); break; case 7: FrontMiddleR(); break; case 8: SideMiddleB(); break; case 9: SideMiddleR(); break; ///// TEST CODE ///// case 17: //PID TURN TEST TurnLeft(900); wait1Msec(500); TurnRight(900); break; case 18: //PID DRIVE TEST Drive(36); break; case 19: // LEFT TEST LeftTest(); break; case 20: // RIGHT TEST RightTest(); break; default: //NOTHING } }
void DriveToPegMiddle (bool use_guided) { GoForward (40); TurnRight (45); GoForward (73); if (use_guided) GuidedDriveForward (42); else GoForward (42); }
void TurnRightDegrees(float degrees) { SensorValue[Gyroscope] = 0; while(abs(SensorValue[Gyroscope]) < abs(degrees) * 10 * 0.935) { if (abs(degrees) * 10 - abs(SensorValue[Gyroscope]) < 300) TurnRight(30); else if (abs(degrees) * 10 - abs(SensorValue[Gyroscope]) < 500) TurnRight(40); else if (abs(degrees) * 10 - abs(SensorValue[Gyroscope]) < 700) TurnRight(50); else TurnRight(60); if (stopEventFunction("none")) break; } StopMoving(); }
void DriveToPegLeft () { GoForward (129); TurnRight (25); if (USE_GUIDED_FWD) GuidedDriveForward (60); else GoForward (60); DropHand (); GoBackwards (10); }
void loop() { if(infraredReceiverDecode.buttonState() == 1) { switch(infraredReceiverDecode.read()) { case IR_BUTTON_PLUS: Forward(); break; case IR_BUTTON_MINUS: Backward(); break; case IR_BUTTON_NEXT: TurnRight(); break; case IR_BUTTON_PREVIOUS: TurnLeft(); break; case IR_BUTTON_9: ChangeSpeed(factor*9+minSpeed); break; case IR_BUTTON_8: ChangeSpeed(factor*8+minSpeed); break; case IR_BUTTON_7: ChangeSpeed(factor*7+minSpeed); break; case IR_BUTTON_6: ChangeSpeed(factor*6+minSpeed); break; case IR_BUTTON_5: ChangeSpeed(factor*5+minSpeed); break; case IR_BUTTON_4: ChangeSpeed(factor*4+minSpeed); break; case IR_BUTTON_3: ChangeSpeed(factor*3+minSpeed); break; case IR_BUTTON_2: ChangeSpeed(factor*2+minSpeed); break; case IR_BUTTON_1: ChangeSpeed(factor*1+minSpeed); break; default: // Stop(); break; } } else { Stop(); } }
void Game_Character::TurnTowardPlayer() { int sx = DistanceXfromPlayer(); int sy = DistanceYfromPlayer(); if ( std::abs(sx) > std::abs(sy) ) { (sx > 0) ? TurnLeft() : TurnRight(); } else if ( std::abs(sx) < std::abs(sy) ) { (sy > 0) ? TurnUp() : TurnDown(); } }
void DriveToPegRight (bool use_guided) { GoForward (5); TurnRight (40); GoForward (34); TurnLeft (24); GoForward (45); if (use_guided) GuidedDriveForward (60); else GoForward (60); }
void CPMotion::Meander(short Velocity, short Duration, short Iterations) { //OK double OriginalHeading = m_Robot->GetHeading(); MoveForward(Velocity, Duration); TurnLeft(Velocity); for (int i = 1; i < Iterations; i++) { MoveForward(Velocity, Duration); TurnRight(Velocity); MoveForward(Velocity, Duration); TurnRight(Velocity); MoveForward(Velocity, Duration); TurnLeft(Velocity); MoveForward(Velocity, Duration); TurnLeft(Velocity); } m_Robot->SetHeadingDestination(OriginalHeading, Velocity, 2); }
void TurnRightUsingTimer() { TIM_Cmd(TIM2, ENABLE); TurnRight(); while (timerCount < 30) { } StopVehicle(); TIM_Cmd(TIM2, DISABLE); timerCount = 0; }
void DriveToPegMiddle () { GoForward (45); TurnRight (24); if (USE_GUIDED_FWD) { GoForward (55); GuidedDriveForward (60); } else GoForward (115); DropHand (); GoBackwards (10); }
/* * main.c */ int main(void) { WDTCTL = WDTPW|WDTHOLD; // stop the watchdog timer initMotors(); while(1) { TurnLeft(); ShortDelay(); StopBot(); Delay(); TurnRight(); ShortDelay(); StopBot(); Delay(); MoveForward(); Delay(); StopBot(); Delay(); MoveBack(); Delay(); StopBot(); Delay(); TurnRight(); Delay(); StopBot(); Delay(); TurnLeft(); Delay(); StopBot(); Delay(); Delay(); Delay(); } }
void TurnToIR() { while(!facingIR()) { if(IROnLeft()) { TurnRight(0.05,autospeed); } else { TurnLeft(0.05,autospeed); } } }
task main() { initialize (); // In the original template this was "initializeRobot();" waitForStart (); // Wait for the beginning of autonomous phase. clasp_goal(true); distanceToDrive = 72.0; //6 feet drive_both_wheels (-motorSpeed, -motorSpeed, distanceToDrive * kInch); //drives out of parking zone to kickstand int i = 0; for(i = 0; i <= 1; i++){ distanceToDrive = 6.0; //6 in drive_both_wheels (motorSpeed, motorSpeed, distanceToDrive * kInch); distanceToDrive = 10.0 //10 in drive_both_wheels (-motorSpeed, -motorSpeed, distanceToDrive * kInch); } distanceToDrive = 12.0; //12 in drive_both_wheels(motorSpeed, motorSpeed, distanceToDrive * kInch); //backs up to angle for final try degreesToTurn = 90.0; //90 degrees TurnLeft(degreesToTurn * kDegrees); //turns 90 degrees distanceToDrive = 10.0; //10 in drive_both_wheels(motorSpeed, motorSpeed, distanceToDrive * kInch); //drives 4 in degreesToTurn = 90.0; //90 degrees TurnRight(degreesToTurn * kDegrees); //turns 90 degrees distanceToDrive = 30.0; //2.5 feet drive_both_wheels(-motorSpeed, -motorSpeed, distanceToDrive * kInch); //comes in for final try to knock down the kickstand for(i = 0; i <= 1; i++){ distanceToDrive = 6.0; //6 in drive_both_wheels (motorSpeed, motorSpeed, distanceToDrive * kInch); distanceToDrive = 10.0; //10 in drive_both_wheels (-motorSpeed, -motorSpeed, distanceToDrive * kInch); } //the program basically flails around to knock down the kickstand transition(); //waits for autonomous phase to end } // main
void DriveToPegRight () { GoForward (5); TurnRight (50); GoForward (34); TurnLeft (24); if (USE_GUIDED_FWD) { GoForward (45); GuidedDriveForward (60); } else GoForward (105); DropHand (); GoBackwards (10.0); }
void Return(int Steps) { int i;int tp; for(i=0;i<Steps;i++) { Count1(); LineCheck(); tp=ILeftSpeed; ILeftSpeed=IRightSpeed; IRightSpeed=tp; } TurnRight(); //now (just now) does it return to Navigate. }
private func Activity() { var pBait; // Ein Köder in der Nähe? if (pBait=FindObject(0,-1000,-1250,2000,1500, OCF_InLiquid(), "Bait" ) ) // Schwarze Fische sind nicht wählerisch SetCommand(this(),"Follow",pBait); // Schwimmverhalten if (!GBackLiquid (0, -8)) return (SetComDir (COMD_Down ())); if (Random(2)) return(1); if (SEqual(GetAction(),"Walk")) WalkDir(); if (Not( SEqual(GetAction(),"Swim") )) return(1); if (Random(2)) return(TurnRight(),SetComDir(COMD_Right())); return(TurnLeft(),SetComDir(COMD_Left())); }
actionResponse NavStack::ResolveObstacle(Anshu *AnshuPtr,LocStack *Loc){ if(AnshuPtr->get_isFrontObs()){ TurnRight(0,AnshuPtr); DetectObstacle(AnshuPtr,Loc); } //If forward obstacle //Repeat: //If right obstacle //If left obstacle //Move Backward and goto repeat //else TurnLeft //else TurnRight return Ok; }
void Game_Character::FaceRandomDirection() { switch (rand() % 4) { case 0: TurnDown(); break; case 1: TurnLeft(); break; case 2: TurnRight(); break; case 3: TurnUp(); break; } }
void Game_Character::Turn180Degree() { switch (direction) { case RPG::EventPage::Direction_down: TurnUp(); break; case RPG::EventPage::Direction_left: TurnRight(); break; case RPG::EventPage::Direction_right: TurnLeft(); break; case RPG::EventPage::Direction_up: TurnDown(); break; } }
void CPMotion::RandMotion() { int limit = m_cyepersona->GetRandomNumber(3); for (int i = 1; i <= limit; i++) { TurnLeft(200); } limit = m_cyepersona->GetRandomNumber(3); for (int i = 1; i <= limit; i++) { TurnRight(200); } }
void main(void) { // Stop watchdog timer to prevent time out reset WDTCTL=WDTPW+WDTHOLD; //Init_Clk(); //P1DIR |= BIT0 + BIT6; //P1OUT |= (BIT0 + BIT6); CarInit(); while(1) { TurnLeft(1, 1); delayms(1000); TurnRight(1, 1); delayms(1000); } //LPM0; }
void Game_Character::MoveRight() { if (!IsDirectionFixed()) TurnRight(); if (jumping) { jump_plus_x++; return; } if (IsPassable(GetX(), GetY(), RPG::EventPage::Direction_right)) { SetX(GetX() + 1); BeginMove(); stop_count = 0; move_failed = false; } else { CheckEventTriggerTouch(GetX() + 1, GetY()); move_failed = true; } }