void CircFigure::yMovement(vector<Figure*>& other, int deltaTicks) { int count = 0; //gravity considerations determineGravity(); //jump action determineJump(); //check if inAir is true checkIfInAir(other); p.y += v.y * deltaTicks / 1000.0; if (isCollided(other, count)) { if (v.y * deltaTicks / 1000.0 < 0) p.y -= floor(v.y * deltaTicks / 1000.0); else p.y -= ceil(v.y * deltaTicks / 1000.0); if (gravityEnabled) v.y = 0; } else if (p.y > lh - r) p.y = lh - r; }
void CircFigure::xMovement(vector<Figure*>& other, int deltaTicks) { int count = 0; p.x += v.x * deltaTicks / 1000.0; if (isCollided(other, count)) p.x -= gravity / 2 * v.x * deltaTicks / 1000.0; else if (p.x > lw - r) p.x = lw - r; else if (p.x < r) p.x = r; }
void Figure::xMovement(vector<Figure*>& other, int deltaTicks) { int count = 0; p.x += v.x * deltaTicks / 1000.0; if (isCollided(other, count) && count != -1) resolveCollision(other[count], deltaTicks, XHAT); else if (p.x > lw - dim.w) p.x = lw - dim.w; else if (p.x < 0) p.x = 0; }
void CircFigure::checkIfInAir(vector<Figure*>& other) { int count = 0; inAir = true; p.y += 3; //if on floor or standing on another Figure if ((v.y == 0 && p.y >= lh - r) || (isCollided(other, count))) inAir = false; p.y -= 3; //Figure is at the peak of trajectory if (p.y < lh - r && v.y <= 0.5 && v.y >= 0.5) inAir = true; }
void PlayerFigure::xMovement(vector<Figure*>& other, int deltaTicks) { int count = 0; //x movement grabstate determineGrabX(deltaTicks); p.x += (v.x * deltaTicks / 1000.0) + grabVel.x; if (isCollided(other, count) && count != -1) resolveCollision(other[count], deltaTicks, XHAT); else if (p.x > lw - dim.w) p.x = lw - dim.w; else if (p.x < 0) p.x = 0; }
void Figure::checkIfInAir(vector<Figure*>& other) { int count = 0; inAir = true; p.y += 3; //standing on ground or other Figure if ((v.y == 0 && p.y >= lh - dim.h) || (v.y <= gravity && isCollided(other, count))) inAir = false; p.y -= 3; //peak of trajectory if (p.y < lh - dim.h && v.y <= 0.5 && v.y >= -0.5) inAir = true; }
void PlayerServer::update(float dt, Terrain *terrain, std::list<BaseObject*> *plistRelativeObjs) { char oldState = mState; D3DXMATRIX oldRotMat = mRotMat; D3DXVECTOR3 oldScale = mScale; D3DXVECTOR3 oldPos = mPos; updateState(dt, terrain); if(isCollided(plistRelativeObjs)) { setTransMat(oldRotMat, oldScale, oldPos); SSync syncPack; syncPack.nPlayerID = mID; syncPack.mRotMat = mRotMat; syncPack.vScale = mScale; syncPack.vPos = mPos; syncPack.chState = mState; gNetServer->SendPacketToAll(&syncPack); } }
void Figure::yMovement(vector<Figure*>& other, int deltaTicks) { int count = 0; //gravity considerations determineGravity(); //jump action determineJump(); //check if inAir is true checkIfInAir(other); //collision with boundaries or other Figures p.y += v.y * deltaTicks / 1000.0; if (isCollided(other, count) && count != -1) { resolveCollision(other[count], deltaTicks, YHAT); } else if (p.y > lh - dim.h) p.y = lh - dim.h; }
void PlayerFigure::checkIfInAir(vector<Figure*>& other) { int count = 0; inAir = true; //standing on ground or other Figure p.y += 3; if ((v.y == 0 && p.y >= lh - dim.h) || (v.y <= gravity && isCollided(other, count))) inAir = false; p.y -= 3; //peak of trajectory if (p.y < lh - dim.h && v.y <= 0.5 && v.y >= -0.5) inAir = true; //collision with TempFigure when in midair if (count != -1 && ((typeid(*other[count]) == typeid(TempFigure) && p.y < lh - dim.h) || (typeid(*other[count]) == typeid(GrabbableFigure) && p.y < lh - dim.h))) inAir = true; }