Beispiel #1
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            niebo                = Content.Load <Texture2D>("niebo");
            rakieta              = Content.Load <Texture2D>("AnimRakiety");
            meteor               = Content.Load <Texture2D>("meteor");
            pocisk               = Content.Load <Texture2D>("pocisk2D");
            control              = Content.Load <Texture2D>("control");
            wykrytoKolizje       = Content.Load <SpriteFont>("File");
            wykrytoKolizjePocisk = Content.Load <SpriteFont>("KolizjaPocisk");
            wybuch               = Content.Load <SoundEffect>("wybuch");
            wróg      = new Meteor(meteor, 10);
            wrógDrugi = new Meteor(meteor, 20);
            gracz     = new Rakieta(rakieta, pocisk);
            wybuchRaz = wybuch.CreateInstance();
        }
Beispiel #2
0
        public bool Kolizja(Rakieta gracz)
        {
            Rectangle graczRectangle  = new Rectangle((int)gracz.GetPosition().X, (int)gracz.GetPosition().Y, (int)gracz.GetSize().X, (int)gracz.GetSize().X);
            Rectangle wrógRectangle   = new Rectangle((int)position.X, (int)position.Y, szerokośćKlatki, texture.Height);
            var       result          = Rectangle.Intersect(graczRectangle, wrógRectangle);
            Rectangle pociskRectangle = new Rectangle((int)gracz.GetPocisk().X, (int)gracz.GetPocisk().Y, 10, 5);
            var       result2         = Rectangle.Intersect(wrógRectangle, pociskRectangle);

            if (!result2.IsEmpty)
            {
                score++;
                Startuj(generujLL);
                gracz.deletePocisk();
            }
            if (result.IsEmpty)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }