Starting Out with Alice: A Visual Introduction to Programming

Paperback
from $0.00

Author: Tony Gaddis

ISBN-10: 0321475151

ISBN-13: 9780321475152

Category: 3D Computer Graphics

Search in google:

Starting Out with Alice: A Visual Introduction to Programming presents a fun and motivational way for novice programmers to learn the basic tenets of programming. Using Alice, an innovative and increasingly popular teaching tool, readers from a variety of backgrounds create virtual programming worlds of animations and computer games. In the successful style of Tony Gaddis’ texts, useful examples and detail-oriented explanations allow students to become comfortable with fundamental concepts of programming without dealing with frustrating syntax errors and complex design techniques. With the knowledge acquired using Alice, students gain confidence in their skills to transition into Java or other programming languages.

Preface xiiiChapter 1 Introduction to Alice and Objects 11.1 What Is a Computer Program? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11.2 Algorithms and Programming Languages . . . . . . . . . . . . . . . . . . . . . . .21.3 Learning to Program with Alice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5TUTORIAL 1-1: Opening and playing an Alice world . . . . . . . . . . . . . . . . . . . . . .61.4 Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131.5 Classes and the Alice Galleries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16TUTORIAL 1-2: Creating a world and adding objects . . . . . . . . . . . . . . . . . . . . .191.6 3D Objects and the Camera . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31TUTORIAL 1-3: Moving the camera in 3D space . . . . . . . . . . . . . . . . . . . . . . . .34TUTORIAL 1-4: Manipulating objects in 3D space . . . . . . . . . . . . . . . . . . . . . . .40TUTORIAL 1-5: Manipulating subpart objects . . . . . . . . . . . . . . . . . . . . . . . . . .43Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51Chapter 2 Programming in Alice 572.1 Writing Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57TUTORIAL 2-1: Adding instructions to an Alice world . . . . . . . . . . . . . . . . . . . .62TUTORIAL 2-2: Exploring additional primitive methods . . . . . . . . . . . . . . . . . .672.2 Naming Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .732.3 Designing a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77TUTORIAL 2-3: Using the program design cycle . . . . . . . . . . . . . . . . . . . . . . . . .822.4 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88TUTORIAL 2-4: Inserting comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .892.5 Tips for Setting Up an Initial Scene . . . . . . . . . . . . . . . . . . . . . . . . . . . .902.6 Executing Instructions Simultaneously . . . . . . . . . . . . . . . . . . . . . . . . .97TUTORIAL 2-5: Creating simultaneously executed instructions . . . . . . . . . . . . .982.7 Exporting Your Code for Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . .1042.8 Exporting an Alice World to Video . . . . . . . . . . . . . . . . . . . . . . . . . . .105Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106Chapter 3 Variables, Functions, Math, and Strings 1133.1 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113TUTORIAL 3-1: Creating and using a variable . . . . . . . . . . . . . . . . . . . . . . . . .116TUTORIAL 3-2: Creating a set instruction for a variable . . . . . . . . . . . . . . . . .1183.2 Using Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120TUTORIAL 3-3: Calling an ask user function . . . . . . . . . . . . . . . . . . . . . . . . .122TUTORIAL 3-4: Using a proximity function . . . . . . . . . . . . . . . . . . . . . . . . . . .1273.3 Creating Math Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130TUTORIAL 3-5: Using math to avoid collisions . . . . . . . . . . . . . . . . . . . . . . . .1323.4 Working with Strings and Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138TUTORIAL 3-6: Converting a Number variable to a string . . . . . . . . . . . . . . . .141Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144Chapter 4 Decision and Repetition Structures 1514.1 Boolean Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1514.2 The If/Else Decision Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . .153TUTORIAL 4-1: Creating an If/Else instruction . . . . . . . . . . . . . . . . . . . . . . .1564.3 Relational Comparisons and Logical Operators . . . . . . . . . . . . . . . . . .163TUTORIAL 4-2: Using a relational operator . . . . . . . . . . . . . . . . . . . . . . . . . . .165TUTORIAL 4-3: Testing an object’s color property . . . . . . . . . . . . . . . . . . . . . .1694.4 The Loop Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .174TUTORIAL 4-4: Using the Loop instruction . . . . . . . . . . . . . . . . . . . . . . . . . . .1754.5 The While Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180TUTORIAL 4-5: Using a While instruction to make an object vanish . . . . . . . .182TUTORIAL 4-6: Using the While instruction to move an object . . . . . . . . . . . .186Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .189Chapter 5 Methods, Functions, and More about Variables 1955.1 Writing Custom Class-Level Methods . . . . . . . . . . . . . . . . . . . . . . . . .195TUTORIAL 5-1: Creating a class-level method . . . . . . . . . . . . . . . . . . . . . . . . .1965.2 Saving an Object to a New Class . . . . . . . . . . . . . . . . . . . . . . . . . . . .199TUTORIAL 5-2: Saving an object to a class . . . . . . . . . . . . . . . . . . . . . . . . . . . .2005.3 Stepwise Refinement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .203TUTORIAL 5-3: Completing the WorkOut world . . . . . . . . . . . . . . . . . . . . . . .2075.4 Passing Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .209TUTORIAL 5-4: Passing arguments to a method . . . . . . . . . . . . . . . . . . . . . . . .2115.5 Using Class-Level Variables as Properties . . . . . . . . . . . . . . . . . . . . . . .215TUTORIAL 5-5: Adding a property to an object . . . . . . . . . . . . . . . . . . . . . . . .2175.6 Writing Class-Level Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .220TUTORIAL 5-6: Writing a class-level function . . . . . . . . . . . . . . . . . . . . . . . . .2215.7 World-Level Methods and Variables . . . . . . . . . . . . . . . . . . . . . . . . . .2265.8 Using Clipboards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2295.9 Tips for Visual Effects and Animation . . . . . . . . . . . . . . . . . . . . . . . . .230Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .241Chapter 6 Events 2496.1 Responding to Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2496.2 Handling Key Press and Mouse Events . . . . . . . . . . . . . . . . . . . . . . . .253TUTORIAL 6-1: Handling key press events . . . . . . . . . . . . . . . . . . . . . . . . . . . .254TUTORIAL 6-2: Handling the while a key is pressed event . . . . . . . . . . .258TUTORIAL 6-3: Handling a mouse click event . . . . . . . . . . . . . . . . . . . . . . . . .2616.3 Using Events in Simulations and Games . . . . . . . . . . . . . . . . . . . . . . .2646.4 Tips for Games and Simulations . . . . . . . . . . . . . . . . . . . . . . . . . . . . .268Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .275Chapter 7 Lists and Arrays 2817.1 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .281TUTORIAL 7-1: Creating a list and using the For all in order and For all together instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .285TUTORIAL 7-2: More complex list processing . . . . . . . . . . . . . . . . . . . . . . . . .291TUTORIAL 7-3: Using the Let the mouse move event . . . . . . . .3057.2 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .308TUTORIAL 7-4: Creating an array and a loop that steps through it . . . . . . . . .311TUTORIAL 7-5: Randomly selecting an array element . . . . . . . . . . . . . . . . . . .317Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .319Chapter 8 Recursion 3238.1 Introduction to Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .323TUTORIAL 8-1: Creating a recursive method . . . . . . . . . . . . . . . . . . . . . . . . . .3278.2 Problem Solving with Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . .330TUTORIAL 8-2: Recursive problem solving in animation . . . . . . . . . . . . . . . . .331TUTORIAL 8-3: Writing a recursive mathematical function . . . . . . . . . . . . . . .336Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .338Appendix A Installing Alice 343Appendix B Answers to Checkpoints 347Index 355