Step 9: Coding the Lightsaber On (Part 3)

Goal:


Now that our program can tell whether or not our lightsaber is on, and now we have set the width of our lightsaber blade and its color, we need to tell our code exactly where to draw the lightsaber blade.

We are going to tell our code to find the center of the picture first.

Steps:

  1. From Canvas1, place a call Canvas1.DrawLine block.
  2. From Math, place a +(plus) block in the x1 slot of the DrawLine block.
  3. From Lightsaber, place a light green Lightsaber.X into the left side of the +(plus) block.
  4. From Math, place a /(divide) block into the right side of the +(plus) block.
  5. From Lightsaber, place a light green Lightsaber.Width block into the left side of the /(divide) block.
  6. From Math, place a 0(zero) block on the right side of the /(divide) block and set the number to 2.
  7. From Lightsaber, place a Lightsaber.Y into y1.

Code: