Tile.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // Tile.cs
  4. //
  5. // Microsoft XNA Community Game Platform
  6. // Copyright (C) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #endregion
  9. using System;
  10. using Microsoft.Xna.Framework;
  11. using Microsoft.Xna.Framework.Graphics;
  12. namespace Platformer
  13. {
  14. /// <summary>
  15. /// Controls the collision detection and response behavior of a tile.
  16. /// </summary>
  17. enum TileCollision
  18. {
  19. /// <summary>
  20. /// A passable tile is one which does not hinder player motion at all.
  21. /// </summary>
  22. Passable = 0,
  23. /// <summary>
  24. /// An impassable tile is one which does not allow the player to move through
  25. /// it at all. It is completely solid.
  26. /// </summary>
  27. Impassable = 1,
  28. /// <summary>
  29. /// A platform tile is one which behaves like a passable tile except when the
  30. /// player is above it. A player can jump up through a platform as well as move
  31. /// past it to the left and right, but can not fall down through the top of it.
  32. /// </summary>
  33. Platform = 2,
  34. }
  35. /// <summary>
  36. /// Stores the appearance and collision behavior of a tile.
  37. /// </summary>
  38. struct Tile
  39. {
  40. public Texture2D Texture;
  41. public TileCollision Collision;
  42. public const int Width = 40;
  43. public const int Height = 32;
  44. public static readonly Vector2 Size = new Vector2(Width, Height);
  45. /// <summary>
  46. /// Constructs a new tile.
  47. /// </summary>
  48. public Tile(Texture2D texture, TileCollision collision)
  49. {
  50. Texture = texture;
  51. Collision = collision;
  52. }
  53. }
  54. }