Guest User

Untitled

a guest
Nov 7th, 2016
93
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var scale = (float)lineHeight / sprite.Texture.Size.Y; //Set texture height to == lineHeight
  2. sprite.Scale = new Vector2f(scale, scale); //Textures must be squares, so this is fine for now
  3. var toTakeWidth = (int)Math.Round(1 / scale); //Far away objects use up more of the texture per strip drawn
  4. if(toTakeWidth == 0) { //A guard against close objects (doesnt work very well)
  5.     toTakeWidth = 1;
  6. }
  7. sprite.TextureRect = new IntRect((int)texX, 0, toTakeWidth, (int)sprite.Texture.Size.Y);
  8. sprite.Position = new Vector2f(x, drawStart);
  9. Settings.Game.Window.Draw(sprite);
RAW Paste Data