Hello. I am trying to make a simple 2D game with a person that can walk and jump over objects.
I made a function - person_Jump(), it is supposed to make the player jump and then fall.
My problem is that when the function is being run I can not move the person left or right,
and by the time the function ends the player is on the ground again. How can I fix this?
Code:
private async void person_Jump()
{
double originalX = personX;
double originalY = personY;
for (int i = 0; i < 10; i++) // Run a jump animation.
{
personY -= 10; // personY : person.Margin.Top
await Task.Delay(10);
}
for (int i = 0; i < 10; i++) // Run a fall animation.
{
personY += 10; // personX : person.Margin.Left
await Task.Delay(10);
}
}
EDIT: Ok, I got that part working fine.
Now I need the player to keep momentum when jumping,
and not stop moving.
Request clarification if needed.
Thanks in advance.