Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. public void ValidateVerticalPosition()
  2.         {
  3.             // if hit od gore (ili dole?) currentJump=0
  4.             // if hit od dole isDoubleJumping = false
  5.  
  6.             foreach(Rectangle boundary in Boundaries)
  7.             {
  8.                 bool collisionAbove = Collisions(Hero.Character, boundary)[0];
  9.                 if (collisionAbove && Hero.Character.IntersectsWith(boundary))
  10.                 {
  11.                     currentJump = 0;
  12.                     Hero.Character = new RectangleF(Hero.Character.X, boundary.Bottom + 0.1f, Hero.Character.Width, Hero.Character.Height);
  13.                     break; // might bug, check out later
  14.                 }
  15.  
  16.                 bool collisionBelow = Collisions(Hero.Character, boundary)[1];
  17.                 if (collisionBelow && Hero.Character.IntersectsWith(boundary))
  18.                 {
  19.                     isDoubleJumping = false;
  20.                     Hero.Character = new RectangleF(Hero.Character.X, boundary.Top - 0.5f - Hero.Character.Height, Hero.Character.Width, Hero.Character.Height);
  21.                     break; // read above
  22.                 }
  23.             }
  24.         }
  25.  
  26.  
  27. public void GravityPull()
  28.         {
  29.             if (currentJump == 0 && HeroIsInAir())
  30.             {
  31.                 Hero.Fall();
  32.             }
  33.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement