Presentation is loading. Please wait.

Presentation is loading. Please wait.

Functions.

Similar presentations


Presentation on theme: "Functions."— Presentation transcript:

1 Functions

2 Functions Methods that return a Value
Number Boolean (True/False) Object Other (Sound, Video, etc.) Does not change the current state of the world Does not move / change objects

3 What Functions Do Check a current condition (run-time)
Get information about objects Where they are Size Ask questions about the state of the world As it is now  With program running

4 Built In Functions Proximity Size Spatial Relationship Point of View
Relation to other objects Size Spatial Relationship Point of View Proximity – where the object is Distance to Distance to right/left/above/below/behind Size: Height Width Depth Smaller Than/Larger Than Spatial Relationship To the left of To the right of above / below in front of / behind Point of View: Point of View Position

5 Where to Use – Calling the Function
Anywhere that requires the type of information returned from the function Number Object Boolean Example: Bopper.move (how far) Bopper.move (distanceTo(mole))

6 Create Your Own Function
Exercise 6-1 #2 Create a new world with a car or truck. Write a program to make the 4 wheels of the car realistically turn forward as the car moves forward. Why a function??? Roll and move forward at the same time doesn’t look realistic. When cars move the tires do not rotate at the same rate as the car is moving forward Rotation must be based on the size of the tires (distance / (3.14 * diameter))

7 Create Your Own Function
Like Creating a Method Select Object in Object Tree Select Functions from Details Window Create New Function

8 Create Your Own Function
Name Type  Return Type Must have a Return Type Number Boolean Object Other

9 Coding Function Code Function Cannot Delete the Return Statement
All functions return some Information

10 Call the Function Function Call


Download ppt "Functions."

Similar presentations


Ads by Google