Vectors, Thrust, & Spaceships: Particles

Information
Step 1
Particles

Particles are visual effects that add emphasis to our game

Temp1567546990
Step 2
Create a new file for our particles
Temp1567548456
Step 3
Include the particle.js script
Temp1567547423
Step 4
Create a class to store your particles
Temp1567548531
Step 5
Create a constructor

We will have two main categories of properties:

Dynamic Values are different for similar particles, they control things like position and direction

Predetermined Values are identical for each of the same type of particle, they control it's appearance, deceleration/acceleration, and duration

Temp1567547909
Step 6
Add a draw method

We set up the default shape to be an ellipse, but we can change that on other particles

Temp1567548049
Step 7
Create a move method
Temp1567548125
Step 8
Create a test particle
Temp1567548249
Step 9
Move and draw the particle
Temp1567548379
Check Your Work
Step 10
You should now see the particle
Temp1567548737
Step 11
Add a specific particle type

extends gives ThrustParticle all the properties of Particle

Temp1567548939
Step 12
Constructor

super calls the constructor of Particle

Temp1567549027
Step 13
Replace particle with our new thrust particle
Temp1567549542 Temp1568150032
Planning
Step 14
Arrays

An array will let us handle all of our particles at the same time!

Temp1568150479
Step 15
An array of particles
Temp1567549934 Temp1567549945
Step 16
Remove particles who have no duration left
Temp1567553171
Check Your Work
Step 17
Your particle should now vanish after its duration is up
Temp1567553213
Step 18
Add particles when you push the pedal

Feel free to adjust the speed and/or offset the start position of the particles

Temp1567554225 Temp1567554290
Step 19
Offset
Temp1567720854
Challenge
Step 20
Customize your thrust particle
Temp1567720995
Planning
Step 21
We will be able to add more particles as we find places for them in our game:

Collisions:

Temp1567721452

Explosions:

The move function can be overwritten to make the explosion grow instead of move

Temp1567721509
Vectors, Thrust, & Spaceships: Particles Info

Account

MVCode Clubs

Created By

Missing tiny jake wheaton

Access Level

premium

For Teachers and Schools

Teach coding to your students with MVCode Teach

MVCode offers an integrated product designed to teach coding to students.

Learn more about MVCode Teach