Example #1
0
 public override void Update()
 {
     frame++;
     frame2++;
     if (frame == 30)
     {
         posX = (432 / 2) + (MathFunctions.Rand(0, 200) * posMod);
         posY = MathFunctions.Rand(30, 150);
         CreateLaser01(posX, posY, 6, MathFunctions.getAngleTo(new Vector2(posX, posY), new Vector2(playerX(), playerY())), 200, 10, "Red", 12, false);
         while (Loop(120))
         {
             CreateBullet01(posX, posY, 1.4f + speedMod, MathFunctions.getAngleTo(new Vector2(posX, posY), new Vector2(playerX(), playerY())) + angle + 360f / 240f, "Blue", 11, false, 4);
             angle    += 360f / 120f * angleMod;
             speedMod += 0.2f;
             if (speedMod >= 1)
             {
                 speedMod = 0;
             }
         }
         posMod   *= -1;
         angleMod *= -1;
         frame     = -20;
     }
     if (frame2 == 100)
     {
         MoveRandom(100, 50, 432 - 100, 130, 30, 50, 0.05f);
         frame2 = 0;
     }
     base.Update();
 }
Example #2
0
 public void MoveTo(float posX, float posY, int duration)
 {
     moveDistance     = MathFunctions.getDistanceTo(this.position, new Vector2(posX, posY));
     moveAcceleration = 0;
     moveSpeed        = (float)(moveDistance / duration);
     moveDuration     = duration;
     moveAngle        = MathFunctions.getAngleTo(this.position, new Vector2(posX, posY));
     movePosition     = new Vector2(posX, posY);
 }
Example #3
0
 public override void Draw(SpriteBatch sb)
 {
     if (length != maxLength)
     {
         sb.Draw(Assets.bulletSheet, position + CommonData.drawOffset, delaySprite, Color.White, 0, new Vector2(delaySprite.Width / 2, delaySprite.Height / 2), ((maxLength - length) / maxLength) * 2, SpriteEffects.None, 0);
     }
     drawAngle = MathHelper.ToRadians(drawAngle = MathFunctions.getAngleTo(this.position, this.position + (velocity + velocityXY)));
     sb.Draw(spriteSheet2, position + CommonData.drawOffset, sprite, Color.White, drawAngle, new Vector2(0, (sprite.Height / 2)), new Vector2(length / sprite.Width, width / sprite.Height), SpriteEffects.None, 0);
     //Draw origo for testing
     //sb.Draw(spriteSheet, test, sprite, Color.White, drawAngle, new Vector2((sprite.Width / 2), (sprite.Height / 2)), 0.5f, SpriteEffects.None, 0);
 }
Example #4
0
        /*protected override void CheckCollision(Vector2 playerPosition)
         * {
         *  Vector2 origo = position + new Vector2((float)Math.Cos(angle) * (length / 2), (float)Math.Sin(angle) * (width / 2));
         *  test = Vector2.Zero;
         *  if (MathFunctions.getDistanceTo(origo, playerPosition) <= (length/2))
         *  {
         *      float checkAngle;
         *      Vector2 checkHit;
         *      checkAngle = MathFunctions.getAngleTo(Vector2.Zero, velocity) + MathFunctions.getAngleTo(origo, playerPosition);
         *      checkHit = new Vector2((float)Math.Cos(MathHelper.ToRadians(checkAngle))*(length*0.45f),(float)Math.Sin(MathHelper.ToRadians(checkAngle))*(width*0.45f));
         *      test = origo + checkHit;
         *      //if (checkHit.Length() <= MathFunctions.getDistanceTo(origo, playerPosition))
         *      if (checkHit.Length() >= MathFunctions.getDistanceTo(origo, playerPosition))
         *      {
         *          //setAlive(false);
         *      }
         *  }
         * }
         * ^*/
        protected override void CheckCollision(PlayerCharacter player)
        {
            origo      = position + new Vector2((float)Math.Cos(angle) * (length / 2), (float)Math.Sin(angle) * (length / 2));
            checkAngle = MathHelper.ToRadians(MathFunctions.getAngleTo(origo, player.getPosition()) - MathHelper.ToDegrees(angle));
            float distance = ((width / 2) * (length / 2)) / (float)Math.Sqrt((Math.Pow((length / 2) * Math.Sin(checkAngle), 2)) + (Math.Pow((width / 2) * Math.Cos(checkAngle), 2)));

            test = origo + new Vector2((float)Math.Cos(checkAngle - angle) * distance, (float)Math.Sin(checkAngle - angle) * distance);
            if (MathFunctions.getDistanceTo(origo, player.getPosition()) <= distance && player.getAlive() == true)
            {
                setAlive(false);
                player.takeHit();
            }
        }
