Example #1
0
 public Platform(Pair s, Pair e, Dimentions backgroundDimentions, bool g, bool wr, bool cd)
 {
     this.setCharacteristics(s, e, backgroundDimentions);
     ground  = g;
     water   = wr;
     canDrop = cd;
 }
Example #2
0
        public static Dimentions calculateScale(Dimentions newDim, Dimentions oldDim)
        {
            Dimentions scale;

            scale.width  = (double)newDim / (double)oldDim;
            scale.height = (double)newDim.height / (double)oldDim.height;
            return(scale);
        }
Example #3
0
        public void resize()
        {
            float height = scaledImage.Height;

            Dimentions scale = Dimentions.calculateScale(window.getDimentions, this.getDimentions);

            scaledImage = new Bitmap(originalImage, new Size((int)(originalImage.Width * scale.width), (int)(height * scale.width)));
        }
Example #4
0
        public Animation(String characterFileName, Dimentions size, Sprite p)
        {
            player = p;
            state  = animStateEnum.IDLE_RIGHT;

            characterFileName += "/";
            images             = new List <Image> [7];

            addSprites(ref images[(int)animImageEnum.WALK_IMAGES], characterFileName + "run", size);
            addSprites(ref images[(int)animImageEnum.JUMP_IMAGES], characterFileName + "jump", size);
            addSprites(ref images[(int)animImageEnum.LAND_IMAGES], characterFileName + "land", size);
            addSprites(ref images[(int)animImageEnum.TUCK_IMAGES], characterFileName + "tuck", size);
            addSprites(ref images[(int)animImageEnum.IDLE_IMAGES], characterFileName + "idle", size);
            addSprites(ref images[(int)animImageEnum.CROUCH_IMAGES], characterFileName + "crouch", size);
            addSprites(ref images[(int)animImageEnum.DIE_IMAGES], characterFileName + "dead", size);
        }
Example #5
0
        public static Image ScaleImage(Image image, Dimentions size)
        {
            var ratioX = size.width / image.Width;
            var ratioY = size.height / image.Height;

            var ratio = ratioX < ratioY ? ratioX : ratioY;

            var newWidth  = (int)(image.Width * ratio);
            var newHeight = (int)(image.Height * ratio);

            var newImage = new Bitmap(image, new Size(newWidth, newHeight));

            using (var graphics = Graphics.FromImage(newImage))
                graphics.DrawImage(image, 0, 0, newWidth, newHeight);

            return(newImage);
        }
Example #6
0
 public override void resize(Dimentions newSize)
 {
     jumpForce *= newSize;
     base.resize(newSize);
 }
Example #7
0
        public override void resize(Dimentions newDim)
        {
            Dimentions scale = newDim / this.originalDimentions;

            tolerance *= scale.width;
        }
Example #8
0
 public Wall(Pair s, Pair e, Dimentions backgroundDimentions) : base(s, e, backgroundDimentions)
 {
 }
Example #9
0
 public void resize(Dimentions newSize)
 {
     scaledImage = Utilities.ScaleImage(this.originalImage, newSize);
     center      = new Pair(scaledImage.Width / 2, scaledImage.Height / 2);
 }
Example #10
0
 // Barriers are scaled to the dimentions of the background image.
 public virtual void resize(Dimentions newDim)
 {
     Pair scale = newDim / this.originalDimentions;
     Pair start = this.originalStart * scale;
     Pair end   = this.originalEnd * scale;
 }
Example #11
0
 protected void setCharacteristics(Pair s, Pair e, Dimentions backgroundDimentions)
 {
     this.start = this.originalStart = s;
     this.end   = this.originalEnd = e;
     this.originalDimentions = backgroundDimentions;
 }
Example #12
0
 public Barrier(Pair s, Pair e, Dimentions backgroundDimentions)
 {
     this.setCharacteristics(s, e, backgroundDimentions);
 }
Example #13
0
 /// <summary>
 /// Scale references the scale relitive to changes to the background.
 /// </summary>
 /// <param name="scale">Scale.</param>
 public void resize(Dimentions scale)
 {
     velocityMagnitude *= scale;
     bulletImage        = Utilities.ScaleImage(bulletImage, scale);
 }
Example #14
0
        protected void addSprites(ref List <Image> arrayImages, String fileNamePrefix, Dimentions size)
        {
            bool spriteFound = true;

            while (spriteFound)
            {
                //TODO: create standardized file name system and automate image import.
                String imagePath = System.IO.Directory.GetCurrentDirectory() + "/../../Images/cropped_contra_images/" + fileNamePrefix + (count + 1) + ".png";
                try
                {
                    Image image = Image.FromFile(imagePath, true);
                    image = Utilities.ScaleImage(image, size);
                    arrayImages.Add(image);
                }
                catch
                {
                    spriteFound = false;
                }
            }
        }