void AddVelocityCurrPos(struct Tracker_Windows *window){ struct WBlocks *wblock=window->wblock; struct LocalZooms *realline= wblock->reallines[wblock->curr_realline]; int subtrack=window->curr_track_sub; if(-1==subtrack) return; ADD_UNDO(Notes_CurrPos(window)); struct Notes *note = FindNoteOnSubTrack( wblock->wtrack, subtrack, &realline->l.p ); if(note==NULL) return; AddVelocity( root->standardvel, &realline->l.p, note ); #if !USE_OPENGL ClearTrack(window,wblock,wblock->wtrack,wblock->top_realline,wblock->bot_realline); UpdateWTrack(window,wblock,wblock->wtrack,wblock->top_realline,wblock->bot_realline); #endif }
void psLinearMovement::SetSoftDRData (bool on_ground, csVector3& pos, float yrot, iSector *sector, csVector3& vel, csVector3& worldVel, float ang_vel) { if (colldet) colldet->SetOnGround (on_ground); csVector3 cur_pos; float cur_rot; iSector *cur_sect; GetLastPosition (cur_pos, cur_rot, cur_sect); if (cur_sect == sector) { offset_err = pos - cur_pos; // Check for NaN conditions: if (offset_err.x != offset_err.x) offset_err.x = 0.0f; if (offset_err.y != offset_err.y) offset_err.y = 0.0f; if (offset_err.z != offset_err.z) offset_err.z = 0.0f; offset_rate = offset_err; SetPosition (cur_pos, yrot, sector); } else { offset_rate = offset_err = csVector3 (0.0f, 0.0f ,0.0f); SetPosition (pos, yrot, sector); } SetVelocity (vel); ClearWorldVelocity (); AddVelocity (worldVel); csVector3 rot (0.0f, ang_vel, 0.0f); SetAngularVelocity (rot); lastDRUpdate = csGetTicks (); }
void ZCharacterObject::OnKnockback(rvector& dir, float fForce) { AddVelocity(dir * fForce); // ³Ë¹é ÃÖ´ë¼Óµµ¿¡ ¸ÂÃá´Ù rvector vel = GetVelocity(); if (Magnitude(vel) > MAX_KNOCKBACK_VELOCITY) { Normalize(vel); vel *= MAX_KNOCKBACK_VELOCITY; SetVelocity(vel); } // Ÿ°Ý°¨ - ²ÞƲ rvector dir1 = m_Direction; rvector dir2 = dir; Normalize(dir2); float cosAng1 = DotProduct(dir1, dir2); float fMaxValue = m_fTremblePower; if (cosAng1 < 0.f) { fMaxValue = -fMaxValue; } Tremble(fMaxValue, 50, 100); }
int Particle::Update() { iLife--; fAlpha = min(1, iLife/60.f); fFlash = max(0, fFlash-0.125f); AddVelocity(0, fGravity); if (iLife <= 0) return STATE_DELETED; else return GameObj::Update(); }
/** Update this game object by updating position, velocity and angle of object. */ void GameObject::Update(int t) { // Calculate seconds since last update float dt = t / 1000.0f; // Update angle AddAngle(mRotation * dt); // Update position AddPosition(mVelocity * dt); // Update velocity AddVelocity(mAcceleration * dt); // Update sprite if one exists if (mSprite.GetPtr() != NULL) mSprite->Update(t); // If in world, wrap position const int zl = mGameWindow->GetZoomLevel(); if (mWorld) { mWorld->WrapXY(mPosition.x, mPosition.y); } }
void psLinearMovement::SetDRData (bool on_ground, csVector3& pos, float yrot, iSector *sector, csVector3& vel, csVector3& worldVel, float ang_vel) { if (colldet) { colldet->SetOnGround (on_ground); } SetPosition (pos,yrot,sector); SetVelocity (vel); ClearWorldVelocity (); AddVelocity (worldVel); csVector3 rot (0.0f, ang_vel, 0.0f); SetAngularVelocity (rot); lastDRUpdate = csGetTicks (); lastClientDRUpdate = lastDRUpdate; lastClientPosition = pos; lastClientSector = sector; lastClientYrot = yrot; }
void ZActor::ProcessMovement(float fDelta) { bool bMoving = CheckFlag(AF_MOVING); bool bLand = CheckFlag(AF_LAND); if ( CheckFlag(AF_MOVING) && CheckFlag(AF_LAND) && ((GetCurrAni() == ZA_ANIM_WALK) || (GetCurrAni() == ZA_ANIM_RUN))) { float fSpeed = m_fSpeed; if (GetCurrAni() == ZA_ANIM_RUN) fSpeed = m_fSpeed; const float fAccel = 10000.f; AddVelocity(m_Direction * fAccel * fDelta); rvector vel = GetVelocity(); if (Magnitude(vel) > fSpeed) { Normalize(vel); vel *= fSpeed; SetVelocity(vel); } return; } if(CheckFlag(AF_BLAST_DAGGER)) { float fSpeed = m_fSpeed; #define BLAST_DAGGER_MAX_TIME 0.8f float fTime = max((1.f - (g_pGame->GetTime() - m_fAddBlastVelTime) / BLAST_DAGGER_MAX_TIME),0.0f); if( fTime < 0.4f ) fTime = 0.f; float fPower = 400.f * fTime * fTime * fDelta * 80.f; if(fPower==0.f) SetFlag(AF_BLAST_DAGGER,false); rvector vel = m_vAddBlastVel * fPower; SetVelocity( vel ); return; } if (ZActorAnimation::IsAttackAnimation(GetCurrAni())) { SetVelocity(rvector(0,0,0)); } else { rvector dir=rvector(GetVelocity().x,GetVelocity().y,0); float fSpeed=Magnitude(dir); Normalize(dir); float fRatio = m_pModule_Movable->GetMoveSpeedRatio(); float max_speed = 600.f * fRatio; if(fSpeed>max_speed) fSpeed=max_speed; #define NPC_STOP_SPEED 2000.f fSpeed = std::max(fSpeed-NPC_STOP_SPEED*fDelta, 0.0f); SetVelocity(dir.x*fSpeed, dir.y*fSpeed, GetVelocity().z); } }
void Flow2D::AddVelocityOnLine(int fromPx, int fromPy, int toPx, int toPy,float vel, const int bold) { if (vel<= 0.0) return; int iVx = toPx - fromPx; int iVy = toPy - fromPy; vel = vel/sqrtf((float)(iVx * iVx + iVy * iVy)); if ( vel == 0.0f ) return; float mx, my; int px,py; float fVx = float(iVx) * vel; float fVy = float(iVy) * vel; if (fVx == 0.0f) { if (fromPy > toPy) { Swap(fromPx, toPx); Swap(fromPy, toPy); } for (int j = fromPy; j <= toPy; j++) { for (int i = fromPx - bold; i <= fromPx + bold; i++){ AddVelocity(GetIndex(i, j), fVx, fVy); } } } else if (fVy == 0.0f) { if (fromPx > toPx) { Swap(fromPx, toPx); Swap(fromPy, toPy); } for (int i = fromPx; i < toPx; i++) { for (int j = fromPy - bold; j <= fromPy + bold; j++) { AddVelocity(GetIndex(i, j), fVx, fVy); } } } else { mx = (float)(fVy / fVx); if (fabs(mx) < 1.0) { if (fromPx > toPx) { Swap(fromPx, toPx); Swap(fromPy, toPy); } for (int i = fromPx; i < toPy; i++) { py = (int)( mx * (i - fromPx) + fromPy); for (int j = py - bold; j <= py + bold; j++) { AddVelocity(GetIndex(i, j),fVx, fVy); } } } else { if (fromPy > toPy) { Swap(fromPx, toPx); Swap(fromPy, toPy); } my = (float)(fVx / fVy); for (int j = fromPy; j < toPy; j++) { px = (int)(my * (j - fromPy) + fromPx); for(int i = px - bold ; i <= px + bold; i++){ AddVelocity(GetIndex(i, j), fVx, fVy); } } } } SetBoundary(m_Vel.x.aligned); SetBoundary(m_Vel.y.aligned); }
void GameObj::AddVelocity( const float x, const float y ){ AddVelocity(D3DXVECTOR3(x, y, 0)); }