Using Functions http://www.alice.org/resources/lessons/using-functions/

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

JustinMind: Dynamic Panels
Built-in Functions & Arithmetic Expressions.
Monkey See, Monkey Do. Important Turn on Java-like syntax option in Alice, if is not on already.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Microsoft® Small Basic
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Calvin and Hobbes Teach Properties and Functions Created by Daniel MacDonald under the direction of Professor Susan Rodger Duke University June 2013.
Adobe Forms THE FORM ELEMENT PANEL. Creating a form using the Adobe FormsCentral is a quick and easy way to distribute a variety of forms including surveys.
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running o Stored in.
Visual Basic Chapter 1 Mr. Wangler.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Branching and Looping Examples, cont’d. Remember the generic triple jump world…
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Introduction to Arrays. definitions and things to consider… This presentation is designed to give a simple demonstration of array and object visualizations.
Working with the VB IDE. Running a Program u Clicking the”start” tool begins the program u The “break” tool pauses a program in mid-execution u The “end”
By Melissa Dalis Professor Susan Rodger Duke University June 2011 Multiplication Table.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
Mathematical Expressions, Conditional Statements, Control Structures
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2: Methods and Data Programming with Alice and Java First Edition.
LANDESK SOFTWARE CONFIDENTIAL Tips and Tricks with Filters Jenny Lardh.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Programming in Alice IT-IDT-9 Design, develop, test and implement programs using visual programming. 9.1 Utilize drag and drop software to develop programs.
Perfecto Mobile Automation
CS320n –Visual Programming Execution Control with If / Else and Boolean Functions (Slides 6-2-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for.
1 Quiz Show Programming Terms. 2 Alice - 3D Virtual Programming Vocabulary Quiz Board Chapter 1 Chapter 2a Chapter 2b Chapter 3 Chapter 4 $100 $200 $300.
Creating a UFO Rescue Game in Alice
Visual Basic.NET Windows Programming
Collision Theory and Logic
Programming & Scratch.
Scratch for Interactivity
Interacting Sprites Module 3: Investigation 1
Collision Theory and Logic
Comparing objects and changing color
Chapter 3: Variables, Functions, Math, and Strings
Chapter 3: Variables, Functions, Math, and Strings
Creating your Function
Simple Control Structures
Control Structures
Let's Race! Typing on the Home Row
Introduction to Events
Creating a UFO Rescue Game in Alice
Chapter 2 Visual Basic Interface
Tables, Smart Art and Templates
Event Driven Programming
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Objectives Learn about Function procedures (functions), Sub procedures (subroutines), and modules Review and modify an existing subroutine in an event.
Making Procedural Methods
Coding Concepts (Sub- Programs)
Arithmetic Expressions
Alice Variables Pepper.
Coding Concepts (Basics)
Arrays
Design and Implementation
Introduction to Problem Solving and Control Statements
Using Lists and Functions to Create Dialogue
ICT Gaming Lesson 3.
Tutorial for Arrays and Lists
Relational Expressions
Guidelines for Microsoft® Office 2013
Javascript Chapter 19 and 20 5/3/2019.
Selection Statements Chapter 3.
Web Programming and Design
Presentation transcript:

Using Functions http://www.alice.org/resources/lessons/using-functions/

What is a Method A method is set of instructions that is named, may have parameters and / or return a value, which defines a task to be performed. Methods are defined with a class, and are used by objects of that class

There are two types of methods in Alice What is a Method There are two types of methods in Alice Procedural Methods - directions for how the environment or objects in the environment should behave i.e“move forward” Functional methods – directions for getting information from the environment, objects, or the user i.e. “how far is the rabbit from the carrot?”

What is a Function What is a Function? A function asks a question (to check a condition or compute a value). In Alice, a function is used to get the information we need concerning: Information from Alice Find out the properties of an object Find out the relationship of one object to another Information from outside of Alice Ask for information from the user or return data from inputs Get information from the computer

What is a Function Built In Functions There are two places you can find built in functions in Alice. Class Methods Panel - Similar to the procedures tab you will find different functions depending on the class type you have select. Event Listeners Header - Many of the event listeners have functions that are built into them that allow you to request specific information about the event.

What is a Function Information From Inside Alice Functions can be used to find out information from within an Alice virtual world. They can be used to find out: Object Properties: What color an object is How tall an object is Relational Properties: How far is the ostrich from the baby ostrich Is the ostrich to the right of the baby ostrich

What is a Function Information From Users Information from users can be returned using built in functional methods that are found in the methods panel or by using functions that extend specific event listeners to get information like: A text string A number What key was pressed What object the mouse clicked

Using a Function Using a Function A function can’t be added to your program simply by dragging them to the appropriate locations. Unlike procedures Functions need to be used to replace parts of statements that you have already added to your program.

Using a Function Where They Go? Alice will only let you drag a function into your program in a place where: The statement can include a function The data type that the function will return will match the expected data type When you grab a function Alice will obscure the interface everywhere that is off limits and highlight and put a box around areas that will accept the inclusion of the selected function. Sometimes you will need to implement an arithmetic or relational expression to get the correct data type.

Using a Function Replacing a Parameters A useful way to use functions is to replace parameters in simple procedures to make them more dynamic: To move a character an unknown distance between objects To allow the user to input dialogue for a text bubble To allow the user to decide the number of times an animation will loop

Using a Function As a Conditional Expression Functions are very useful for setting up conditional outcomes based on user input or world relationships. Using a function allows you to request information that may be user defined or that can be different depending on when the procedure is called.

Using a Function Using an Expression You can use a function together with a mathematical expression to modify the information that is returned by the function. In this example you want the mom to move to the baby but not to move on top of her. If I use getDistance to to replace the move distance they will end up on top of each other. If I use the same function but add an arithmetical expression to subtract 1 from that return value I can have her stop just short.

Tips and Tricks

Tips and Tricks Sort Function By Return Type One great way to easily see what type of data the functions will return is to group the function list by return type using the top right drop down.

Tips and Tricks Using Random Number Function The getRandom functions use the computer to randomly create a number or value within the range you specify. The random number generation function is an extremely useful tool in Alice. It allows you to create variety in behavior and outcomes that can help add complex dimensions to animations and interactions. In these examples the random function will: Randomly determine how far the ostrich will run Select from a list of statements to determine what the ostrich will say

Tips and Tricks Random Number in a Conditional Random functions can be used to set up multiple different possible outcomes. By using a random boolean or number function with the if_else control structure you can create variations in behavior over time or on separate program runs. By not having to script every change in direction or behavior you can save a lot of time and create the illusion that objects or characters are naturally moving around of their own free will..