CSE 203 Closed Lab 10 Instructions

Table of Contents


1. Objectives

To learn more about sprite rotations, including other methods available for handling them.


2. Set Up

  1. Two students should work together at one workstation.
  2. In one student's account, follow the instructions given below in section 3, Method.  Remember, trading roles (driver and non-driver) for each new session is a very good idea.

3. Method

  1. Open file LOGO_Style_Sprites_W_Sound_N_Msg.kpl from the Week05 folder in the OSU folder.
  2. Find the method call "Spider.FlipVertical()" and comment that line out.  Run the program.  Notice now that the up arrow key (which causes a call to "Spider.Forward( speed )") moves the sprite forward, but that the forward part of the sprite is the back end of the spider!  The default initial forward direction of a sprite (before any call to TurnLeft or TurnRight) is down, that is to say, in the positive Y direction, or the direction labeled 0 degrees.  Now stop the running program and make sure its window is closed.
  3. Let's put that call "Spider.FlipVertical()" back in, by uncommenting it, so we don't get confused.  Now let's change the sprite property ForwardDirection of Spider by inserting the assignment statement "Spider.ForwardDirection = 45" after the call to FlipVertical().  Run the program.  Notice that the up arrow key moves the sprite forward, but that the forward part of the sprite is now, from the spider's point of view, 45 degrees to the spider's left.  If we now rotate the spider 45 degrees to the spider's right, the up arrow will now take the spider forward straight down.  The behavior of property ForwardDirection seems backwards to me, but, if we need it, we need to deal with it the way it is!  Now stop the running program and make sure its window is closed.  Feel free to comment out the change to ForwardDirection so that the changes you make in the next step are not so confusing.
  4. The ForwardDirection property affects the behavior of the following methods: Forward, Back, MoveLeft, and MoveRight.  See if you can modify this program so that the Down key causes the spider to crawl backward (Back), and that some other keys cause the spider to move left and right.  How about the F1 key for left, and F2 for right?
  5. How did that work for you?  Now change the ForwardDirection property back to 45, or to any angle you prefer, to see what happens.
  6. Use Intellisense to see if you can discover other things available for Sprite objects that might interest and/or help you.  As you do so, keep in mind that not all things in Phrogram are as advertised.  For example, I can't seem to get SetRotationOffset to work for me in a way that's even close to its advertisement: so far I've just been unable to figure it out.  If you have similar problems, you can ask us directly or through Carmen, or you can visit on the WWW phrogram.com, go to Forums, Phrogram Questions and Answers, and ask your question there.
  7. If you've been wondering what colors are available for the pen and for rectangles, open the Utilities folder in Phrogram, and open and run ColorComparison.kpl.
  8. Similarly, good information about fonts available for PrintInRectangle can be found by running StandardFonts.kpl from the Utilities folder.

4. Proctor Help

If you have a question or get stuck, raise your hand and one of the proctors will come by to chat.