예제 #1
0
        public void FireBullet(GameTime gameTime)
        {
            Bullet b = new Bullet();

            b.Position = p.playerSprite.position;
            b.Velocity = LinePrimatives.AngleToV2(MathHelper.ToDegrees(p.playerSprite.rotation), b.moveSpeed);
        }
예제 #2
0
 public override void Draw(SpriteBatch spriteBatch)
 {
     if (Collision != null)
     {
         LinePrimatives.DrawRectangle(spriteBatch, 3, Color.Red, Collision);
     }
     playerSprite.Draw(spriteBatch);
 }
        public void ShootTorpedo()
        {
            Torpedo T = new Torpedo();

            T.Position = sprite.position;
            T.Rotation = sprite.rotation;
            T.Velocity = LinePrimatives.AngleToV2(MathHelper.ToDegrees(sprite.rotation), T.MovementSpeed);
            T.owner    = this;
        }
예제 #4
0
 public override void Draw(SpriteBatch spriteBatch)
 {
     asteroidSprite.position = Position;
     if (Collision != null)
     {
         LinePrimatives.DrawRectangle(spriteBatch, 3, Color.Red, Collision);
     }
     asteroidSprite.Draw(spriteBatch);
 }
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(clearColor);

            spriteBatch.Begin();

            //theGrid.Draw(spriteBatch);


            // Draw the line as normal
            //.color = Color.Red;
            //theline.Draw(spriteBatch);

            // Now Draw to grid size

            theline.color = Color.LightBlue;
            theGrid.DrawLine(spriteBatch, theline);

            // Draw on Grid, but not scaled to grid Size

            // theline.color = Color.LightBlue;
            // theGrid.DrawLine(spriteBatch, theline);

            // Draw a line object on screen
            theGrid.DrawLineObject(spriteBatch, xMark);

            LinePrimatives.DrawCircle(spriteBatch, 10f, Color.White, theGrid.Grid2ScreenPoint(Vector2.Zero, true), 10, 12);
            LinePrimatives.DrawPoint(spriteBatch, 10f, Color.Blue, theGrid.Grid2ScreenPoint(new Vector2(3, 5), true));

            LinePrimatives.DrawPoint(spriteBatch, theGrid.ScaleGrid2Screen(2), Color.Green, theGrid.Grid2ScreenPoint(new Vector2(-10, -10), true));

            LinePrimatives.DrawCircle(spriteBatch, 3f, Color.White, theGrid.Grid2ScreenPoint(new Vector2(-5, 5), true), theGrid.ScaleGrid2Screen(2), 6);

            LinePrimatives.DrawPoint(spriteBatch, 10f, Color.Green, theGrid.Grid2ScreenPoint(LinePrimatives.CircleRadiusPoint(new Vector2(-5, 5), 0, 2)));
            LinePrimatives.DrawPoint(spriteBatch, 10f, Color.Green, theGrid.Grid2ScreenPoint(LinePrimatives.CircleRadiusPoint(new Vector2(-5, 5), 60, 2)));
            LinePrimatives.DrawPoint(spriteBatch, 10f, Color.Green, theGrid.Grid2ScreenPoint(LinePrimatives.CircleRadiusPoint(new Vector2(-5, 5), 120, 2)));
            LinePrimatives.DrawPoint(spriteBatch, 10f, Color.Green, theGrid.Grid2ScreenPoint(LinePrimatives.CircleRadiusPoint(new Vector2(-5, 5), 180, 2)));
            LinePrimatives.DrawPoint(spriteBatch, 10f, Color.Green, theGrid.Grid2ScreenPoint(LinePrimatives.CircleRadiusPoint(new Vector2(-5, 5), 240, 2)));
            LinePrimatives.DrawPoint(spriteBatch, 10f, Color.Green, theGrid.Grid2ScreenPoint(LinePrimatives.CircleRadiusPoint(new Vector2(-5, 5), 300, 2)));
            //LinePrimatives.CircleRadiusPoint(theGrid.Grid2ScreenPoint(new Vector2(-5, 5), true), -60, 40);

            Vector2 Pos = LinePrimatives.CircleRadiusPoint(new Vector2(graphics.PreferredBackBufferWidth / 2f, graphics.PreferredBackBufferHeight / 2f), offset / 120, theGrid.GridSize * 7.5f);

            LinePrimatives.DrawPoint(spriteBatch, theGrid.ScaleGrid2Screen(2), Color.Wheat, Pos);



            theGrid.Draw(spriteBatch);

            spriteBatch.End();

            base.Draw(gameTime);
        }
        public override void InitalizeObject()
        {
            sprite          = new Sprite("Torp");
            sprite.scale    = .15f;
            sprite.origin.X = sprite.texture.Width / 2;
            sprite.origin.Y = sprite.texture.Height / 2;

            MovementSpeed = 70f;

            Velocity = LinePrimatives.AngleToV2(Rotation, MovementSpeed);

            Collison = new Rectangle(0, 0, (int)(sprite.texture.Width * sprite.scale), (int)(sprite.texture.Height * sprite.scale));
        }
        public virtual void Draw(SpriteBatch spriteBatch)
        {
            if (sprite != null)
            {
                sprite.position = Position;
                sprite.rotation = Rotation;
                sprite.Draw(spriteBatch);
            }

            // Debug
            if (Collison != null)
            {
                LinePrimatives.DrawRectangle(spriteBatch, 5, Color.Red, Collison);
            }
        }
