Alice. Coverage. Mathematical Expressions, Conditional Statements, Control Structures. Arithmetic Expressions Built-in Functions Conditional Execution

Similar documents
Repetition everywhere comparing while in a method and as an event. Comparison

Getting Started with Java Using Alice. 1 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Chapter 0. Getting Started. Objectives

Making Billboards. By Deborah Nelson Duke University, Under the direc:on of Professor Susan Rodger, July 14, 2008

Plotting Points. By Francine Wolfe Professor Susan Rodger Duke University June 2010

Peeking into Computer Science Alice Lab Manual. Lab Manual. Programming

An object in 3D space

Exit: These control how the object exits the slide. For example, with the Fade animation the object will simply fade away.

Multimedia web page Board

Nonvisual Arrays and Recursion. by Chris Brown under Prof. Susan Rodger Duke University June 2012

The Mathcad Workspace 7

The Alice Scene Editor

Introduction to Flash - Creating a Motion Tween

Creating a Fancier Fox and Inheritance in Alice 3

REMEMBER TO BRING YOUR MEMORY STICK TO EVERY LAB!

Appendix A Reference: Built-in Methods

How to...create a Video VBOX Gauge in Inkscape. So you want to create your own gauge? How about a transparent background for those text elements?

SIMPLE TEXT LAYOUT FOR COREL DRAW. When you start Corel Draw, you will see the following welcome screen.

By Ruthie Tucker Under the direction of Professor Susan.

Skater World: Part Three

= 3 + (5*4) + (1/2)*(4/2)^2.

using Arrays and Lists in an Alice world Prerequisites Everything World.OpeningScene Cinderella.end the chickens while they dance.

CompSci 94 Classwork: While loops and Randomness March 6, Prof. Susan Rodger CompSci 94 Spring 2018

The Essentials of Alice

Decision Structures. Chapter 4

3.6: First Person Computer Games

Word 2003: Flowcharts Learning guide

Clickteam Fusion 2.5 Creating a Debug System - Guide

Autodesk Navisworks Freedom Quick Reference Guide

Variables and Functions Chapter 3

Adobe Flash CS3 Reference Flash CS3 Application Window

Choose the best answer from each of the following; answer A for True, B for False for any T/F questions.

A Simple Quiz for Alice 3.2: Ask User Functions.

Telling a Story Visually. Copyright 2012, Oracle. All rights reserved.

Using Flash Animation Basics

HAPPY HOLIDAYS PHOTO BORDER

Using Functions in Alice

Adjust model for 3D Printing. Direct modeling tools 13,0600,1489,1616(SP6)

Game Starter Kit Cheat Sheet

This is the opening view of blender.

The Matrix. By Melissa Dalis Professor Susan Rodger Duke University June 2011

COMP : Practical 6 Buttons and First Script Instructions

Using Microsoft Word. Text Editing

EXCEL SKILLS. Selecting Cells: Step 1: Click and drag to select the cells you want.

Premiere Pro Desktop Layout (NeaseTV 2015 Layout)

CompSci 94 Making Decisions February 8, Prof. Susan Rodger

COMP : Practical 8 ActionScript II: The If statement and Variables

This document describes the user interface, navigation and the common resources that are available in SvalSim

PC4G - University of Waterloo December 8, 2017

The UBot Studio SCRIPT REFERENCE. The Qualifier Functions

When you move an (unparented and unrotated) item in Layout, generally your mouse movements have the following effects:

potions. The troll doubles in size.

StudioPrompter Tutorials. Prepare before you start the Tutorials. Opening and importing text files. Using the Control Bar. Using Dual Monitors

Shorter of two objects and changing color V2

Simply Personnel Screen Designer

Methods (part 2) Alice In Action, Ch 2

Index. Guide. Camera Detect Event Guide. AcuraVision

Prezi Quick Guide: Make a Prezi in minutes

3 Programming. Jalal Kawash Mandatory: Chapter 5 Section 5.5 Jalal s resources: How to movies and example programs available at:

Recipes4Success. Animate Plant Growth. Share 4 - Animation

LAB 2 CREATING A COMBINED PROPOSAL

Class-level Methods. Chapter 6 part 1

Introduction to Computer Science with MakeCode for Minecraft

To get a copy of this image you right click on the image with your mouse and you will get a menu. Scroll down the menu and select "Save Image As".

LmÉPï C Á npï À ƵÀ ïì itech Analytic Solutions

Shorter of two objects and changing color

Basic Data Acquisition with LabVIEW

Work with RSS Feeds. Procedures. Add an RSS Text Object CHAPTER. Procedures, page 7-1

IT Introduction to Programming for I.T. Midterm Exam #1 - Prof. Reed Spring 2008

MS PowerPoint. Module 6

An Approach to Content Creation for Trainz

EDIT202 Spreadsheet Lab Prep Sheet

Budget Exercise for Intermediate Excel

The Villa Savoye ( ), Poisy, Paris.

How to create interactive documents

Customizing FlipCharts Promethean Module 2 (ActivInspire)

Introduction to Microsoft Excel 2010

Work with Shapes. Concepts CHAPTER. Concepts, page 3-1 Procedures, page 3-5

ProductView Express Documentation

Processing Assignment Write- Ups

Animatron Tutorial. Ronald Bourret

PowerPoint 2016 Building a Presentation

Shift Register: Exercise # 1: Shift Register Example VI. 1. Build the following front panel. Figure (8.1): Shift register exercise front panel

The Newsletter will contain a Title for the newsletter, a regular border, columns, Page numbers, Header and Footer and two images.

Making Objects Move in Unison: Using Lists. Overview

Making Objects Move in Unison: Using Lists

Introducing MoveIt! First, start the Baxter simulator in Gazebo:

GEOCIRRUS 3D Viewer. User Manual: GEOCIRRUS 3D Viewer Document version 1.6 Page 1

Princess & Dragon Part 1: Objects in an Alice World

2.2 - Layouts. Bforartists Reference Manual - Copyright - This page is Public Domain

Opening the Program. Movie Maker II 1

How to Add a Text Watermark to a Digital Image

B.Sc. VI SEM (CS+BIO)

MAKING TABLES WITH WORD BASIC INSTRUCTIONS. Setting the Page Orientation. Inserting the Basic Table. Daily Schedule

Geoffrey G Roy School of Engineering Science Murdoch University

LECTURE 5 Control Structures Part 2

Methods Tutorial: Part Two. By Deborah Nelson Duke University Professor Susan Rodger June 16, 2008

Repetition. Add in Objects. Position Objects. Monkey Eat Bananas Repetition Simple Loops and Conditional Loops for Alice 3

Monkey Eat Bananas Repetition Simple Loops and Conditional Loops for Alice 3

3Using and Writing. Functions. Understanding Functions 41. In this chapter, I ll explain what functions are and how to use them.

Transcription:

Alice Mathematical Expressions, Conditional Statements, Control Structures Coverage Arithmetic Expressions Built-in Functions Conditional Execution If/Then Statements Control Structures Loops 1

Functions Alice provides a set of built-in functions Similar to methods but like a mathematical function Takes some input and computes some output E.g. SquareRoot(25) We say the function returnsthe value 5 and has an input parameter of 25 Built-in functions give us information about properties of objects and relationship to other objects (e.g. distance, position in world, width) Functions Click on the functions tab after selecting an object 2

Arithmetic Function Example Make the alien on wheels move to another object If we use are not careful it will move right through the object We can experiment to find a good number More generally, we could change the distance it moves to the function that computes the distance between the two objects Drag the distance function over the 1 meter box Arithmetic Function Example Now the alien moves to the middle of the object; how to fix this? 3

Arithmetic Function Example Should move a distance: (distance to object) (Object width)/2 (alien width)/2 We can perform the math by clicking on the down arrow If-Then True Is Condition True? False To create, drag If/Else from bottom to the code window Do This Action Single Path If Statement 4

If-Then-Else True Is Condition True? False Do This Action Do Something Else If / Else Statement If/Else Example If the alien is smaller than the object Move around it Else Move right through it Can resize the object to check both cases 5

Relational Operators Relational operators are functions of the world object A == B A!= B A > B A < B A >= B A <= B A is equal to B A is not equal to B A greater than B A less than B A gteb A lteb If/Else Example If the alien s height < 2 then Move around it Else Move right through it Change the number 2 to test both cases 6

Repetition Sometimes you want to repeat some code multiple times Example: Make a flying cow Should wiggle front legs together as it flies, like a dolphin kick Remember how to do this? Flying Cow Problem: We would like the cow to wiggle her legs a total of 5 times, but it is a pain to copy the turn code 4 more times 7

Repetition We can use a loop to repeat any block as many times as we like Use LOOP to repeat something some known number of times Use WHILE to repeat something while some condition is true Once the condition becomes false, the loop will stop Version 1 Off a bit, why? Consider that we want the legs to move together like a dolphin kick, not running 8

Version 2 The leg turning is done at the same time; requires another Do Together block To try: Change Number of times to Infinity Flying Cow Reminder: Can also move camera around in the scene 9

While Loop True Is Condition True? False Do This Action While Loop Example Make the alien try to randomly get close to the object While (alien s distance to the object > some value) Turn some random amount Go forward 1 meter Say Found it! 10

While Loop code Random Roll Many other versions possible More Complex Loop If we click on the Complex loop then it shows additional loop options Most notably there is a loop index This is a variable that holds a number for the current iteration of the loop Sometimes we may want to do processing based on the index Loop index from NUM1 to NUM2 Loop body 11

More Complex Loop Example The opacity property sets how transparent an object is 0 = invisible 1 = fully solid Use the complicated loop to make the cow Fade from invisible to visible Fade from visible to invisible Class Exercise Make a kangaroo jump onto a crate. The legs should make a hopping motion. Use the height/width of the objects to guide the forward and upward movements. 12

Create a new event Class Exercise 2 Let the mouse move any object Create a loop so the kangaroo turns toward the crate and moves toward it ½ meter until it is close to the crate, then it stops and says GOT IT Use the mouse to move the crate around; the kangaroo should chase it 13