Exemplo n.º 1
0
        public Sprite(string spriteImage, int posX, int posY, int sirina, int visina, string name)//moj novi kontruktor,razlika je samo sta postavimo sami sirinu i visinu,te prima ime spritea
        {
            CurrentCostume = new Bitmap(spriteImage);
            Kopija         = new Bitmap(spriteImage);

            h2 = Kopija.Height / 2;
            w2 = Kopija.Width / 2;

            CostumeName = spriteImage;
            X           = posX;
            Y           = posY;
            Width       = sirina; //1.promjena
            Heigth      = visina; //2.promjena
            Show        = true;
            SpriteIndex = -1;
            Costumes.Add(new Bitmap(spriteImage));
            CostumeIndex   = 0;
            RotationStyle  = RotationStylesType.DontRotate.ToString();
            Direction      = 0;
            Size           = 100;
            originalWidth  = width;
            originalHeigth = heigth;

            //3.promjena   IME MOZE BITI SAMO KARTA ILI POZADINA,SLUZI DA NE IZBRISEMO SPRITE KOJI JE POZADINA IZ IGRE
            if (name.ToLower().Trim() == "card" || name.ToLower().Trim() == "karta")
            {
                Name = "card";
            }
            else
            {
                Name = "pozadina";
            }

            //nova rotacija, predviđeno 36 sličica
            int numOfRotations = 36;

            if (numOfRotations > 360)
            {
                numOfRotations %= 360;
            }
            if (numOfRotations < 1)
            {
                numOfRotations = 1;
            }
            Rotations = new List <SpriteCostume>();

            Bitmap original = new Bitmap(spriteImage);

            int ang = 360 / numOfRotations;

            for (int i = 0; i < numOfRotations; i++)
            {
                PointF        offset = new PointF(this.Width / 2, this.Heigth / 2);
                Bitmap        b      = RotateImage(original, offset, ang * i);
                SpriteCostume s      = new SpriteCostume(b, i * ang);
                Rotations.Add(s);
            }
        }
Exemplo n.º 2
0
        public Sprite(string spriteImage, int posX, int posY, int sirina, int visina, string name)//moj novi kontruktor,razlika je samo sta postavimo sami sirinu i visinu,te prima ime spritea
        {
            CurrentCostume = new Bitmap(spriteImage);
            Kopija         = new Bitmap(spriteImage);

            h2 = Kopija.Height / 2;
            w2 = Kopija.Width / 2;

            CostumeName = spriteImage;
            X           = posX;
            Y           = posY;
            Width       = sirina;
            Heigth      = visina;
            Show        = true;
            SpriteIndex = -1;
            Costumes.Add(new Bitmap(spriteImage));
            CostumeIndex   = 0;
            RotationStyle  = RotationStylesType.DontRotate.ToString();
            Direction      = 0;
            Size           = 100;
            originalWidth  = width;
            originalHeigth = heigth;


            if (name.ToLower().Trim() == "card" || name.ToLower().Trim() == "karta")
            {
                Name = "card";
            }
            else
            {
                Name = "pozadina";
            }


            int numOfRotations = 36;

            if (numOfRotations > 360)
            {
                numOfRotations %= 360;
            }
            if (numOfRotations < 1)
            {
                numOfRotations = 1;
            }
            Rotations = new List <SpriteCostume>();

            Bitmap original = new Bitmap(spriteImage);

            int ang = 360 / numOfRotations;

            for (int i = 0; i < numOfRotations; i++)
            {
                PointF        offset = new PointF(this.Width / 2, this.Heigth / 2);
                Bitmap        b      = RotateImage(original, offset, ang * i);
                SpriteCostume s      = new SpriteCostume(b, i * ang);
                Rotations.Add(s);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Konstruktor za Sprite.
        /// </summary>
        /// <param name="spriteImage">naziv/putanja slike</param>
        /// <param name="posX">x koordinata lika</param>
        /// <param name="posY">y koordinata lika</param>
        /// <remarks>Sprite se može instancirati i uz pomoć metode NewSprite koja se nalazi u klasi Game: <see cref="Game.NewSprite"/>.</remarks>
        public Sprite(string spriteImage, int posX, int posY)
        {
            CurrentCostume = new Bitmap(spriteImage);
            Kopija         = new Bitmap(spriteImage);

            h2 = Kopija.Height / 2;
            w2 = Kopija.Width / 2;

            CostumeName = spriteImage;
            X           = posX;
            Y           = posY;
            Width       = CurrentCostume.Width;
            Heigth      = CurrentCostume.Height;
            Show        = true;
            SpriteIndex = -1;
            Costumes.Add(new Bitmap(spriteImage));
            CostumeIndex   = 0;
            RotationStyle  = RotationStylesType.DontRotate.ToString();
            Direction      = 0;
            Size           = 100;
            originalWidth  = width;
            originalHeigth = heigth;

            //nova rotacija, predviđeno 36 sličica
            int numOfRotations = 36;

            if (numOfRotations > 360)
            {
                numOfRotations %= 360;
            }
            if (numOfRotations < 1)
            {
                numOfRotations = 1;
            }
            Rotations = new List <SpriteCostume>();

            Bitmap original = new Bitmap(spriteImage);

            int ang = 360 / numOfRotations;

            for (int i = 0; i < numOfRotations; i++)
            {
                //PointF offset = new PointF(this.Width / 2, this.Heigth / 2);
                PointF        offset = new PointF(originalWidth / 2, originalWidth / 2);
                Bitmap        b      = RotateImage(original, offset, ang * i);
                SpriteCostume s      = new SpriteCostume(b, i * ang);
                Rotations.Add(s);
            }
        }