예제 #8
0
        public override void InitalizeObject()
        {
            playerSprite          = new Sprite("Cursor");
            playerSprite.scale    = .025f;
            playerSprite.position = (ScreenSize / 2);
            playerSprite.origin.X = playerSprite.texture.Width / 2;
            playerSprite.origin.Y = playerSprite.texture.Height / 2;

            // Set this a object creation
            //Position = center;

            moveSpeed = 50;

            Velocity = LinePrimatives.AngleToV2(Rotation, moveSpeed);

            //Velocity.X = moveSpeed;
            //Velocity.Y = moveSpeed;


            Collision = new Rectangle(0, 0, (int)(playerSprite.texture.Width * playerSprite.scale), (int)(playerSprite.texture.Height * playerSprite.scale));
        }
예제 #9
0
        public override void InitalizeObject()
        {
            // set these in child classes...
            bulletSprite          = new Sprite("heart");
            bulletSprite.scale    = .025f;
            bulletSprite.origin.X = bulletSprite.texture.Width / 2;
            bulletSprite.origin.Y = bulletSprite.texture.Height / 2;

            // Set this a object creation
            //Position = center;

            moveSpeed = 50;

            Velocity = LinePrimatives.AngleToV2(Rotation, moveSpeed);

            //Velocity.X = moveSpeed;
            //Velocity.Y = moveSpeed;


            Collision = new Rectangle(0, 0, (int)(bulletSprite.texture.Width * bulletSprite.scale), (int)(bulletSprite.texture.Height * bulletSprite.scale));
        }
예제 #10
0
        public virtual void Thrust()
        {
            Vector2 newThrust = LinePrimatives.AngleToV2(RotationInDegrees, ThrustValue);

            Velocity += newThrust;
        }
        public void Draw(SpriteBatch sb)
        {
            int     index         = 0;
            Vector2 PositivePoint = Vector2.Zero;
            Vector2 NegativePoint = Vector2.Zero;
            Color   drawColor     = LineColor;
            float   drawWidth     = LineWidth;
            bool    StillDrawing  = true;
            bool    MustDraw      = true;

            if (isDrawingOrigin)
            {
                LinePrimatives.DrawSolidCircle(sb, AxisColor, Origin, GridSize / 2);
            }

            while (StillDrawing)
            {
                // Is this an Axis...
                if ((index == 0) && IsDrawingAxis)
                {
                    drawColor = AxisColor;
                    drawWidth = AxisWidth;
                    MustDraw  = true;
                }
                // Is this a Division Line
                else if (((index % DivisionCount) == 0) && isDrawingDivsions)
                {
                    drawColor = DivisionColor;
                    drawWidth = DivisionWidth;
                    MustDraw  = true;
                }
                // Or is this just every other line
                else
                {
                    drawColor = LineColor;
                    drawWidth = LineWidth;
                    MustDraw  = false;
                }

                if (!isDrawingLines && !MustDraw)
                {
                }
                else
                {
                    _GridScale    = new Vector2(GridSize, GridSize);
                    PositivePoint = Origin + (_GridScale * index);
                    NegativePoint = Origin - (_GridScale * index);

                    LineDrawer.DrawLine(sb, drawWidth, drawColor, new Vector2(0, PositivePoint.Y), new Vector2(ScreenSize.X, PositivePoint.Y));
                    LineDrawer.DrawLine(sb, drawWidth, drawColor, new Vector2(PositivePoint.X, 0), new Vector2(PositivePoint.X, ScreenSize.Y));

                    LineDrawer.DrawLine(sb, drawWidth, drawColor, new Vector2(0, NegativePoint.Y), new Vector2(ScreenSize.X, NegativePoint.Y));
                    LineDrawer.DrawLine(sb, drawWidth, drawColor, new Vector2(NegativePoint.X, 0), new Vector2(NegativePoint.X, ScreenSize.Y));
                }

                index++;

                if ((PositivePoint.X > ScreenSize.X) && (PositivePoint.Y < 0) &&
                    (NegativePoint.X < 0) && (NegativePoint.Y > ScreenSize.Y))
                {
                    StillDrawing = false;
                }


                if (index > ScreenSize.X / GridSize)
                {
                    StillDrawing = false;
                }
            }
        }