how to (stick man)

edited January 2018 in How To...

You need to make your stickman move back and forth across your screen except he never goes off the screen. Make him move to and from 100 pixels from each side of your screen. To do this, you will need to draw him based on an x value, rather than at a constant location. You will need to add another boolean variable, movingLeft, that is set to false in setup. You will also need to check the following in your code:

Coding your Program:

  1. Initialize his x location in setup.
  2. If movingLeft is true, you will decrement your man’s x value in draw (He is moving left.) else, you will increment your man’s value in draw. (He is moving right.)
  3. If your stickman has an x value of 100 or less, you will change movingLeft to false in draw.
  4. If your stickman has an x value within 100 of the width, you will change movingLeft to true in draw.

Answers

Sign In or Register to comment.