コード例 #1
0
        void SpawnSingleObject(FO flyingObject, Image imgForSprite, string pictureBoxName)
        {
            var size = new Size((int)flyingObject.Width, (int)flyingObject.Hight);

            AssignValues(flyingObject.sprite, (int)flyingObject.x, (int)flyingObject.y, size, imgForSprite, pictureBoxName);
            flyingObject.sprite.BringToFront();
            Controls.Add(flyingObject.sprite);
        }
コード例 #2
0
        private void RenderSingleBullet(FO bullet, Image bulletImage)
        {
            switch (bullet.sprite.Name)
            {
            //bullet tylko raz bedzie wolany na ekran, pozniej tylko przesuwany
            case "toDraw":
                SpawnSingleObject(bullet, bulletImage, "alive");
                break;

            case "alive":
                SetSpritePosition(bullet.sprite, (int)bullet.x, (int)bullet.y);
                break;
            }
        }
コード例 #3
0
        public Shield(float x, float y, float width, float hight) : base(x, y, width, hight)
        {
            // this.width = width;
            float elementsWidth = width / cols;
            float elementsHight = hight / rows;

            this.x   = x;
            this.y   = y;
            elements = new FO[cols, rows];
            for (int i = 0; i < rows; ++i)
            {
                for (int j = 0; j < cols; ++j)
                {
                    elements[j, i] = new FO(x + j + elementsWidth * (j - 7), y + i + elementsHight * (i - 7), elementsWidth, elementsHight);
                    //for 11x13
                    if (j + rows - i < 3)
                    {
                        elements[j, i].alive = false;                   //lewy góry róg.
                    }
                    if ((cols - j - 1) + rows - i < 3)
                    {
                        elements[j, i].alive = false;                                //prawy góry róg.
                    }
                    if (Math.Abs(cols / 2 - j) + (i - 1) < 5 && (i - 1) < 3 && Math.Abs(cols / 2 - j) < 5)
                    {
                        elements[j, i].alive = false;                                                                                  //srodek
                    }
                    //for 22x26

                    /*if (j + i < 4) elements[j, i].alive = false;  //lewy góry róg.
                     * if ((cols - j - 1) + i < 4) elements[j, i].alive = false;  //prawy góry róg.
                     *
                     * if (Math.Abs(cols / 2 - j) + (rows - i - 1) < 12 && (rows - i - 1) < 6 && Math.Abs(cols / 2 - j) < 10) elements[j, i].alive = false;  //srodek
                     */
                }
            }

            //destroy(10, 0);
            //print_message(); //test

            //zwiekszenie hitboxa

            this.width += elementsWidth * 3;
            this.hight += elementsHight * 3;
            //this.x -= elementsWidth*2;
            //this.y -= elementsHight*2;
        }
コード例 #4
0
 public void colisionInside(FO bullet, List <Explosion> exp, float expX, float expY)
 {
     for (int i = 0; i < rows; ++i)
     {
         for (int j = 0; j < cols; ++j)
         {
             if (bullet.colisionWith(elements[j, i]))
             {
                 destroy(j, i);
                 bullet.alive = false;
                 Form1.Self.Controls.Remove(bullet.sprite);
                 ToUpdate = true;
                 Explosion explosion = new Explosion(elements[j, i].x, elements[j, i].y, expX * 2, expY * 2);
                 explosion.sprite.Name = "toDraw";
                 exp.Add(explosion);
                 //print_message();
             }
         }
     }
     //MessageBox.Show("col");
 }
コード例 #5
0
        public bool colisionWith(FO fo)
        {
            if (!alive || !fo.alive)
            {
                return(false);                     //martwi nie koliduja
            }
            float fooTop    = fo.y + fo.width / 2;
            float fooBottom = fo.y - fo.width / 2;
            float myTop     = y + width / 2;
            float myBottom  = y - width / 2;

            float fooLeft  = fo.x + fo.width / 2;
            float fooRight = fo.x - fo.width / 2;
            float myLeft   = x + width / 2;
            float myRight  = x - width / 2;

            if (fooBottom < myTop && fooTop > myBottom &&
                fooRight < myLeft && fooLeft > myRight)
            {
                return(true);
            }
            return(false);
        }