Example #1
0
        ////
        //METHODS
        ////

        private void spawnBullet(Color cColor)
        {
            //reset timer
            bulletspawntimer = 0;
            //direction, distance from center init
            linedirection = (linedirection + 1) % numlindirs;
            float spawnradius = (float)Math.Sqrt(Math.Pow(gamearea.Right - gamearea.Center.X, 2) + Math.Pow(gamearea.Bottom - gamearea.Center.Y, 2));
            //
            double anglevariant = (rand.NextDouble() - 0.5) * Math.PI / 2;
            //Create and init bullets
            GRBullet abullet = new GRBullet();

            abullet.setTex(waveTex);
            abullet.position   = Vector2.Zero;
            abullet.position.X = gamearea.Center.X + spawnradius * (float)Math.Cos(2 * Math.PI / numlindirs * linedirection);
            abullet.position.Y = gamearea.Center.Y + spawnradius * (float)Math.Sin(2 * Math.PI / numlindirs * linedirection);
            abullet.velocity   = Vector2.Zero;
            abullet.velocity.X = -GRWave.BULLETSPEED * (float)Math.Cos(2 * Math.PI / numlindirs * linedirection);
            abullet.velocity.Y = -GRWave.BULLETSPEED * (float)Math.Sin(2 * Math.PI / numlindirs * linedirection);
            abullet.rotation   = (float)rand.NextDouble();
            abullet.rotation   = (abullet.rotation - 0.5f) * maxbulletspin;
            abullet.color      = cColor;
            abullet.fading     = true;

            bullets.Add(abullet);
        }
Example #2
0
        ////
        //METHODS
        ////

        private void spawnBullet(Color cColor)
        {
            //reset timer
            bulletspawntimer = 0;
            //direction, distance from center init
            linedirection = (linedirection + 1) % numlindirs;
            float spawnradius = (float)Math.Sqrt(Math.Pow(gamearea.Right - gamearea.Center.X, 2) + Math.Pow(gamearea.Bottom - gamearea.Center.Y, 2));
            //
            //Create and init bullets
            GRBullet abullet = new GRBullet();

            abullet.setTex(waveTex);
            abullet.position   = Vector2.Zero;
            abullet.position.X = gamearea.Center.X + spawnradius * (float)Math.Cos(2 * Math.PI / numlindirs * linedirection);
            abullet.position.Y = gamearea.Center.Y + spawnradius * (float)Math.Sin(2 * Math.PI / numlindirs * linedirection);
            abullet.velocity   = Vector2.Zero;
            abullet.velocity.X = -GRWave.BULLETSPEED * (float)Math.Cos(2 * Math.PI / numlindirs * linedirection);
            abullet.velocity.Y = -GRWave.BULLETSPEED * (float)Math.Sin(2 * Math.PI / numlindirs * linedirection);
            abullet.angle      = (float)Math.Atan2(player.position.Y - abullet.position.Y, player.position.X - abullet.position.X);
            //
            abullet.color  = cColor;
            abullet.fading = true;

            bullets.Add(abullet);
        }
Example #3
0
        ////
        //METHODS
        ////

        private void spawnburst(Color cColor)
        {
            bulletspawntimer = 0;
            //
            extrabullettoggle = -extrabullettoggle;
            bulletsperburst  += extrabullettoggle;
            //
            for (int burstind = 0; burstind < numspirals; burstind++)
            {
                ArrayList cspiral = (ArrayList)spirals[burstind];
                for (int index = 0; index < bulletsperburst; index++)
                {
                    GRBullet abullet = new GRBullet();

                    abullet.setTex(waveTex);
                    abullet.position    = new Vector2(spiralcenter[burstind].X - waveTex.Width / 2, spiralcenter[burstind].Y - waveTex.Height / 2);
                    abullet.spiraltheta = 2 * (float)Math.PI / bulletsperburst * index;

                    abullet.rotation = bulletspin;
                    abullet.color    = cColor;
                    abullet.fading   = true;
                    //add bullet both to its spiral(for updates) and the masterlist(for rendering)
                    cspiral.Add(abullet);
                    bullets.Add(abullet);
                }
                //spirals.Add(cBurst);
            }
        }
Example #4
0
        public GRWaveBounce(int wavenum, Rectangle gamearea, Texture2D waveTex, Color cColor)
        {
            this.wavetime = 0;
            this.wavenum  = wavenum;
            this.gamearea = gamearea;
            this.waveTex  = waveTex;
            bullets       = new ArrayList();
            Random rand = new Random();

            //Init number of bullets
            int numbullets = wavenum + 2;

            if (numbullets > maxbullets)
            {
                numbullets = maxbullets;
            }

            //Create and init bullets
            for (int index = 0; index < numbullets; index++)
            {
                GRBullet abullet = new GRBullet();

                abullet.setTex(waveTex);
                abullet.position = new Vector2(
                    rand.Next(gamearea.Left + abullet.sprTx.Width / 2, gamearea.Right - abullet.sprTx.Width / 2),
                    rand.Next(gamearea.Top + abullet.sprTx.Height / 2, gamearea.Bottom - abullet.sprTx.Height / 2));
                abullet.velocity = new Vector2(rand.Next(1, 50), rand.Next(1, 50));
                abullet.velocity.Normalize();
                abullet.velocity *= GRWave.BULLETSPEED;
                abullet.rotation  = (float)rand.NextDouble();
                abullet.rotation  = (abullet.rotation - 0.5f) * maxbulletspin;
                abullet.color     = cColor;
                abullet.fading    = true;
                abullet.opacity   = 0;

                bullets.Add(abullet);
            }
        }