public void updateJump() { if (mySprite.CurrentAnim == constants.AnimType.JUMPING) { if (startingPos.Y - mySprite.GlobPos.Y > constants.JUMP_HEIGHT) { myJumpType = constants.jumpType.FALLING; } if ((mySprite.GlobPos.Y > startingPos.Y) && myJumpType == constants.jumpType.FALLING) { mySprite.GlobPos = new Vector2(mySprite.GlobPos.X, startingPos.Y); setAnim(constants.AnimType.STANDING); } int xPos = 0; if (isOnLeft) { if (myJumpType == constants.jumpType.FORWARD) { xPos = (int)constants.JUMP_SPEED/2; } else if (myJumpType == constants.jumpType.BACK) { xPos -= (int)constants.JUMP_SPEED/2; } } else { { if (myJumpType == constants.jumpType.FORWARD) { xPos -= (int)constants.JUMP_SPEED/2; } else if (myJumpType == constants.jumpType.BACK) { xPos = (int)constants.JUMP_SPEED/2; } } } // We are falling. Decrement pos. if (myJumpType != constants.jumpType.FALLING) { mySprite.incPos(xPos, -((int)constants.JUMP_SPEED)); } else { // We are still jumping. mySprite.incPos(xPos, (int)constants.JUMP_SPEED); } } }
public void startJump(constants.jumpType jumpType) { if (mySprite.CurrentAnim != constants.AnimType.JUMPING) { this.setAnim(constants.AnimType.JUMPING); myJumpType = jumpType; updateJump(); } }