Advertisement
Guest User

Bounds

a guest
Dec 3rd, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace EAE_Assignment_8
  8. {
  9.     class Bounds : Component
  10.     {
  11.         int bounds;
  12.  
  13.  
  14.         public Bounds(int bounds)
  15.         {
  16.             this.bounds = bounds;
  17.            
  18.            
  19.         }
  20.  
  21.         public override void Update()
  22.         {
  23.             if (Container.Position.x > bounds )
  24.             {
  25.                 Container.Position.x = bounds;
  26.                
  27.             }
  28.             else if(Container.Position.x<0)
  29.             {
  30.                 Container.Position.x = 0;
  31.             }
  32.  
  33.             else
  34.             {
  35.                 Container.Position.x = Container.Position.x;
  36.             }
  37.  
  38.             if (Container.Position.y > bounds)
  39.             {
  40.                 Container.Position.y = bounds;
  41.             }
  42.  
  43.             else if(Container.Position.y<0)
  44.             {
  45.                 Container.Position.y = 0;
  46.             }
  47.  
  48.             else
  49.             {
  50.                 Container.Position.y = Container.Position.y;
  51.             }
  52.  
  53.            
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement