Skip to content

Instantly share code, notes, and snippets.

@amulware amulware/00-simple-particle.cs Secret
Last active Aug 29, 2015

Embed
What would you like to do?
Snippets for GameDev<T> post on parametric particles
class Particle
{
Vector3 position;
Vector3 velocity;
public Particle(Vector3 position, Vector3 velocity)
{
this.position = position;
this.velocity = velocity;
}
void Update(float timeStep)
{
// piece-wise integrate velocity
this.position += this.velocity * timeStep;
}
void Draw()
{
// draw at this.position
}
}
class Particle
{
Vector3 startPosition;
Vector3 velocity;
public Particle(Vector3 startPosition, Vector3 velocity)
{
this.startPosition = startPosition;
this.velocity = velocity;
}
void Draw(float timeAlive)
{
var p = this.startPosition + this.velocity * timeAlive
// draw at p
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.