My Community

Tutorial 5 Speed And Angles For Games In Javascript


  • *********
  • 469
  • Christopher Michael Ransom The 1 and only.
    • View Profile
    • Draft Utopia
    • Email
Tutorial 5 Speed And Angles For Games In Javascript
« on: September 26, 2014, 10:32:11 PM »
Today I will discuss speed and angles.

The speed can be defined as anything in pixels.

You can have a .setSpeed(10);

This means the speed was 20px in javascript.

An angle can be set at directions like 0, 90, 180, or 270.

0=North Angle
90=East Angle
180=South Angle
270=West Angle

You can adjust the angle by using the setAngle attribute.  To adjust the direction of an object just name the variable of your sprite.  If your variable sprite is a jetpack enter.

jetpack.setAngle (0);
jetpack.setSpeed (0);

I have set the jetpack angle to the north.  the jetpack.setSpeed angle lets me determine how slow or ho wfast the direction of the jetpack is.

Next time we will talk about using keyboard functions for designing a game in javascript.
My name is Chris Ransom and I am the creator of Draft Utopia.  I run the podcast, website, and forum for Draft Utopia.