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; }
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); }
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))); }
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); }
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); }
public override void resize(Dimentions newSize) { jumpForce *= newSize; base.resize(newSize); }
public override void resize(Dimentions newDim) { Dimentions scale = newDim / this.originalDimentions; tolerance *= scale.width; }
public Wall(Pair s, Pair e, Dimentions backgroundDimentions) : base(s, e, backgroundDimentions) { }
public void resize(Dimentions newSize) { scaledImage = Utilities.ScaleImage(this.originalImage, newSize); center = new Pair(scaledImage.Width / 2, scaledImage.Height / 2); }
// 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; }
protected void setCharacteristics(Pair s, Pair e, Dimentions backgroundDimentions) { this.start = this.originalStart = s; this.end = this.originalEnd = e; this.originalDimentions = backgroundDimentions; }
public Barrier(Pair s, Pair e, Dimentions backgroundDimentions) { this.setCharacteristics(s, e, backgroundDimentions); }
/// <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); }
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; } } }