Git Product home page Git Product logo

particles's People

Contributors

farbfetzen avatar

Stargazers

 avatar

Watchers

 avatar  avatar

particles's Issues

Improve emission logic

Rewrite the emission logic so that it does not need an increased update rate to produce smooth emission points. Instead update everything with 60 fps and if the emitter moves too fast, interpolate between current position and previous position.
current_position.lerp(previous_position) in this order.
The number of steps should be equal the number of particles to emit this frame. Or limit the number of interpolation steps? Or limit the distance between interpolation steps?

Don't use EventTimer as it spams the event queue unnecessarily. Instead create a Timer class that returns the number of events since the last update.

Remember to adjust also fire and bounce. And think about maybe extracting that logic to a base class.

Improve fireballs.py

  • Delete fireball if its particle list is empty after an update. Change the update order to remove dead particles as the last step. Or just cheat and set is_emitting to False if Fireball is offscreen.
  • All flame images of all fireballs should be blitted on to the same fire_surface Surface. And the fire_surface is blitted to the window only once. That means don't use the draw method of the fire emitter. That also means I don't need the fill_background argument in draw().
  • Make "number of particles" a property so the number can be correct for nested emitters.

Emitter and Particle Refactor

  • Some Particle attriutes are constant and should be defined as class variables or top level constants, e.g. x_max, x_min and y_max.
  • Make a simulation class separate from the emitter class. This way it is easier to have multiple emitters at the same time.

Blit surfaces instead of using draw.circle()

Should be faster for default and bounce because all circles are identical.

  • Use colorkey
  • Make the image a class attribute.
  • Change the position to the top left. That is important when spawning the particle and when it bounces.
  • Test if it is really faster, with lots of particles on and off screen.

Use emitter velocity to throw particles

When spawning a particle add the velocity of the emitter to the initial particle velocity. Calculate the emitter velocity from dt and the distance between previous position and current position.
Do this for default and bounce but maybe not for the fire?

initialize timer with time

Add option to initialize a Timer object with a certain amount of time, such that the first update already produces results. Maybe use self.time = delay - 0.000001 (one microsecond less than the desired delay). This way the emitter starts emitting immediately instead having to wait. This will be most noticeable for very low emission rates.

Also: reset the timer to the initial value (0 or that other one) when the emitter stops emitting. And only update the timer if the emitter is emitting.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.