Title: CS103 HW23 Mr. Ts Commonwealth Adventure
1CS103 HW2/3Mr. Ts Commonwealth Adventure
- Group 16
- Group Leader Mathew Scott
- Members Steven White , William Ma , Sue Ellen ,
Linh Tran
2The Game Overview
Stop location title
The T the element hat is being moved by the
user
Map with current location highlighted
3User Interaction and Game Behavior
- The UP Arrow key will set T in vertical motion
- Holding the UP Arrow key down will move the T
with momentum
- When the back of the T reaches the top of the
screen (pixel location 0), the T wraps around to
bottom of the screen, the frame increments by 1,
and the T stop changes.
4Authoring ModeDesign Organization
All of the elements of each stop are organized in
separate layers.
There are 10 frames in all, each frame holds the
elements of another T stop.
Each frame has a stop() action on it. However the
first frame initializes the global variables.
5The Code
The following code is attached to the train movie
clip to give it movement.
onClipEvent (enterFrame) .
The code goes under the enterFrame handler
because the code will be executed continually.
The code has to update the position of the T
every frame to give it fluid motion.
6The Code
// normalize the (v) vertical position of the
T if (vlt0) v _root.drag if (vgt0) v -
_root.drag // move the train _y - v
This gives the momentum effectbecause if the v
variable (whichholds the amount of pixels
tomove vertically) is a positive numberthen the
global drag variable isadded to that variable to
normalize itto zero, the stopping state of the
T.
This is the exact point in code where the train
decrements its vertical property, which gives the
effect of going outbound. Variable v holds
the momentum to move vertically.
7The Code
// testing, boundary check if (_root.train_2._y(t
his._height/2)lt0) _root.gotoAndPlay(_root._cur
rentFrame 1) _y 500(this._height/2)
The above code executes if the back of the second
trainis less than zero which is the top of the
movie. If that is true, then the playhead moves
to the next frame (the nextT stop) and
repositions the T to the bottom of the screen.
8The Code
// respond to the up key if (Key.isDown(Key.UP))
if (vlt_root.thrustMax) v
_root.thrustSpeed
If the Up arrow key is being pressed down
then if the v variable (holds the value to
which the _y property of the train is
decremented) is less than the global variable
thrustMax (provides an upper bound to which the
speed of the T can increase) then increment the
v variable by the global variable thrustSpeed
(which holds the value of how fast the T
should travel). So basically this just makes the
T move up until the max speed allowed.
9The Code
Summary
Calculate the momentum
Move the train
Boundary check
Respond to Up key to move
10The End Of The Line
Once the user reaches the end of the map,they
are transported to a page that says thatyou have
reached the end of the line. There is areplay
button with the simple script on (release)
_root.gotoAndPlay (1) Which brings the
main playhead to the first frame, to start the
simulation over again.