Exemplo n.º 1
0
void Player::move(float dt)
{
    if(_inputManager->isPressed(SDLK_w)){
        currentMoveSpeed += acceleration * dt;
    }
    if(_inputManager->isPressed(SDLK_s)){
        currentMoveSpeed += -acceleration * dt;
    }
    if(_inputManager->isPressed(SDLK_a)){
        currentTurnSpeed = Maths::interpolate(currentTurnSpeed, 900.0f, dt);
    }
    if(_inputManager->isPressed(SDLK_d)){
        currentTurnSpeed = Maths::interpolate(currentTurnSpeed, -900.0f, dt);
    }
    if(_inputManager->isPressed(SDLK_SPACE)){
        upwardSpeed = 20;
    }
    
    float distance = currentMoveSpeed * dt;
    float dx = distance * glm::sin(glm::radians(_ry));
    float dz = distance * glm::cos(glm::radians(_ry));
    
    increasePosition(dx, 0, dz);
    increaseRotation(0, currentTurnSpeed * dt, 0);
    
    currentMoveSpeed *= 0.9f;
    currentTurnSpeed *= 0.9f;
}
Exemplo n.º 2
0
unsigned int DataReadingInfo::readBits(int numberOfBits) {
    unsigned int ret = 0;
    int bitsToRead = numberOfBits;

    int bitsToReadThisByte = 0;

    while (bitsToRead > 0){
        //unsigned int byteValue = *currentByte;
        unsigned int byteValue = currentByte;

        int bitsAvailThisByte = 8 - posInByte;
        bitsToReadThisByte = (bitsToRead < bitsAvailThisByte) ? bitsToRead : bitsAvailThisByte;

        int bitsToShift = bitsAvailThisByte - bitsToReadThisByte;
        byteValue = applyMask(byteValue >> bitsToShift, bitsToReadThisByte);

        bitsToRead -= bitsToReadThisByte;

        ret += byteValue;

        if (bitsToRead > 0) {
            //We have processed the whole byte, but there are still bits to read: move to the next byte
            moveToNextByte();

            //Make room for the next bits to be read
            shiftToLeftCurrentValue(ret, (bitsToRead >= 8) ? 8 : bitsToRead);
        }
    }

    increasePosition(bitsToReadThisByte);

    return ret;
}
Exemplo n.º 3
0
void Orange::move(int delta_t) {
	increaseRotation(160.0f *(delta_t / 1000.0f), 0, 0);
	current_speed += aceleration * delta_t;
	float distance = current_speed * delta_t;
	increasePosition(0, 0, distance);
	//increasePosition(0, 0, initial_velocity[2] + aceleration);
}
Exemplo n.º 4
0
void Player::jump(float dt)
{
    upwardSpeed += -80.0f * dt;
    increasePosition(0, upwardSpeed * dt, 0);
    if(_position.y < 0){
        _position.y = 0;
        upwardSpeed = 0;
    }
}