Example #5
0
        public void MoveTo2(float posX, float posY, float acceleration)
        {
            moveDuration = 0;
            moveSpeed    = 0;
            float tempDistance = 0;

            moveDistance     = MathFunctions.getDistanceTo(this.position, new Vector2(posX, posY));
            moveAcceleration = acceleration;
            while (tempDistance < moveDistance)
            {
                moveSpeed    += acceleration;
                tempDistance += moveSpeed;
                moveDuration += 1;
            }
            tempDistance -= moveDistance;
            moveAngle     = MathFunctions.getAngleTo(this.position, new Vector2(posX, posY));
            position     -= new Vector2((float)Math.Cos(MathHelper.ToRadians(moveAngle)) * tempDistance, (float)Math.Sin(MathHelper.ToRadians(moveAngle)) * tempDistance);
            movePosition  = new Vector2(posX, posY);
        }
Example #6
0
 protected float AngleToPlayer()
 {
     return(MathFunctions.getAngleTo(this.position, new Vector2(playerX(), playerY())));
 }
Example #7
0
        public override void Update()
        {
            frame++;
            frame2++;
            if (frame == 20)
            {
                while (Loop(10))
                {
                    CreateBulletA(position.X, position.Y, "Green", 12, false, 44);
                    SetBulletDataA(0, 2, MathFunctions.Rand(0.1f, 0.15f), 3, angle2, 0, "Green", 12, false);
                    SetBulletDataA(50, 3, -MathFunctions.Rand(0.01f, 0.015f), 1.5f, angle2, 0.3f, "Green", 12, false);
                    SetBulletDataA(150, true, 0, 0, true, 0, "Green", 12, false);
                    Shoot();
                    CreateBulletA(position.X, position.Y, "Cyan", 12, false, 44);
                    SetBulletDataA(0, 2, MathFunctions.Rand(0.1f, 0.15f), 3, -angle2, 0, "Cyan", 12, false);
                    SetBulletDataA(50, 3, -MathFunctions.Rand(0.01f, 0.015f), 1.5f, -angle2, -0.3f, "Cyan", 12, false);
                    SetBulletDataA(150, true, 0, 0, true, 0, "Green", 12, false);
                    Shoot();
                    angle2 += 360f / 10f;
                }

                angle2 += 22.12f;
                frame   = 11;
            }
            if (frame2 == 120)
            {
                while (Loop(20))
                {
                    CreateBulletA(position.X, position.Y, "Lime", 3, false, 20);
                    SetBulletDataA(0, 8, -0.1f, 1.5f, AngleToPlayer() + angle, 0, "Lime", 3, false);
                    Shoot();
                    angle += 360 / 20;
                }
                frame2 = 40;
            }
            if (frame == 30)
            {
                posX = (432 / 2) + (MathFunctions.Rand(0, 200) * posMod);
                posY = MathFunctions.Rand(30, 150);
                //CreateLaser01(posX, posY, 6, MathFunctions.getAngleTo(new Vector2(posX, posY), new Vector2(playerX(), playerY())), 200, 10, "Red", 12, false);
                while (Loop(120))
                {
                    CreateBullet01(posX, posY, 1.4f + speedMod, MathFunctions.getAngleTo(new Vector2(posX, posY), new Vector2(playerX(), playerY())) + angle + 360f / 240f, "Purple", 11, false, 4);
                    angle    += 360f / 120f * angleMod;
                    speedMod += 0.2f;
                    if (speedMod >= 1)
                    {
                        speedMod = 0;
                    }
                }
                posMod   *= -1;
                angleMod *= -1;
                frame     = -20;
                if (frame == 30)
                {
                }
            }

            if (frame2 == 600)
            {
                MoveTo2(0, 140, 0.2f);
            }
            if (frame2 == 1200)
            {
                MoveTo2(432, 140, 0.2f);
                frame2 = 0;
            }
            base.Update();
        }