Art.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //---------------------------------------------------------------------------------
  2. // Ported to the Atomic Game Engine
  3. // Originally written for XNA by Michael Hoffman
  4. // Find the full tutorial at: http://gamedev.tutsplus.com/series/vector-shooter-xna/
  5. //----------------------------------------------------------------------------------
  6. using AtomicEngine;
  7. namespace AtomicBlaster
  8. {
  9. public class CustomSprite
  10. {
  11. public CustomSprite(Sprite2D sprite)
  12. {
  13. var rect = new Rect();
  14. sprite.GetTextureRectangle(ref rect);
  15. TexCoordTL = rect.Min;
  16. TexCoordBR = rect.Max;
  17. Height = (int) (rect.Height * 128);
  18. Width = (int) (rect.Width * 128);
  19. Texture = sprite.Texture;
  20. }
  21. public int Height;
  22. public int Width;
  23. public Vector2 TexCoordTL;
  24. public Vector2 TexCoordBR;
  25. public Texture2D Texture;
  26. }
  27. static class Art
  28. {
  29. public static CustomSprite Player { get; private set; }
  30. public static CustomSprite Seeker { get; private set; }
  31. public static CustomSprite Wanderer { get; private set; }
  32. public static CustomSprite Bullet { get; private set; }
  33. public static CustomSprite Pointer { get; private set; }
  34. public static CustomSprite BlackHole { get; private set; }
  35. public static CustomSprite LineParticle { get; private set; }
  36. public static CustomSprite Glow { get; private set; }
  37. public static CustomSprite Pixel { get; private set; } // a single white pixel
  38. public static void Load()
  39. {
  40. var cache = AtomicNET.GetSubsystem<ResourceCache>();
  41. SpriteSheet2D sheet = cache.GetResource<SpriteSheet2D>("Sprites/AtomicBlasterSprites.xml");
  42. Player = new CustomSprite(sheet.GetSprite("Player"));
  43. Seeker = new CustomSprite(sheet.GetSprite("Seeker"));
  44. Wanderer = new CustomSprite(sheet.GetSprite("Wanderer"));
  45. Bullet = new CustomSprite(sheet.GetSprite("Bullet"));
  46. Pointer = new CustomSprite(sheet.GetSprite("Pointer"));
  47. BlackHole = new CustomSprite(sheet.GetSprite("BlackHole"));
  48. LineParticle = new CustomSprite(sheet.GetSprite("Laser"));
  49. Glow = new CustomSprite(sheet.GetSprite("Glow"));
  50. Pixel = new CustomSprite(sheet.GetSprite("Pixel"));
  51. }
  52. }
  53. }