Beispiel #1
0
        /* public bool Collides(clsSprite otherSprite)
        {
            // check if two sprites intersect
            if (this.position.X + this.size.X > otherSprite.position.X &&
            this.position.X < otherSprite.position.X + otherSprite.size.X &&
            this.position.Y + this.size.Y > otherSprite.position.Y &&
            this.position.Y < otherSprite.position.Y + otherSprite.size.Y)
            return true;
            else
            return false;

        }*/
        public bool CircleCollides(clsSprite otherSprite)
        {
            //  Check if two circle sprites collided
            if((Vector2.Distance(this.center, otherSprite.center) < this.radius +
            otherSprite.radius))
            return true;
            else
            return false;
        }
Beispiel #2
0
 public bool Collides(clsSprite otherSprite)
 {
     // check if two sprites intersect
     if (this.position.X + this.size.X > otherSprite.position.X &&
     this.position.X < otherSprite.position.X + otherSprite.size.X &&
     this.position.Y + this.size.Y > otherSprite.position.Y &&
     this.position.Y < otherSprite.position.Y + otherSprite.size.Y)
     return true;
     else
     return false;
 }
Beispiel #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Load files built from XACT project
            audioEngine = new AudioEngine("Content\\Lab3Sounds.xgs");
            waveBank = new WaveBank(audioEngine, "Content\\Wave Bank.xwb");
            soundBank = new SoundBank(audioEngine, "Content\\Sound Bank.xsb");
            // Load streaming wave bank
            streamingWaveBank = new WaveBank(audioEngine, "Content\\Music.xwb", 0, 4);
            // The audio engine must be updated before the streaming cue is ready
            audioEngine.Update();
            // Get cue for streaming music
            musicCue = soundBank.GetCue("Music");
            // Start the background music
            musicCue.Play();

            // Load a 2D texture sprite
            mySprite1 = new clsSprite(Content.Load<Texture2D>("ball"), new Vector2(0f, 0f), new Vector2(64f, 64f),
            graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            mySprite2 = new clsSprite(Content.Load<Texture2D>("ball"), new Vector2(218f, 118f), new Vector2(64f, 64f),
            graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            // Create a SpriteBatch to render the sprite
            spriteBatch = new SpriteBatch(graphics.GraphicsDevice);

            //load the SoundEffect resource
            soundEffect = Content.Load<SoundEffect>("chord");
            // set the velocity of the two sprites will move
            mySprite1.velocity = new Vector2(5, 5);
        }
Beispiel #4
0
 public bool CircleCollides(clsSprite otherSprite)
 {
     //  Check if two circle sprites collided
     return (Vector2.Distance(this.center, otherSprite.center) < this.radius +
     otherSprite.radius);
 }
Beispiel #5
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Load a 2D texture sprite
            mySprite1 = new clsSprite(Content.Load<Texture2D>("ball"), new Vector2(0f, 0f), new Vector2(64f, 64f),
            graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            mySprite2 = new clsSprite(Content.Load<Texture2D>("ball"), new Vector2(218f, 118f), new Vector2(64f, 64f),
            graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);

            // Create a SpriteBatch to render the sprite
            spriteBatch = new SpriteBatch(graphics.GraphicsDevice);

            // load the sound effect resource
            soundEffect = Content.Load<SoundEffect>("chord");

            // set the velocity of the two sprites will move
            mySprite1.velocity = new Vector2(5, 5);
            mySprite2.velocity = new Vector2(0, 0);
        }