void CombatCamera::ZoomImpl(Ogre::Real total_move) { m_camera_animation->destroyAllTracks(); if (Moving()) total_move += m_distance_to_look_at_point_target - DistanceToLookAtPoint(); Ogre::Real distance = ZoomResult(total_move); Ogre::Vector3 camera_start = CameraPositionAndOrientation(DistanceToLookAtPoint()).first; Ogre::Vector3 camera_stop = CameraPositionAndOrientation(distance).first; const Ogre::Vector3 CAMERA_DELTA = camera_stop - camera_start; m_camera_animation_state->setTimePosition(0.0); Ogre::AnimableValuePtr animable_camera_pos(new AnimableCamera(m_camera, camera_start)); Ogre::NumericAnimationTrack* camera_track = m_camera_animation->createNumericTrack(CAMERA_TRACK_HANDLE, animable_camera_pos); const Ogre::Vector3 CAMERA_INCREMENT = CAMERA_DELTA / CAMERA_ANIMATION_STEPS; // the loop extends an extra 2 steps in either direction, to // ensure smoothness (since splines are being used) for (int i = -2; i < CAMERA_ANIMATION_STEPS + 2; ++i) { Ogre::NumericKeyFrame* camera_key = camera_track->createNumericKeyFrame(i * TIME_INCREMENT); camera_key->setValue(camera_stop - CAMERA_DELTA + i * CAMERA_INCREMENT); } m_distance_to_look_at_point_target = distance; }
LRESULT DockCont::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { if (message == WM_NCRBUTTONDOWN) { WindowMenu(); return 1L; } if (message == WM_NCLBUTTONDOWN && IsFloating() && base) dragging = 1; if (message == WM_NCLBUTTONUP) dragging = 0; if (message == WM_MOVE && IsFloating() && base && GetMouseLeft() && dragging) { if (dragging == 1) { MoveBegin(); dragging++; } Moving(); dragging = 2; } else if (message == WM_EXITSIZEMOVE && IsFloating() && base && !GetMouseLeft() && dragging) { MoveEnd(); dragging = 0; } return TopWindow::WindowProc(message, wParam, lParam); }
void CombatCamera::MouseWheel(const GG::Pt& pt, int move, GG::Flags<GG::ModKey> mod_keys) { Ogre::Real total_move = TotalMove(move, mod_keys, DistanceToLookAtPoint()); if (0 < move) { const unsigned int TICKS = GG::GUI::GetGUI()->Ticks(); const unsigned int ZOOM_IN_TIMEOUT = 750u; if (m_initial_zoom_in_position == INVALID_MAP_LOCATION || ZOOM_IN_TIMEOUT < TICKS - m_previous_zoom_in_time) { std::pair<bool, Ogre::Vector3> intersection = IntersectMouseWithEcliptic(pt); m_initial_zoom_in_position = intersection.first ? intersection.second : INVALID_MAP_LOCATION; } if (m_initial_zoom_in_position != INVALID_MAP_LOCATION) { const double CLOSE_FACTOR = move * 0.333 * ZoomFactor(mod_keys); Ogre::Vector3 start = Moving() ? m_look_at_point_target : LookAtPoint(); Ogre::Vector3 delta = m_initial_zoom_in_position - start; double delta_length = delta.length(); double distance = std::min(std::max(1.0, delta_length * CLOSE_FACTOR), delta_length); delta.normalise(); Ogre::Vector3 new_center = start + delta * distance; if (new_center.length() < SystemRadius()) LookAtPositionAndZoom(new_center, ZoomResult(total_move)); } m_previous_zoom_in_time = TICKS; } else if (move < 0) { ZoomImpl(total_move); } }
void DockCont::EventProc(XWindow& w, XEvent *event) { if (IsOpen()) { switch(event->type) { case ConfigureNotify:{ XConfigureEvent& e = event->xconfigure; if (Point(e.x, e.y) != GetScreenRect().TopLeft()) { if (!dragging) MoveBegin(); Moving(); SetFocus(); dragging = true; } } break; case FocusIn: { XFocusChangeEvent &e = event->xfocus; if (e.mode == NotifyUngrab && dragging) { dragging = false; MoveEnd(); // SetFocus(); return; } break; } } } TopWindow::EventProc(w, event); }
void FlyingComputer::Compute(fixed takeoff_speed, const NMEAInfo &basic, const NMEAInfo &last_basic, const DerivedInfo &calculated, FlyingState &flying) { if (basic.HasTimeRetreatedSince(last_basic)) { Reset(); flying.Reset(); } // GPS not lost if (!basic.location_available) return; // Speed too high for being on the ground const fixed speed = basic.airspeed_available ? std::max(basic.true_airspeed, basic.ground_speed) : basic.ground_speed; if (speed > takeoff_speed || (calculated.altitude_agl_valid && calculated.altitude_agl > fixed(300))) Moving(flying, basic.time, basic.location); else Stationary(flying, basic.time, basic.location); }
void FlyingComputer::Compute(fixed takeoff_speed, const AircraftState &state, FlyingState &flying) { if (state.ground_speed > takeoff_speed) Moving(flying, state.time); else Stationary(flying, state.time); }
void FlyingComputer::Compute(fixed takeoff_speed, const AircraftState &state, fixed dt, FlyingState &flying) { if (negative(state.time)) return; if (state.ground_speed > takeoff_speed) Moving(flying, state.time, dt, state.location); else Stationary(flying, state.time, dt, state.location); }
void FlyingComputer::Compute(double takeoff_speed, const AircraftState &state, double dt, FlyingState &flying) { if (state.time < 0) return; if (state.ground_speed > takeoff_speed) Moving(flying, state.time, dt, state.location); else Stationary(flying, state.time, dt, state.location); }
void Simulator (Vehicle *vehicle, char *type, int distance) { srand (time (NULL)); int clock = 0, obstacle = 0, at_destination = 0; InitScreen (distance, type); attrset (A_BOLD); while (! at_destination && distance > 0) { mvaddstr (17, 19, "Driving... "); Moving (vehicle, clock++, obstacle, distance, 0, "[]O>"); at_destination = vehicle->Drive (); if ((rand () % 10) == 0 && ! at_destination) { Crashing (vehicle, clock++, obstacle++, distance, 1); mvaddstr (17, 19, "Backing up... "); vehicle->Reverse (); Moving (vehicle, clock++, obstacle, distance, 0, "<O[]"); Moving (vehicle, clock++, obstacle, distance, -1, "<O[]"); mvaddstr (17, 19, "Passing... "); Moving (vehicle, clock++, obstacle, distance, -1, "[]O>"); vehicle->Reverse (); at_destination = vehicle->Pass (); } } mvaddstr (17, 19, "Turning off... "); Moving (vehicle, clock++, obstacle, distance, 0, "[]O>"); attrset (A_NORMAL); refresh (); }
void TMaze::Movement(Direction d) // Makes the move in d direction { if (Moving()) return; switch (d) { case dirForward: if (!Cube.Move( Cube.Forward() )) // Can't move forward return; else break; case dirBack: if (!Cube.Move( Cube.Back() )) // Can't move back return; else break; case dirUp: Cube.TurnUp(); break; case dirDown: Cube.TurnDown(); break; case dirLeft: Cube.TurnLeft(); break; case dirRight: Cube.TurnRight(); break; } Move = d; Step = Frames; AnimationType = aniMovement; }
void TrackRegulator(float *Coord_cur, float *SpeedCur, Path *cur, float *V) { float velocity[3] = {0.0, 0.0, 0.0}; float cosAlphZad = cosf(cur->alphZad), sinAlphZad = sinf(cur->alphZad); float t_alph_zad[2][2]; float buf1[3]; float velFromEt[2]; //float tracer; //float Coord_local_track[3] = {0.0, 0.0, 0.0}; matrixPlusMinus(Coord_cur,cur->coordCenter, 3, 1, -1, &buf1[0]); //(CURCOORD-CUR_CENTER) = buf1 t_alph_zad[0][0] = cosAlphZad; t_alph_zad[0][1] = sinAlphZad; t_alph_zad[1][0] = -sinAlphZad; t_alph_zad[1][1] = cosAlphZad; matrixMultiplyM2M(&t_alph_zad[0][0], 2, 2, SpeedCur, 2, 1, &(cur->Speed_local_track[0])); matrixMultiplyM2M(&t_alph_zad[0][0], 2, 2, &buf1[0], 2, 1, &(cur->Coord_local_track[0]));// cur->Coord_local_track[2] = (robotCoord[2]-cur->coordCenter[2])*cur->phiDir; if (cur->Coord_local_track[2]<0) cur->Coord_local_track[2]+=2.0*PI; //if(Coord_local_track[0]<0) // tracer=fabs(Coord_local_track[0]); //else // tracer=Coord_local_track[0]; Moving(cur->Coord_local_track[0], (cur->lengthTrace), (cur->traceVel), &velFromEt[0]); RotMoving((cur->coordCenter[2]), robotCoord[2], (cur->phiZad), (cur->omegaVel), &velFromEt[1]); //velFromEt[1]= velFromEt[1]*cur->phiDir; //LOCALCOORD(3,1)=(phiZad-CURCOORD(3,1)); //VELOCITY=regulate(LOCALCOORD,vEt); Regulate(&(cur->Coord_local_track[0]), &(cur->Speed_local_track[0]), &t_alph_zad[0][0], &velFromEt[0], &(cur->alphZad), &velocity[0]); matrixCopy(&velocity[0], 3, 1, &V[0]); }////////////////////////////////////////////////////////////////////////////////
/*---------------------------------------------------------------------- GeometryMove draws a box at a specific origin location (x,y) in frame and of size (width, height) when interracting with the user to mofify the box position (button press). xmin, xmax, ymin, ymax are the maximum values allowed. xm and ym gives the initial mouse coordinates in the frame. This function returns the new position (x, y) of the origin. ----------------------------------------------------------------------*/ void GeometryMove (int frame, int *x, int *y, int width, int height, PtrBox box, int xmin, int xmax, int ymin, int ymax, int xm, int ym) { Moving (frame, x, y, width, height, box, xmin, xmax, ymin, ymax, xm, ym); }
int TaskForceClass::GetDeaggregationPoint (int slot, CampEntity *installation) { int pt=0,type; static int last_pt, index = 0; if (!*installation) { // We're looking for a new list, so clear statics last_pt = index = 0; // Check if we care about placement if (!Moving()) { // Find the appropriate installation GridIndex x,y; Objective o; GetLocation(&x,&y); o = FindNearestObjective (x,y,NULL,0); *installation = o; // Find the appropriate list if (o) { ObjClassDataType *oc = o->GetObjectiveClassData(); index = oc->PtDataIndex; while (index) { if (PtHeaderDataTable[index].type == DockListType) { // The first time we look, we just want to know if we have a list. // Return now. return index; } index = PtHeaderDataTable[index].nextHeader; } #ifdef DEBUG FILE *fp = fopen("PtDatErr.log","a"); if (fp) { char name[80]; o->GetName(name,79,FALSE); fprintf(fp, "Obj %s @ %d,%d: No header list of type %d.\n",name,x,y,DockListType); fclose(fp); } #endif } } } if (index) { // We have a list, and want to find the correct point UnitClassDataType *uc = GetUnitClassData(); VehicleClassDataType *vc = GetVehicleClassData(uc->VehicleType[slot]); // Check which type of point we're looking for // TODO: Check ship type here... // type = SmallDockPt; type = LargeDockPt; // Return the next point, if it's the base type // NOTE: Log error if we don't have enough points of this type if (last_pt) { last_pt = pt = GetNextPt(last_pt); #ifdef DEBUG if (!pt || PtDataTable[pt].type != type) { FILE *fp = fopen("PtDatErr.log","a"); if (fp) { char name[80]; GridIndex x,y; (*installation)->GetName(name,79,FALSE); (*installation)->GetLocation(&x,&y); fprintf(fp, "HeaderList %d (Obj %s @ %d,%d): Insufficient points of type %d.\n",index,name,x,y,type); fclose(fp); } } #endif return pt; } // Find one of the appropriate type pt = GetFirstPt(index); while (pt) { if (PtDataTable[pt].type == type) { last_pt = pt; return pt; } pt = GetNextPt(pt); } #ifdef DEBUG FILE *fp = fopen("PtDatErr.log","a"); if (fp) { char name[80]; GridIndex x,y; (*installation)->GetName(name,79,FALSE); (*installation)->GetLocation(&x,&y); fprintf(fp, "HeaderList %d (Obj %s @ %d,%d): No points of type %d.\n",index,name,x,y,type); fclose(fp); } #endif } return pt; }
void SceneNode::Update(float dt) { Moving(dt); }
void FlyingComputer::Compute(fixed takeoff_speed, const NMEAInfo &basic, const DerivedInfo &calculated, FlyingState &flying) { if (!basic.time_available || !basic.location_available) return; const fixed dt = delta_time.Update(basic.time, fixed(0.5), fixed(20)); if (negative(dt)) { Reset(); flying.Reset(); } if (!positive(dt)) return; const auto any_altitude = basic.GetAnyAltitude(); if (!basic.airspeed_available && !calculated.altitude_agl_valid && any_altitude.first && !negative(last_ground_altitude) && any_altitude.second > last_ground_altitude + fixed(250)) { /* lower the threshold for "not moving" when the aircraft is high above the take-off airfield and there's no airspeed probe; this shall reduce the risk of false landing detection when flying in strong head wind (e.g. ridge or wave) */ fixed dh = any_altitude.second - last_ground_altitude; if (dh > fixed(1000)) takeoff_speed /= 4; else if (dh > fixed(500)) takeoff_speed /= 2; else takeoff_speed = takeoff_speed * 2 / 3; } if (CheckTakeOffSpeed(takeoff_speed, basic) || CheckAltitudeAGL(calculated)) Moving(flying, basic.time, dt, basic.location); else if (!flying.flying || (CheckLandingSpeed(takeoff_speed, basic) && (!any_altitude.first || !CheckClimbing(dt, any_altitude.second)))) Stationary(flying, basic.time, dt, basic.location); if (basic.engine_noise_level_available) CheckPowered(dt, basic, flying); if (any_altitude.first) { if (flying.on_ground) last_ground_altitude = any_altitude.second; CheckRelease(flying, basic.time, basic.location, any_altitude.second); } else sinking_since = fixed(-1); if (flying.flying && flying.release_location.IsValid()) { fixed distance = basic.location.Distance(flying.release_location); if (distance > flying.far_distance) { flying.far_location = basic.location; flying.far_distance = distance; } } }
//Ham chua noi dung Update cac su kien //Trong ham chua Ham kiem tra Ban phim void clsMapple::Update(clsInput *input, clsCamera *camera, list<clsObject*> *l_StaticObj, list<clsObject*> *l_DynamicObj) { if(m_x<camera->rectCamera.left) m_x = camera->rectCamera.left; if(m_x+m_width>camera->rectCamera.right) m_x = camera->rectCamera.right-m_width; ProcessInput(input); if(!m_Dev) { ResetRect(0,65,8,42); m_Arrow->ResetRect(3,9,8,60); } else { ResetRect(0,65,0,50); m_Arrow->ResetRect(3,9,8,60); } //ResetRect(); if(m_Light) if(m_Develop->Delay()) m_Develop->Next(); if(m_Develop->m_frameNow==m_Develop->m_frameTotal-1) { //m_Develop->SetIndex(0); m_Light = false; } if(m_exp>KN[m_level-1]) { m_exp = 0; m_Light = true; m_dame+=20; m_level++; if(m_level==3) { m_Dev = true; } m_health = M[m_level-1]; } Moving(l_StaticObj,l_DynamicObj); //if(m_Jumping) // Jump(); if(m_Arrow->m_alive) { m_Arrow->Update(input, camera,l_StaticObj,l_DynamicObj); /*if(m_Arrow->m_x > 1000||m_Arrow->m_x < 0) m_Arrow->m_alive=false;*/ } if(m_life<=0) gamelose = true; clsObject *temp; list<clsObject*>::iterator i; for(i=l_DynamicObj->begin();i!=l_DynamicObj->end();i++) { temp = *i; if(clsCollision::KiemTraVaCham(m_Rect,temp->m_Rect)&& temp->m_ID!=4) { if(!isProtected&&temp->m_alive&&m_Action!=DIE) { if(m_health - temp->m_dame >0) { isProtected=true; waitProtected = 0; waitRender=0; m_health -= temp->m_dame; } else { m_health = 0; m_Action = DIE; m_life--; } break; } } if(clsCollision::KiemTraVaCham(m_Rect,temp->m_Rect)&&(temp->m_ID==4)) { if(m_Rect.left>=(temp->m_Rect.left-10)&&m_Rect.right<=(temp->m_Rect.right+10)) isNext = true; } else isNext = false; } if(isProtected) { if(m_timeProtcted->CallWaiting()) { waitProtected++; waitRender++; if(waitRender>2) { waitRender--; isRender = !isRender; } if(waitProtected>50) { isRender = true; isProtected = false; } } } switch(m_Action) { case STAND: if(m_Maple->Delay()) m_Maple->Next(4,5); if(m_Maple->m_frameNow==4) m_Maple->m_delayTime->SetTimePerImage(500); break; case MOVE: if(m_Maple->Delay()) m_Maple->Next(0,3); if(m_Mapple2->Delay()) m_Mapple2->Next(0,3); break; case JUMP: m_Maple->SetIndex(8); m_Mapple2->SetIndex(4); //Jump(); break; case SHOOT: if(!m_Dev) { if(m_Maple->Delay()) m_Maple->Next(9,11); if(m_Maple->m_frameNow==11) { m_Action = m_oldAction; if(m_Jumping==false) m_Action = STAND; } } else { if(m_Mapple2->Delay()) m_Mapple2->Next(7,9); if(m_Mapple2->m_frameNow==7) { m_Action = m_oldAction; if(m_Jumping==false) m_Action = STAND; } } break; case CLIMB: /*if(m_Mapple2->Delay()) m_Mapple2->Next(5,6);*/ break; case DIE: if(m_Die->m_frameNow==m_Die->m_frameTotal-1) { if(m_life>0) { m_alive = true; m_Action = STAND; m_health = m_revivehealth; isProtected=true; waitProtected = 0; waitRender=0; m_Light = true; } } if(m_Die->Delay()) m_Die->Next(); break; default: break; } }
int main(void) { U16 Dis = 0; U16 cnt; U16 ccnt; Main_Init(); /* X_Move_deg(); } _delay_ms(500); */ while(1) { /* for(cnt=0; cnt<200; cnt++) { X_Move_deg(); } */ if( startpoint1 == 1 ) { startpoint1 = 0; X_Move_Startpoint(); _delay_ms(100); Y_Move_Startpoint(); } else if( startpoint2 == 1) { startpoint2 = 0; Moving(); // until start point for(ccnt=0; ccnt<17; ccnt++) { for(cnt=0; cnt<200; cnt++) { X_Move_deg(); } _delay_ms(1); if( BREAK_NUM0 == 1) { BREAK_NUM0 = 0; _delay_ms(1); X_Move_Return(); } _delay_ms(500); ///////////////////////////// X_sensing and return until this line Y_Move_Simple(CCW); _delay_ms(1); if( BREAK_NUM1 == 1 ) { BREAK_NUM1 = 0; break; } } } else if( startpoint3 == 1) { startpoint3 = 0; for(cnt=0; cnt<200; cnt++) { X_Move_deg(); } _delay_ms(1); if( BREAK_NUM0 == 1) { BREAK_NUM0 = 0; _delay_ms(1); X_Move_Return(); } } else if(startpoint4 == 1) { startpoint4 = 0; X_Move_deg(); //Read_ADC_NOSTOP(0); //Dis = (( (11.65/(( ADC/204.8) - 0.147 )) - 0.42 ) * 10)-4; //Uart_U16Bit_PutNum(1,Dis); } else if(startpoint5 == 1) { startpoint5 = 0; X_Move_Return(); } } /* Read_ADC(0); Dis = (( (11.65/((ADC/204.8) - 0.147) ) - 0.42 ) * 10)-4; Uart_U16Bit_PutNum(1,Dis); */ return 0; }
KVOID BulletFactor::Tick( KFLOAT fElapsed ) { Factor::Tick(fElapsed); Moving(fElapsed); }