CSE 203 Closed Lab 22 Instructions
Table of Contents
1. Objectives
To continue practicing allowing the user, by using the keyboard, to
influence
the movement of one or more sprites around in a window. In doing
so, to continue practicing the use of the program control constructs of
sequencing, selection, and iteration.
2. Set Up
- Two students should work together at one workstation.
- 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
- Work on your course project. Your partnership may elect to
create a project
program jointly, or to work on one partner's project for a while, then
switch and give time to the other partner's project.
- Stay in closed lab until the bell rings: there's plenty to do
when you're making an interactive situation.
- You may, perhaps, be interested in the following technique for
recognizing that a key has moved from the up to the down position, that
is to say, the key has been "clicked" down. Important in this
technique is the Boolean-valued object whose name says
"key_was_up". This example involves the "G" key, so the object's
name is "G_key_was_up". If you open these instructions in Carmen,
you may be able to copy the following program and paste it into
Phrogram.
/* Wayne D. Heym
November 6, 2007
Click the "G" key. Watch the telescope advance.
*/
Program SenseKeyboardClick
Method Main()
Shell.Status( "Click the \"G\" key. Watch the telescope advance." )
Define tel As Sprite
tel.Load( "telescope.gif" )
Define tel_animation_time_line As Integer [] = { 150, 750, 150, 2000, 0, 0 }
tel.AnimationTimeline = tel_animation_time_line
tel.MoveTo( 0, 0 )
tel.ForwardDirection = 45
tel.Show()
Define G_key_was_up As Boolean = True
While Not Keyboard.IsKeyDown( Keys.Escape )
If Keyboard.IsKeyDown( "G" ) Then
If G_key_was_up Then
tel.Forward( 10 )
End If
G_key_was_up = False
Else
G_key_was_up = True
End If
Shell.RefreshScreen()
End While
End Method
End Program
4. Proctor Help
If you have a question or get stuck,
raise your hand and one of the proctors will come by to chat.