Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Block : Entity
- {
- public static readonly int BLOCK_WIDTH = 32;
- public static readonly int BLOCK_HEIGHT = 24;
- public static readonly int BLOCK_WIDTH_MARGIN = 4;
- public static readonly int BLOCK_HEIGHT_MARGIN = 4;
- public static readonly int NUM_OF_BLOCKS = 60;
- public static readonly float STARTING_BLOCK_POS_X = 10.0F;
- public static readonly float STARTING_BLOCK_POS_Y = 10.0F;
- private static Vector2 nextBlockPos = new Vector2(10.0F, 10.0F);
- private Ball ball;
- private bool deletionFlag;
- public Block(Texture2D texture, Ball ball_)
- : base(
- new Vector2(nextBlockPos.X, nextBlockPos.Y), //pos
- new Vector2(BLOCK_WIDTH, BLOCK_HEIGHT), //size
- Vector2.One, //scale
- Color.BlanchedAlmond, //colour
- texture)
- {
- //get next block position
- nextBlockPos.X += BLOCK_WIDTH + BLOCK_WIDTH_MARGIN;
- //if we are off the screen, move down a line
- if ( nextBlockPos.X > Game1.SCREEN_WIDTH )
- {
- nextBlockPos.X = STARTING_BLOCK_POS_X;
- nextBlockPos.Y += BLOCK_HEIGHT + BLOCK_HEIGHT_MARGIN;
- }
- this.ball = ball_;
- deletionFlag = false;
- }
- }
- //created in Game1.cs by
- for (int i = 0; i < Block.NUM_OF_BLOCKS; ++i)
- {
- Block b = new Block(pixelTexture, ball);
- blocks.Add(b);
- entities.Add(b);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement