CS Problem Solving and Object-Oriented Programming Lab 2 - Methods, Variables and Functions in Alice Due: September 23/24

Similar documents
CS Problem Solving and Object-Oriented Programming

Repetition. Add in objects. The world should look like this: Bunny Eat Broccoli Repetition Simple loops and Conditional loops

Lets Play Catch! Keeping Score in Alice. Overview. Set Up. Position the ball 20 feet away: Orienting the ball 7/19/2010

3. Select a colour and then use the Rectangle drawing tool to draw a rectangle like the one below.

Start - All Programs - Class Software - Scratch - Scratch move move move Sound play drum move move move play drum Control forever forever forever

User Guide. Two-Wheeled Add-on. Created By: A-Lab Software Limited. Date Created: Feb Date Modified: Feb Revision: 1.

Alice in Wonderland Tea Party Coding Animation

Skater World: Part Two. By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 2009

Chapter 13. ANTY: the robotic ant

TECHNICAL NOTE HOW TO USE LOOPERS. Kalipso_TechDocs_Loopers. Revision: 1.0. Kalipso version: Date: 16/02/2017.

Page 1 GM-FAQ Club Profile FAQs. Page

Table Football. Introduction. Scratch. Let s make a world cup football game in Scratch! Activity Checklist. Test your Project.

Sailwave Scoring Instructions for Thursday Night Races 2017

HOW TO SETUP ROUND ROBIN IN DARTS FOR WINDOWS

Air Ball! Evaluation copy

FIBA Europe Coaching Website. Manual. Practice Section

Microsoft Windows Software Manual for FITstep Stream Version 4

Fun Soccer Drills that Teach Soccer Skills to 5, 6, and 7 year olds

Mac Software Manual for FITstep Pro Version 2

Mapping a course for Pocket Caddy

Activity 5.1B Dragster Assembly Drawing

Circle Left / Circle Right. Forward & Back. Right-Arm Turn Left-Arm Turn Allemande Left. Promenade. Right & Left Grand.

[1] Introduction..pg3. [2] The Windows you Need pg3-4

Robot Activity: Programming the NXT 2.0

Start a new Scratch project. Delete the cat by right-clicking it and selecting Delete.

USER MANUAL April 2016

NCSS Statistical Software

Advantages and Disadvantages of Systems of Play

Hydrus 1D Tutorial. Example: Infiltration and drainage in a large caisson. 1) Basic model setup. Sebastian Bauer Geohydromodellierung

[MYLAPS INTEGRATION]

Figure 1 Example feature overview.

Design of Experiments Example: A Two-Way Split-Plot Experiment

Step 1. CoderDojo Milltown Exercise 1 Pong Page 1 of 13

Repetition Structures

Felix and Herbert. Level. Introduction:

LADOTD Roundabout Assistance Contract

Walking for Health: Scheme page guide Contents

Special Olympics Junior Athletes. Basketball

Requesting Team Activation

Relative Motion. A look at "Frames of Reference" Website

Integrated Sports Systems (ISS) Inc. Meet Management Suite

Assignment #3 Breakout!

Version 3.1.0: New Features/Improvements: Improved Bluetooth connection on Windows 10

1.2 Example 1: A simple hydraulic system

A PRACTICAL GUIDE TO YOUR TRAINING SESSIONS

Tutorial: Setting up and importing Splat Maps from World Machine

Ranger Walking Initiation Stephanie Schneider 5/15/2012 Final Report for Cornell Ranger Research

Background Summary Kaibab Plateau: Source: Kormondy, E. J. (1996). Concepts of Ecology. Englewood Cliffs, NJ: Prentice-Hall. p.96.

BALL HANDLING SKILLS

Midas Method Betting Software 3.0 Instruction Manual

Assignment 3: Breakout!

1. First start a new scratch project and remove the default sprite.

Welcome to the ABGC Basketball House League

Online League Management lta.tournamentsoftware.com. User Manual. Further support is available online at

UNDERGROUND SURVEY WITH MINEMODELLER

Gravity: How fast do objects fall? Teacher Version (Grade level: 4 7)

Hitting Your Marks on the Drag Strip

QUICK WARM UP: Thursday 3/9

Week 1 - Movement. Other quick ways to warm-up: 1) 10 spike approaches 2) tuck jumps 3) line touches

Student Exploration: Distance-Time Graphs

ADVANCED. CATIA V5 Workbook. Knowledgeware and Workbenches. Release 16. Knowledgeware. Workbenches. Richard Cozzens. Southern Utah University

23 August 2016 Page: 1

Lab 4: Root Locus Based Control Design

Boyle s Law: Pressure-Volume Relationship in Gases

Previous Release Notes

: User Manual. 1 Getting Started

BVIS Beach Volleyball Information System

Tutorial 6a Manual Digitisation

Volleyball Tryout Games & Drills

HIP HOP HEADUCATION - Vol. 1 Breakin THE FOUR ELEMENTS DJ ING - MC ING - BREAKIN - GRAFFITI

This portion of the piping tutorial covers control valve sizing, control valves, and the use of nodes.

NVSL Divisional Relay Carnival procedures using Hy-Tek

Module 8 Coils and Threads

ORF 201 Computer Methods in Problem Solving. Final Project: Dynamic Programming Optimal Sailing Strategies

Walk-O-Meter User Manual

Navy Guidance and Tips for Using DOEHRS-IH Ventilation NAVY & MARINE CORPS PUBLIC HEALTH CENTER

WEEK 5: TEAMWORK T-Ball Practice Plan

Quick Start Guide. A. Hardware installation B. Software installation C. Start the software for the first time D. Do your first measurement

Wooden Dummy Construction

Tutorial 2 Time-Dependent Consolidation. Staging Groundwater Time-dependent consolidation Point query Line query Graph Query

IMGA PAIRINGS INSTRUCTIONS USING the ONLINE GOLF GENIUS SOFTWARE ROGRAM Revised as of 12/31/2017

Page 1 Make more profit from your betting at Betting Speed Evolution and the Race Advisor

[CROSS COUNTRY SCORING]

Microfluidic Demonstration

Bikes and Energy. Pre- Lab: The Bike Speedometer. A Bit of History

Module 3 Developing Timing Plans for Efficient Intersection Operations During Moderate Traffic Volume Conditions

Technology. In the My Files [My Files] submenu you can store all the programs that you have made on the NXT or downloaded from your computer.

North, South, East & West Environmental Education Lesson Plan Edwards Camp and Conference Center

Welcome to Step Outside with Togo & Nogo a road safety training resource for year 2 children

ARCCOS 360 NEW USER GUIDE

Assignment A7 BREAKOUT CS1110 Fall 2011 Due Sat 3 December 1

[CROSS COUNTRY SCORING]

Taking Your Class for a Walk, Randomly

Note! In this lab when you measure, round all measurements to the nearest meter!

SickleFuse's Furisode For Genesis/G2F. A Manual

2 ND 3 RD FOOTBALL STANDARDS GRADE LEVEL STANDARD DESCRIPTION

TEAM MANAGER LITE ENTRY INSTRUCTIONS

Figure SM1: Front panel of the multipatcher software graphic user interface (GUI) at the beginning of multipatcher operation.

GHSA Swimming/Diving POP School User s Guide

Kari Hunt. Course KH Volleyball

Transcription:

CS 101 - Problem Solving and Object-Oriented Programming Lab 2 - Methods, Variables and Functions in Alice Due: September 23/24 Pre-lab Preparation Before coming to lab, you are expected to have: Read Adams, Chapters 2-3. Used Alice to do the marching toy soldier problem in the book in Section 2.2.2. Used Alice to do the wizard and troll example in the book in Section 2.4.1 and 2.4.2. Used Alice to do the girl and horse example in the book in Section 3.1.1 and 3.4. Introduction to the Assignment Here is the English description of the world you will create and program for parts 1 and 2 of this lab assignment: Two people play volleyball. Generally, they volley the ball nicely back and forth directly to each other. Sometimes one player will hit the ball into the net. When that happens, the other player will get the ball and start a new volley. In your animation, each player should use body motions to animate the movement necessary to hit the ball. You can decide when a player should hit into the net. Every time that you play the animation, it should do the same thing. Your animation should also use at least 2 camera views. There are a few simplifications I encourage you to make, compared to a real game of volleyball: Players always hit the ball either directly to the other player or into the net. A player does not need to move to get into position to hit the ball back. The ball always follows the same arc as it goes over the net. Here are some snapshots from the animation. 1

I have animated the scientist by having him bend his arms to hit the ball. The rest of his body is stationary. I have animated the zombie by having him use his legs to get more underneath the ball. This animation is much more complicated as it involves more body parts and motion. 2

This is a view of the 2 players with the ball in midair. Both players stay in their ready position the entire time. Here is the ball when the scientist hits it into the net. 3

After hitting the net, the ball falls to the ground. A view from the scientist s side. 4

A view from the zombie s side. For this assignment, it is best to approach the problem one step at a time, introducing a new object and then programming the animations for that object. Step 1: Posing the mad scientist The mad scientist can be found in the People category. Feel free to choose a different person if you like. Your first step should be to pose the mad scientist in such a way that he is prepared to hit the ball. This involves: Raising the scientist s arms Turning / rolling the arms so that the hands are close enough together to hit the ball. To ensure that the scientist s arms look ready to hit the ball, you should also add the volleyball to the world. You can find the volleyball in the Sports category. Tips on positioning the scientist s arms. I generally find it easier to change the pose of an object by executing methods on the object rather than trying to use the mouse controls. For example, to raise the scientist s left arm do the following: Click on the plus sign next to madscientist in the object tree to see the scientist s parts. Select leftarm in the object tree. Right-click (or ctrl-click on a Mac) on leftarm. Select methods in the menu that pops up. Select turn then BACKWARD and then ¼ revolution. Look at the result. You will probably find ¼ revolution to be too little. Use the Undo button and try again, turning the arm a bit more. Once you find a revolution distance you like, rotate the right arm the same amount. Next, you should make sure the hands are close enough together to hit the ball. Use the following steps to accomplish that. First, we ll get the mad scientist to face us: 5

Right click on madscientist in the object tree. Select methods, then turn to face and then camera. Next, we will move the volleyball to the scientist s hands: Select the volleyball in the object tree. Right-click on the volleyball. Select methods, then move to, then use the cascading menus until you can select one of the scientist s hands. This will center the ball on the scientist s hand, not really what we want. Click on the arrow in the top right to allow you to drag the volleyball left or right. Drag it until it is centered between the hands. Next experiment with the turn and roll methods on the scientist s arms until you get the arms in a good position. Step 2: Animating the mad scientist At this point, we have the mad scientist in the pose we want for the start of the animation. This is also the pose that he should be in when he is not actively hitting the ball. To work on the animation of the scientist hitting the ball, it is probably best to have a side view of the scientist. So, use the methods as above to turn the scientist left or right ¼ revolution. Note that at this point, we are not trying to make the ball move. You should probably just move the ball out of the way for now. All we are concerned about is animating the scientist so he moves his arms in a way that looks realistic to hit the ball. To do the animation, we need to write a method. First, we should think about how we want the animation to look and then come up with an algorithm for it. Start simply and if you don t like the result, try something else. Also, I would like each character to have a different animation, so don t try to get the scientist to do everything. First, write down in English the steps you want to take. It s easiest just to move the arms and leave the rest of the body stationary. Once, you have an idea what you want to do, you need to create a new method: Select madscientist in the object tree In the details pane (bottom left), click on the methods tab. Click on the Create new method button and give the method a name, like hitball. A good method name should be descriptive of what the method does, should have no spaces in it, should use lowercase letters except that the first letter of each word other than the first word should be capitalized. Find the instructions you want to use in the animation (probably just involving the arms) and drag those tiles into the method editor (bottom right). Menus will pop up for arguments you need to provide, like the number of revolutions to turn, for example. When you think you have something you like, click on the world.my first method tab in the method editor. Click on madscientist in the object tree. Drag the hitball tile (or whatever you called your new method) into my first method. Click the Play button in the top left corner of the window to see how the animation looks. It s probably not exactly what you want, so go back to the hitball method in the method editor and try something else. 6

Step 3: Posing and Animating the zombie Next, pose and animate the zombie (choosing a different character if you like). You should try for a different effect, but the basic procedure should be similar. Use the methods menu to adjust the zombie s body parts to get the initial pose. Write in English the steps you want to take for this animation. Create a new method for the zombie to do the animation. Call this new method from world.my first method. Keep modifying your zombie s method until you get an effect that you like and that is significantly different from what the scientist does. Step 4: Volleying the ball Now, you are ready to actually volley the ball between the two players. First, you need to update your starting world: Add a volleyball net from the Sports category. Position one player on each side of the net, roughly centered left-to-right and facing each other. To get the ball to move from the proper location in one player s hands to the proper location in the other player s hands, we will use Dummy objects: Position the ball in one of the player s hands the way you would like it to be when it arrives at that player. Do this using a combination of move methods on the volleyball and perhaps just using the mouse controls a bit, too. Once you have the ball where you want it, create a Dummy object at that location: On the right side of the world editor, click the more controls button. Select the volleyball Click the drop dummy at selected object button. This will add a Dummy Objects folder in the object tree. Open that up and you should see Dummy. Rename that to something more meaningful, like ballatscientist. This will be very convenient because now as the players volley the ball back and forth, one of your move commands will simply be to move the ball to ballatscientist. Create a similar dummy for the proper position of the ball at the zombie. Now you are ready to define a method hit on the ball to animate the ball s motion between the players. Note that this method will only move the ball. The players will not look like they are hitting it. After you get the ball s motion correct, you will then write another method to put the pieces together. The ball should move in a smooth arc over the net from one player s hands to the other. The first half the ball s horizontal motion it should be moving up, while it should be moving down for the second half. Rather than using a lot of trial and error to figure out how far to move the ball horizontally, you should use a function to find out how far apart the 2 dummy objects are and move ½ that distance as the ball goes up. Create a new variable in the hit method by clicking on the button on the right. This variable will be used to hold the distance between its starting location and its destination. This variable will therefore be a Number and should be given a name like distance. 7

Next, we will want to give this variable a value. Drag the variable declaration from the top of the method into the section where the instructions are. A menu will pop up where you should select set value. From the next menu, select any value. You are using this value as a placeholder. Next, click on Volleyball in the object tree and the functions tab in the details pane. Drag the tile for distance to over the placeholder value in your set instruction. In the next menu, select the destination. If the ball is starting in the scientist s hands, the destination should be the dummy that you placed at the zombie s hands. You are now assigning a value to the distance variable, where the value is the distance from the ball s current location to its final destination. You really only want to move it ½ that distance as the ball is going up, so divide this value by 2. To do this, click on the triangle that the follows (volleyball.distanceto (volleyballatzombie)). In that menu select math, then the division simple and finally the number 2. After doing all this, you should have a statement like this: Now, as the ball is going up, it should move toward its destination distance amount. When you drag the move toward tile into the method editor, for the distance, you should select expressions and then distance. As the ball is moving down, it should simply move to its destination. That is, use the move to method rather than the move toward method. move to moves the object so that it is centered on the destination object, in this case, the dummy object at the zombie. In contrast, move toward moves the object closer to the destination, but requires an argument indicating how far to move the object toward the destination. Put a call to this method into world.my first method to see if the ball moves the way that you expect (again ignoring the fact that it is not yet coordinated with the motion of the players). Next, you will want to have the second player hit the ball back. Think about this for a minute and you should realize that the motion will be very similar but in the opposite direction. It would be very convenient if we could use the same method again. As written it won t quite work because the method refers to a specific destination, the dummy object at the zombie. To make this method more general, we should introduce a parameter. In the method editor, click create new parameter. Call this parameter destination. We will use this to refer to one of the 2 dummy objects, so the type of this parameter is Object. Now, everywhere in your method that you referred to a specific dummy (like volleyballatzombie), change this to say destination. Next, go to world.my first method. You should now see that you need to specify an argument when you call the hit method. The argument needs to be the dummy you want to hit the ball to. So, for the existing call to the hit method, use the dummy at the zombie as the argument. Then add another call to the hit method following this one and pass the dummy at the scientist as the argument this time. Now, when you play your world, the ball should float nicely from the scientist to the zombie and then back! Now, you are ready to put the pieces together. Create a method in the world called volley. We place this method in world because it manipulates multiple objects: both players and the ball. Move the ball to one of the player s hands. Then have this method do the first player s animation, then hit the ball to the other player, the second player s animation and then hit the ball back. Call this method in world.my first method and remove the instructions that were previ- 8

ously there. Now, when you play the world you should get a nice volley back and forth. If you insert a bunch of calls to volley, you should end up with multiple volleys back and forth! There is one more nice finishing touch you can add. When the player animates, the player s hands probably move away from the ball. A good way to prevent this is to set the ball to have one of the player s hands as the ball s vehicle. When the player s hands move, the ball will move with it. At the end of the player s animation, you need to set the ball s vehicle back to the world so that it can move independently. To set the ball s vehicle: Select the ball in the object tree. Select the properties tab in the details pane Drag the vehicle tile into the player s animation method at the beginning and select one of the player s hands. Drag the vehicle tile into the player s animation as the last statement and select world as the vehicle. Do this for both players animations and try again. Things should be starting to look pretty good! Step 5: Hitting the ball into the net Hitting the ball into the net requires you to write another method on the ball. I would again recommend that you create a dummy to represent the location of the ball when it hits the net. Then your animation can just move to or toward that dummy. Test this method by calling it from my first method. When it works the way you like, modify my first method to play the game the way you like mixing up successful volleys with occasional hits into the net. You will also need to move the ball to the winning person s hands before resuming the volley. Be sure to add comments in your methods to help remember and communicate what your animations are doing. Step 6: Changing the camera view As one final touch, I would like you to introduce multiple camera angles and to switch angles at points of your choosing during the animation. First, drop a dummy at the current camera location and give it a suitable name. Then, move the camera either using methods as for the other objects or camera controls until you find another camera angle you like. Drop a dummy there. Next, modify your animation to set the camera s point of view at some point during the animation. Remember to set the duration to 0 for a better effect. 9

Grading 5 Step 1: Posing the first player 5 Step 2: Animating the first player 10 Step 3: Posing and animating the second player 10 Step 4: Volleying the ball 5 Step 5: Hitting the ball into the net 5 Step 6: Changing the camera view 5 Putting the animation pieces together 5 Comments Turning in Your Work Go to ella. Click on COMSC 101 in the toolbar menu across the top. Then click on Assignments in the left column. Click the submit link for this assignment. Click the Add Attachment button. Use the Browse button to upload a local file. Click Continue. Then click the Submit button. 10