Skip to content

michaelruppe/drift-car

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Drift Car

Try the car out for yourself! Control the demo with arrow keys.

A car class with somewhat realistic-looking friction mechanics.

Using the class is easy! Copy car.js into your p5 project directory and create a car in your script:

car = new Car(); // Initialises car in the middle of the canvas.
// OR
car = new Car(x, y, angle); // Initialises car with desired location, angle

you need to call the following once every loop through draw() .

car.update(); // simulates the car
car.show();   // renders the car

This class is a slight improvement on using the classic slidey-spaceship as a car vehicle. It doesn't come close to an accurate representation of vehicle steering - for one thing, the car can turn in place! While it's possible to implement a more accurate model, you lose the fun of being able to directly control angle-rate by pressing arrow keys. More accurate models of vehicle dynamics use steering angle as an input for control. Since all we have are on/off keys on a keyboard, this wouldn't be much fun to control.

About

A p5 class for a car with skidding/drifting

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published