Forums - C# Corner

Forum guidelines
Alvin Eka

Alvin Eka

  • 1.5k
  • 6
  • 199

Running game C# visual studio windows form

Nov 10 2017 8:38 AM
i am currently making a running game for my college assingment using c# with visual studio 2011, currently i managed to make my character jump but i need to make it jump more than once can someone help me with the code?i would appreciate any kind of help
thanks  
 
this is my code for making my player jump
 
in FormKeyDown
 
if (jump == false)
{
if (e.KeyCode == Keys.Space)
{
jump = true;
force = gravity;
}
}
 
in timer
 
if(jump)
{
player.Top -= force;
force--;
}
if(player.Top + player.Height >= screen.Height)
{
player.Top = screen.Height - player.Height;
jump = false;
}
else
{
player.Top += 1;
}
 

Answers (1)