Hands-On Examples Hands-On Examples Chapter 1 Introduction to Com mp uter Programming 1.2 Look at Computer Code . . . . . . . . . . . . . . . . . . . . . . . . . 12 1.4 Write a Greeting in Binary . . . . . . . . . . . . . . . . . . . . . . . 16 Chapter 2 Solving Problems 2.1A Understand the Problem. . . . . . . . . . . . . . . . . . . . . . . 25 2.1B Carry Out a Plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 2.2 Solve a Simpler Problem . . . . . . . . . . . . . . . . . . . . . . . . 30 2.3A Write an Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 2.3B Review an Algorithm. . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Chapter 3 Introduction to the e Scratch Coding Environment 3.1A Experiment with Blocks . . . . . . . . . . . . . . . . . . . . . . . . 46 3.1B Create a Basic Script . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 3.1C Add Sprites to a Project . . . . . . . . . . . . . . . . . . . . . . . . 52 3.2A Explore Sprite Costumes . . . . . . . . . . . . . . . . . . . . . . . 55 3.2B Code Hello World Project. . . . . . . . . . . . . . . . . . . . . . . 60 3.3 Use a Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Chapter 4 Data and Expressions o 4.1 Using Global and Local Variables a . . . . . . . . . . . . . . . 73 4.2 Write an Expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 4.3A Ask for User Input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 4.3B Providing Good Output . . . . . . . . . . . . . . . . . . . . . . . . 85 4.4 Random Sprite Location. . . . . . . . . . . . . . . . . . . . . . . . . 88 4.5 Applying Lists to the Average g Projects . . . . . . . . . . 91 Chapter 5 Decisions 5.1 Basic Comparison Statemen nt . . . . . . . . . . . . . . . . . . 102 5.2 Boolean Expression Construction u . . . . . . . . . . . . . . 106 5.3A Basic IF…THEN Construction. o . . . . . . . . . . . . . . . . 108 5.3B Branching Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 5.3C Nested IF Statements . . . . . . . . . . . . . . . . . . . . . . . . . 114 5.3D Compare Input to a Calculation . . . . . . . . . . . . . . 117 Chapter 6 Loops 6.1A Forever Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 6.1B Repeat Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 6.1C Repeat Until Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 6.2A Nested Loops. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 6.2B Using a Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Chapter 7 Custom Blocks 7.1 Use Custom Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 7.2 Reusing a Custom Block . . . . . . . . . . . . . . . . . . . . . . . . 154 7.3 Data Types for Custom Block ks . . . . . . . . . . . . . . . . . . 158 7.4 Design a Project with Custom Blocks. . . . . . . . . . . 165 Chapter 8 Events 8.1 Events for Multiple Sprites. . . . . . . . . . . . . . . . . . . . . . 176 8.2 Broadcasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 8.3A Multiple Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 8.3B Create an Interactive Game e . . . . . . . . . . . . . . . . . . 187 Chapter 9 Sound and Video 9.1A Code d Background Music . . . . . . . . . . . . . . . . . . . . . 198 9.1B Usin ng Sound Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 9.2 Create a Program with Motion Control . . . . . . . . . 209 Chapter 10 Animation 10.1A Changing Costumes. . . . . . . . . . . . . . . . . . . . . . . . 221 10.1B Animating a Sprite by Rotation. . . . . . . . . . . . . . 225 10.1C Animating a Sprite by Changing Its Size . . . . . 226 10.2 Editi in g an Existing Costume. . . . . . . . . . . . . . . . . . 231 10.3 Crea at e a Rain Shower . . . . . . . . . . . . . . . . . . . . . . . . 236 10.4 Scro ol ling Background . . . . . . . . . . . . . . . . . . . . . . . . 241 Chapter 11 Game Design 11.1A Coding o Game Mechanics . . . . . . . . . . . . . . . . . . . 255 11.1B Adding the Objective Mechanic. . . . . . . . . . . . . 259 11.1C Coding the Character-Abilities Mechanic . . . . 262 11.2A Adding d Assets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 11.2B Developing the Game Loop. . . . . . . . . . . . . . . . . 268 11.2C Bal la ncing the Game . . . . . . . . . . . . . . . . . . . . . . . . 273 Chapter 12 Apps 12.1 Inve es tigate Available Apps . . . . . . . . . . . . . . . . . . . 284 12.2A Set t Up App Inventor. . . . . . . . . . . . . . . . . . . . . . . . 285 12.2B Coding a Hello World App . . . . . . . . . . . . . . . . . . 289 12.3A Exp pl oring Components . . . . . . . . . . . . . . . . . . . . . 295 12.3B Cre ea ting a Utility App. . . . . . . . . . . . . . . . . . . . . . . 298 12.4A Animating n a Ball. . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 12.4B Animating a Sequence of Images . . . . . . . . . . . 307 12.5 Disp pl ay an Address on a Map . . . . . . . . . . . . . . . . . 310 Chapter 13 Working in Three Dimensions 13.1 Rese ea rching 3D Software . . . . . . . . . . . . . . . . . . . . 323 13.2 Inve es tigating Higher Education. . . . . . . . . . . . . . . 325 13.3A Pro oj ect Setup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 13.3B Pro oj ect Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334 13.3C Set tt ing Up Camera Markers . . . . . . . . . . . . . . . . . 340 Chapter 14 Introduction to Coding Web Pages 14.1A HTML T Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354 14.1B Web e Page Title. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 14.1C Headings e and Paragraphs. . . . . . . . . . . . . . . . . . . 357 14.2A Adding d an Image. . . . . . . . . . . . . . . . . . . . . . . . . . . 360 14.2B Ins se rting Line Breaks . . . . . . . . . . . . . . . . . . . . . . . 361 14.3A For rm atting Text with an Internal CSS . . . . . . . . 363 14.3B Dra aw ing Horizontal Rules . . . . . . . . . . . . . . . . . . . 365 14.3C Set tt ing Background and Text Color. . . . . . . . . . 367 14.4A Lin nk ing within a Page. . . . . . . . . . . . . . . . . . . . . . . 369 14.4B Lin nk ing to an External Source . . . . . . . . . . . . . . . 371 14.5 Adding JavaScript to an HTML Button . . . . . . . . 375 xii
Previous Page Next Page