Ejemplo n.º 1
0
 public void Draw(SpriteHook sprite, Vector2 position, SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(textures[sprite].GetTexture(), position, Color.White);
 }
Ejemplo n.º 2
0
 public void DrawCentered(SpriteHook sprite, Rectangle targetRect, SpriteBatch spriteBatch)
 {
     DrawCentered(textures[sprite].GetTexture(), targetRect, spriteBatch);
 }
Ejemplo n.º 3
0
 public void DrawScaled(SpriteHook sprite, Rectangle destination, SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(textures[sprite].GetTexture(), destination, Color.White);
 }
Ejemplo n.º 4
0
 public void DrawRotatedAndScaled(SpriteHook sprite, Rectangle destination, float rotationInRadians, SpriteBatch spriteBatch)
 {
     // Alter the destination (x, y) so that the sprite rotates about its center instead of the origin.
     int originalX = destination.X;
     int originalY = destination.Y;
     int centerX = originalX + destination.Width / 2;
     int centerY = originalY + destination.Height / 2;
     double radius = Math.Sqrt(destination.Width * destination.Width + destination.Height * destination.Height) / 2.0;
     double originalAngle = Math.Asin((centerY - originalY) / radius) - Math.PI;
     destination.X = (int)Math.Round(centerX + radius * Math.Cos(rotationInRadians + originalAngle));
     destination.Y = (int)Math.Round(centerY + radius * Math.Sin(rotationInRadians + originalAngle));
     spriteBatch.Draw(textures[sprite].GetTexture(), destination, null, Color.White, rotationInRadians, new Vector2(), SpriteEffects.None, 0);
 }
Ejemplo n.º 5
0
 public void DrawRotatedAndCentered(SpriteHook sprite, Rectangle destination, float rotationInRadians, SpriteBatch spriteBatch)
 {
     int centerX = destination.Center.X;
     int centerY = destination.Center.Y;
     int width = textures[sprite].GetTexture().Width;
     int height = textures[sprite].GetTexture().Height;
     destination.X = centerX - width / 2;
     destination.Y = centerY - height / 2;
     destination.Width = width;
     destination.Height = height;
     DrawRotatedAndScaled(sprite, destination, rotationInRadians, spriteBatch);
 }
Ejemplo n.º 6
0
 public void DrawLayer(SpriteHook sprite, Rectangle targetRect, SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(textures[sprite].GetTexture(), targetRect, targetRect, Color.White);
 }
Ejemplo n.º 7
0
 public void DrawLayer(SpriteHook sprite, SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(textures[sprite].GetTexture(), new Vector2(), Color.White);
 }