Skip to content

mizquierdo97/Particle-System-by-ElliotJB

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Particle System

INTRODUCTION

Particle:

In the physical sciences, a particle is a small localized object to which can be ascribed several physical or chemical properties such as volume or mass. A particle can be a smoke, a spark, a drop of water, etc. Especially to give visual effects.

Particles are graphical primitives such as points, lines, your imagination:

Particle System

Particle systems are one such technique. By creating a small physics system that throws around hundreds – even thousands – of tiny little particles, awesome visual effects like smoke, fire, sparks, rocket exhaust and many more can be created. They are simple to create and really add nice visual effects to your game.

A Particle system in a graphic engine, Unity:

Atributes of Particle

To create a Particle System, it is necessary to set a series of attributes that will have each particle:

Position:

  • It is the position from where you are respawn, you can play with this value and establish an area from the center of the point and make it exit from a random place.
  • Example:

Speed:

  • The speed at which it will come out, here you can apply a force, for example: gravity or wind. This can increase realism.
  • Example Speed:

  • Example Gravity:

Color:

  • Each particle has to have a color. For greater realism, it is better to have a variety of shades of the same color.
  • Example:

Life Time:

  • It is the life time of the particle. If you play with time so that each particle has a different one, you can get more relist effects.
  • Example:

Age:

  • To understand it better, if you have a particle that has 4 phases, childhood, young, adult and old. Each phase has a different color, with this you can play and tell you that some particles start in childhood and others in the following phases, so you get a greater realism.
  • I haven't used this attribute.

Shape:

  • In my case I use squares but in other cases they can be lines, mini-balls, etc.
  • Example:

Size:

  • You can play with the size of the particles, if you use a small size you can achieve higher quality in some cases.
  • Example:

Transparency:

  • Transparency is important to bring realism to the particles. If you do not use it the player sees something strange.
  • Example Without Transparency:

  • Example With Transparency:

Age Of Empires 2

  • Example:

https://media.giphy.com/media/HJVsC0wynlEo8/giphy.gif

CODE

TODOS

We will create some particles that follow the player "Link" and the mouse, to do this follow the next TODOs:

TODO 1

Set degrade.y -> time of life First we need to know if the particle is active. If it is, we set the maximum life it can have (#define), and if it is not, we put it to death " = 0".

When you finish run the program and try to put explosions and fireworks.

TODO 2

Create a Particle Vector, use std::vector Also, create a pointer to an entity (SceneElement*) And finally a pointer to an iPoint (iPoint*)

TODO 3

Check if entity (element) is different from nullptr Then set the position of the entity and the pointer iPoint (object) to nullptr and entity pointer has created in .h //--------------------------- Otherwise, do it backwards. //element == nullptr and position = object

TODO 4

In this TODO we need open Particle.h and see the constructor Create a new Particle and pushback in vector. TIPS: Speed = fPoint(0,0) // P_Direction = P_NON

TODO 5

Here we have to Update the position. Check if the entity is diferent nullptr and set position. On the contrary, use Update_position(iPoint* pos);

TODO 6

Iterate the filled vector, First Comprovated if the particle is Dead, and then use particle[i]->Modify(); TIPS: Use number_particles!! // iPoint num_tex -> (0, n_textures)!

TODO 7

Draw particles Iterate the filled vector, Call the functioon render();

TODO 8

Uncomment

Content

In this project you can see 4 diferents methods of Particle system:

  • Follow
  • Fire
  • Explosion
  • Firework

Controls

  • With Arrows you can move "Link"
  • "F"-> Put a fire in mouse position.
  • "SPACE" -> Firework in mouse position.
  • Cick-Left -> Explision CROSS.
  • Cick-Center -> Explision CIRCLE.
  • Cick-Right -> Explision RANDOM.

Author

Name: Elliot Jimenez Bosch Email: elliot.jimenez1@gmail.com GitHub: https://github.com/elliotjb

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 72.6%
  • C++ 27.0%
  • Objective-C 0.4%