示例#1
0
        public Block(World w, Texture2D tex, Vector2 size, Vector2 startPosition, int color, bool isRect)
        {
            world = w;
            if (isRect)
            {
                body = BodyFactory.CreateRectangle(world, size.X * pixelToUnit, size.Y * pixelToUnit, 1);
            }
            else
            {
                body = BodyFactory.CreateCircle(world, size.Length() / 2 * pixelToUnit, 1);
            }
            body.BodyType = BodyType.Dynamic;

            Size       = size;
            Position   = startPosition;
            texture    = tex;
            colorNum   = color;
            rectangle  = isRect;
            this.color = LevelData.GetColor(colorNum);
        }
示例#2
0
 private void DrawLevel()
 {
     foreach (Block b in blockList)
     {
         b.Draw(spriteBatch);
     }
     floor.Draw(spriteBatch);
     spriteBatch.Draw(cannonTexture, new Rectangle((int)cannonPosition.X, (int)cannonPosition.Y, cannonTexture.Width, cannonTexture.Height), new Rectangle(0, 0, cannonTexture.Width, cannonTexture.Height), Color.White, -1 * cannonAngle, new Vector2(20, 35), SpriteEffects.None, .9f);
     spriteBatch.Draw(powerBar, new Vector2(160, 370), new Rectangle(0, (powerBar.Height / 8) * (powerInt - 1), powerBar.Width, powerBar.Height / 8), Color.White);
     for (int i = 0; i < ballList.Count; i++)
     {
         spriteBatch.Draw(ballTexture, new Rectangle(25, LevelData.screenHeight - (i * 50 + 100), 30, 30), LevelData.GetColor(ballList.ElementAt(i)));
     }
     spriteBatch.DrawString(regFont, "[esc]", new Vector2(20, 10), Color.Black);
 }