I am wanting to write small Particle and ParticleEmitter Classes for a HTML5 Canvas Game (Though, just discussing it in pseudo code is fine)

I am not great, at all, at Physics, and I don't want to use any 3rd party scripts/libraries to do this for me. Is there a simple way to do this? The Game is a top-down 2D Game and here is the sort of thing I'm wanting to achieve:

The Particle is the black ball, and I want it to accelerate up and move to the left until it reaches a specified amount of pixels above the origin, stop, and then accelerate down until it stops and disappears completely

Any help would be appreciated, I've been searching for a while now and cannot find anything on this.

Thanks

EDIT: I have implemented a quick mock-up in my game and it works well, but I was just wondering if there was any better, more efficient way to do it (Just because I don't know if this is the proper way, it does not affect performance)

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

2

Are you wanting gravity? or deflection off of a plane? Your image implies deflection which can be as simple as switching the vertical velocity to as advanced as using the plane normal to determine the new direction. I think your best bet would be to study up on some physics for game and simulation programming.
–
UnderscoreZeroApr 24 '13 at 19:44

@UnderscoreZero Gravity would help in the velocity sense, but I do not want deflection. Once a Particle has run it's course as shown in the picture, it shall just be removed from the emitter.
–
Thomas MoseyApr 24 '13 at 19:56

By way of inspiration, you could consider Googling "Feynman diagrams". Not strictly relevant to your current proposal, but possibly of interest in terms of seeing how physicists have learned to visualize quantum-mechanical interactions.
–
Pieter GeerkensApr 24 '13 at 22:09

@PieterGeerkens Thank you for directing me to this. I will read up on it over the next few days and see if it could help me out in any way.
–
Thomas MoseyApr 24 '13 at 22:28

1 Answer
1

It seems from your picture that you want the path to be straight, which is not what would happen if the ball was subject to gravity. Also from your description, it sounds like you want the ball to come to a sudden stop before accelerating downwards again.

Anyway, from what I understand of your problem, here is how I would solve it. If I have misunderstood something, I apologise.

I would store position (vector), direction (normalised vector) and speed (scalar).