This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private VertexPositionColorTextured[] _vertices = new VertexPositionColorTextured[4 * 1000]; | |
private short[] _indices = new short[6 * 1000]; | |
public virtual void Draw(Time gameTime, Drawing drawing) | |
{ | |
int pc = particles.Count; | |
if (_vertices.Length < (4 * pc) || _indices.Length < (6 * pc)) | |
{ | |
_vertices = new VertexPositionColorTextured[4 * pc]; | |
_indices = new short[6 * pc]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TextureAtlas | |
// This will use a texture having 5 columns | |
// and 1 rows. And makes a sprite for frame 1 | |
// (yeah, it's the second frame :) | |
atlas = new TextureAtlas( | |
StateManager.Content.Load<Texture2D>( | |
"Images/joukahainen"), 5, 1); | |
atlasSprite = atlas.MakeSprite(1); | |
atlasSprite.Position = new Vector2(42f, 42f); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Invoke new particles from the effect for 1 seconds if mouse right is pressed | |
if (StateManager.Input.IsMouseButtonPressed(SmithNgine.Input.MouseButton.Right)) | |
{ | |
particleEffect.Generate(TimeSpan.FromSeconds(1.0f)); | |
} | |
// OR... Generate 10 new particles on each frame whenever Right mouse button is held down | |
if (StateManager.Input.IsMouseButtonPressed(SmithNgine.Input.MouseButton.Right)) | |
{ | |
particleEffect.AddParticles( emitter.Generate(10) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LineEmitter : ParticleEmitter | |
{ | |
private Vector2 startVector; | |
private Vector2 endVector; | |
public LineEmitter(Vector2 lineStart, Vector2 lineEnd) | |
: base(lineStart) | |
{ | |
startVector = lineStart; | |
endVector = lineEnd; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a new particle system | |
particleSystem = new ParticleSystem(); | |
// Create a new particle Effect | |
particleEffect = new ParticleEffect(); | |
particleEffect.GravityVector = new Vector2(0.0f, 0.04f); | |
// Create new emitter for the Effect, with 2 textures that are randomly used in generation | |
emitter = new PointEmitter(animSprite.Position); | |
emitter.AddTexture(StateManager.Content.Load<Texture2D>("Images/flower")); |