Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.69 KB | None | 0 0
  1.     public class Block : Entity
  2.     {
  3.         public static readonly int BLOCK_WIDTH = 32;
  4.         public static readonly int BLOCK_HEIGHT = 24;
  5.         public static readonly int BLOCK_WIDTH_MARGIN = 4;
  6.         public static readonly int BLOCK_HEIGHT_MARGIN = 4;
  7.         public static readonly int NUM_OF_BLOCKS = 60;
  8.         public static readonly float STARTING_BLOCK_POS_X = 10.0F;
  9.         public static readonly float STARTING_BLOCK_POS_Y = 10.0F;
  10.         private static Vector2 nextBlockPos = new Vector2(10.0F, 10.0F);
  11.  
  12.  
  13.         private Ball ball;
  14.  
  15.         private bool deletionFlag;
  16.  
  17.         public Block(Texture2D texture, Ball ball_)
  18.             : base(
  19.                 new Vector2(nextBlockPos.X, nextBlockPos.Y),    //pos
  20.                 new Vector2(BLOCK_WIDTH, BLOCK_HEIGHT),         //size
  21.                 Vector2.One,                                    //scale
  22.                 Color.BlanchedAlmond,                           //colour
  23.                 texture)
  24.         {
  25.             //get next block position
  26.             nextBlockPos.X += BLOCK_WIDTH + BLOCK_WIDTH_MARGIN;
  27.            
  28.             //if we are off the screen, move down a line
  29.             if ( nextBlockPos.X > Game1.SCREEN_WIDTH )
  30.             {
  31.                 nextBlockPos.X = STARTING_BLOCK_POS_X;
  32.                 nextBlockPos.Y += BLOCK_HEIGHT + BLOCK_HEIGHT_MARGIN;
  33.             }
  34.  
  35.  
  36.             this.ball = ball_;
  37.             deletionFlag = false;
  38.         }
  39.     }
  40.  
  41.  
  42. //created in Game1.cs by
  43.             for (int i = 0; i < Block.NUM_OF_BLOCKS; ++i)
  44.             {
  45.                 Block b = new Block(pixelTexture, ball);
  46.                 blocks.Add(b);
  47.                 entities.Add(b);
  48.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement