- Square ascends at
upSpeed
until just beforetargetHT
is reached - Right before
targetHT
is reached (90% oftargetHT
?),upSpeed
slows dramatically, becomingfinalUpSpeed
- Once
targetHT
is reached, before falling back to the ground, square will pause and hover very briefly - This simulates the effect of gravity taking over after the upward force has been expended
TargetHT
determined by buttonPressDuration
- Minimum
targetHT
is 100px from ground. - Maximum
targetHT
is 300px from ground. - What is
upSpeed
?- What % of
upSpeed
isfinalUpSpeed
?
- What % of
- What is
downSpeed
?downSpeed
is constant
- Are
upSpeed
/downSpeed
the same? - If not, which is greater?
- (actually,
downSpeed
should be greater)- Min speed is 1 ms, so is this even possible?
- (maybe decrement
squareTop
by more than 1px)
handleJumpButton()
- if jump already in progress, return/handle appropriately
- else set state
jumping
boolean to true - determine
targetHT
based onbuttonPressDuration
- invoke handleJumpPhysics(
targetHT
)
handleButtonDuration()
- Stop
buttonTimer
handleJumpPhysics(tH)
- send square up at
upSpeed
until 90% oftargetHT
reached - reduce
upSpeed
tofinalUpSpeed
untiltargetHT
reached - pause, letting square hover briefly
- (a few milliseconds or so at most)
- send square down at
downSpeed
- reset state
buttonPressDuration
to 0 - set state
jumping
boolean to false