void Rock::update(std::vector<std::vector<int>> colMap) { moveM(colMap); if (currentState == FLYING) { if (acceleration.y < 0) { movement.update(vertices, mSize); } else if (acceleration.y > 0) { movement.update(vertices, mSize); } if (acceleration.x < 0) { movement.update(vertices, mSize); } else if (acceleration.x > 0) { movement.update(vertices, mSize); } acceleration.x *= .9; acceleration.y *= .9; if (abs(acceleration.x) <= .1 && abs(acceleration.y) <= .1) { acceleration.x = 0; acceleration.y = 0; } if ((abs(velocity.x) == 0 && abs(velocity.y) == 0)) setCurrentState(GROUND); } if (currentState == GROUND) { setTexCoords(0, 0); } if (currentState == GRABBING) { if (extend.getIndex() == 7) { setCurrentState(HELD); extend.setIndex(0); } else { extend.update(vertices, mSize); } } bounds.left = getPosition().x; bounds.top = getPosition().y; }
void Mob::update(std::vector<std::vector<int>> colMap) { moveM(colMap); if (acceleration.y < 0) { animation.setModifier(UP); animation.update(vertices, mSize); } else if (acceleration.y > 0) { animation.setModifier(DOWN); animation.update(vertices, mSize); } if (acceleration.x < 0) { animation.setModifier(LEFT); animation.update(vertices, mSize); } else if (acceleration.x > 0) { animation.setModifier(RIGHT); animation.update(vertices, mSize); } }