Jump to content
Posted 08 February 2012 - 07:45 AM
Posted 08 February 2012 - 08:29 AM
Posted 08 February 2012 - 09:00 AM
So I take it no gravity means top-down? One clarification: how is the angle you need to turn to calculated? Does the player press left or right to rotate continuously, or does he press a direction to instantly face that direction - or is it something different?
//We need to calculate absolute angles between character current heading and upper limit/ground //get vector to upper y zVec2f vecToUpper, vecToLower; vecToUpper.x = getPosition().x + 5.0f; vecToUpper.y = baseline_y_upper; vecToUpper = vecToUpper - getPosition(); vecToUpper.normalise(); //angle from straight-up to vector pointing towards upper limit float UpperVecAng = vecToUpper.getAngle(); //get vector to lower y vecToLower.x = getPosition().x + 5.0f; vecToLower.y = baseline_y_lower; vecToLower = vecToLower - getPosition(); vecToLower.normalise(); //angle from straight-up to vector pointing towards ground float LowerVecAng = vecToLower.getAngle(); zVec2f heading = moveDir; heading.normalise(); float headingAng = heading.getAngle(); //calculate difference in current heading and upper/lower trajectories float UpperAngDiff = UpperVecAng - headingAng; float LowerAngDiff = LowerVecAng - headingAng;
Posted 08 February 2012 - 09:27 AM
Posted 08 February 2012 - 09:36 AM
how do you want it to move?
My first thought is to separate y and x-movement. x-movement could be constant or slightly accelerating (endless runner style)
when you press, you start to accelerate the y-speed, making it "go down" faster and faster while holding the button.
Maybe you want a "lower limit" where it will start decellerating instead so it can't go below a fixed height too.
Releasing the button to reverse it. (start accelerating upward until its "close enough" to the top, then decellerate so it levels out at the max height)
This would give it a bit "sinus"-like movement.
Posted 09 February 2012 - 03:15 AM