private Flea DropFlea()
        {
            flea   = new Image();
            random = new Random();

            int fleaLeftMargin = random.Next(0, 29) * 16;
            int fleaTopMargin  = random.Next(0, 31) * 16;

            BitmapImage bitFlea = new BitmapImage(new Uri("ms-appx:/Assets/Cenitpede Sprites to .png/Flea_A.png"));

            flea.Stretch = Stretch.None;
            flea.Source  = bitFlea;

            flea.Width               = 16;
            flea.Height              = 16;
            flea.VerticalAlignment   = VerticalAlignment.Top;
            flea.HorizontalAlignment = HorizontalAlignment.Left;
            flea.Margin              = new Thickness(fleaLeftMargin, 0, 0, 0);

            Background.Children.Add(flea);

            Flea fleaBoi = new Flea(fleaLeftMargin, fleaTopMargin, flea);

            return(fleaBoi);
        }
Example #2
0
        public static bool checkCollision(Flea flea, Image shot)
        {
            bool hit = false;

            if (shot != null)
            {
                if (shot.Margin.Left >= flea.locationX && flea.locationX <= (shot.Margin.Left + 16))
                {
                    if (shot.Margin.Top <= flea.locationY && (flea.locationY + 5) <= (shot.Margin.Top + 16))
                    {
                        //😍 Valid Code.

                        hit = true;
                    }
                }
            }
            return(hit);
        }