1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Microsoft.Xna.Framework;
  5. using Microsoft.Xna.Framework.Audio;
  6. using Microsoft.Xna.Framework.Content;
  7. using Microsoft.Xna.Framework.GamerServices;
  8. using Microsoft.Xna.Framework.Graphics;
  9. using Microsoft.Xna.Framework.Input;
  10. using Microsoft.Xna.Framework.Media;
  11. using Microsoft.Xna.Framework.Net;
  12. using Microsoft.Xna.Framework.Storage;
  13.  
  14. using ProjectMercury;
  15. using ProjectMercury.Emitters;
  16. using ProjectMercury.Modifiers;
  17. using ProjectMercury.Renderers;
  18.  
  19.  
  20. namespace MercureyTest
  21. {
  22. /// <summary>
  23. /// This is the main type for your game
  24. /// </summary>
  25. public class Game1 : Microsoft.Xna.Framework.Game
  26. {
  27. GraphicsDeviceManager graphics;
  28. SpriteBatch spriteBatch;
  29.  
  30. ParticleEffect particleEffect;
  31. Renderer particleRenderer;
  32.  
  33. public Game1()
  34. {
  35. graphics = new GraphicsDeviceManager(this);
  36. Content.RootDirectory = "Content";
  37. }
  38.  
  39. /// <summary>
  40. /// Allows the game to perform any initialization it needs to before starting to run.
  41. /// This is where it can query for any required services and load any non-graphic
  42. /// related content. Calling base.Initialize will enumerate through any components
  43. /// and initialize them as well.
  44. /// </summary>
  45. protected override void Initialize()
  46. {
  47. // TODO: Add your initialization logic here
  48. particleEffect.Initialise();
  49. base.Initialize();
  50. }
  51.  
  52. /// <summary>
  53. /// LoadContent will be called once per game and is the place to load
  54. /// all of your content.
  55. /// </summary>
  56. protected override void LoadContent()
  57. {
  58. // Create a new SpriteBatch, which can be used to draw textures.
  59. spriteBatch = new SpriteBatch(GraphicsDevice);
  60.  
  61. particleRenderer = new SpriteBatchRenderer { GraphicsDeviceService = graphics };
  62.  
  63. particleEffect = Content.Load<ParticleEffect>("little_flame");
  64. particleEffect.LoadContent(Content);
  65. particleRenderer.LoadContent(Content);
  66.  
  67.  
  68. // TODO: use this.Content to load your game content here
  69. }
  70.  
  71. /// <summary>
  72. /// UnloadContent will be called once per game and is the place to unload
  73. /// all content.
  74. /// </summary>
  75. protected override void UnloadContent()
  76. {
  77. // TODO: Unload any non ContentManager content here
  78. }
  79.  
  80. /// <summary>
  81. /// Allows the game to run logic such as updating the world,
  82. /// checking for collisions, gathering input, and playing audio.
  83. /// </summary>
  84. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  85. protected override void Update(GameTime gameTime)
  86. {
  87. // Allows the game to exit
  88. if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
  89. this.Exit();
  90.  
  91. particleEffect.Trigger(new Vector2(100, 100));
  92. particleEffect.Update((float)gameTime.ElapsedGameTime.TotalSeconds);
  93.  
  94. // TODO: Add your update logic here
  95.  
  96. base.Update(gameTime);
  97. }
  98.  
  99. /// <summary>
  100. /// This is called when the game should draw itself.
  101. /// </summary>
  102. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  103. protected override void Draw(GameTime gameTime)
  104. {
  105. GraphicsDevice.Clear(Color.CornflowerBlue);
  106.  
  107. // TODO: Add your drawing code here
  108. particleRenderer.RenderEffect(particleEffect);
  109.  
  110. base.Draw(gameTime);
  111. }
  112. }
  113. }
  114.