Introduction and overview of chapters



Introduction and overview of chapters

The goal of this book is to help the reader understand fundamental concepts in programming by examining the concepts in actual use in interesting applications. Much of the discussion is language-independent; that is, it applies to a wide variety of programming languages. However, the approach is for the readers to see and practice producing working examples for themselves. This means time spent on the details of specific programming languages and comparisons between different languages.

Most of the major examples in the text are done using HyperText Markup Language (HTML) with JavaScript and Flash with its programming language, ActionScript. One major example features the use of Java and short examples are provided of other languages. If you have surfed the Web, you definitely have viewed pages made using HTML. If any the sites visited involved dynamic (changing) content, you probably saw JavaScript in use and Flash. It is possible to produce the applications featured in this text because of the inherent power in programming systems such as HTML with JavaScript and Flash. Applications made with these systems are run using the powerful software products called browsers, the tools you use to surf the Web. It is your code with the browser code that provides the functionality for the applications.

The requirement to produce working programs from the very beginning means that several concepts and mechanisms need to be explained quickly just to get started. The text returns to the important concepts over and over. As described in the Preface, each chapter begins with a motivating example, then explains concepts in a more-or-less language independent way, next presents the details of implementation, including a section on what can go wrong, and ends with sections that take a more general, abstract approach.

Here is an overview of the book. It includes informal definitions of the concepts addressed and descriptions of the motivating applications, the major examples featured in each of the chapters.

The first nine chapters introduce fundamental concepts. The last five introduce advanced concepts strongly motivated by games but important for other applications as well. Chapter 10 is helpful for understanding Chapter 11, but the other chapters can be read in any order directly after Chapter 9.

Chapter 1: Development Environment shows how to prepare (develop) a HTML document and a Flash movie. Of course, since two actual applications are produced, you will get a quick, informal introduction to HTML and Flash with ActionScript mechanics. The motivating examples are a Web page describing Favorite Web Sites and a Flash movie giving Directions for folding an origami model. For practice using the drawing facilities of Flash, do the built-in lessons. This also will give you experience with the Flash panels.

Chapter 2: Basics presents the building blocks of programming languages: statements and expressions. These are roughly analogous to the sentences and phrases of English and other so-called natural languages. The chapter also shows ways to communicate with the person using the computer. This is termed input-output. The applications are several calculator programs, including ordering in a coffee shop, implemented in HTML with JavaScript.

Chapter 3: Extending the basic language introduces the fundamental concept of procedure: a way to package and name a sequence of code statements so they can be used many times. Procedures are defined and then invoked. The focus in this chapter is the so-called built-in procedures, procedures that come with the language. Chapter 6 will focus on programmer-defined procedures: these are the ones you, the programmer, create. The motivating applications are HTML documents with different images displayed as backgrounds. This chapter introduces the notion of pseudo-random processing, critical for many games.

Chapter 4: Events and event handling showcases the defining feature of modern programming: specifying that you want a particular action (the event handler) to be taken when the underlying programming system detects that a particular thing (the event) has occurred. The chapter also demonstrates the use of a coordinate system to define areas within an image. The motivating application is a Find game implemented in HTML with JavaScript making use of a digital photograph.

Chapter 5: Variables and Datatypes focuses on how you, the programmer, can give a name to a value, a piece of data, so that you can refer to the value. There are different kinds of values. For example, the datatype for a variable can be an integer, another type of number called floating point, a string of characters or other possibilities. The applications are a set of coin flip games implemented in HTML with JavaScript.

Chapter 6: Functions and parameters returns to the important concept of procedures, this time focusing on procedures defined by the programmer. The motivating application is a computerized version of the playground game rock-paper-scissors implemented in Flash. The application is done in static and animated versions, the latter making use of Flash's capability for frame (also called cel) animation: displaying a sequence of pictures to fool the eye into perceiving motion.

Chapter 7: Application state addressed the requirements for applications to maintain information and to implement logic: the rules of the game, for example. The mechanisms demonstrated include global variables (variables that persist and are accessible independent of procedures starting and stopping) and local variables (variables defined for use within a procedure), objects (aggregations of data and code), and if and switch statements (code for testing and acting on conditions). The example is the dice game of craps, presented using both HTML and Java. Comparing implementations of the same application can be instructive.

Chapter 8: Arrays and issues in automating a real-world application focuses on the mechanism for defining and manipulating sets of things. An array variable is a variable holding a set of values. The chapter also features use of timed events. The motivating application is the familiar card matching game called Memory or Concentration. In this chapter, the implementation is done using HTML.

Chapter 9: Objects returns to the important concept of objects introduced in chapter 7. The motivating application is the same as the previous chapter, Memory. However, this time the implementation is done in Flash. The objects include the built-in movie clip and objects defined for this application, a card.

Chapter 10: Computed Animation demonstrates the use of computed animation for simulation. The simulation is categorized as discrete since it produces a series of displays corresponding to set time intervals. You can think of the displays as snapshots taken of a virtual world. The program generates the snapshots. The motivating application is a ball bouncing against the walls of a two-dimensional box. The implementation is done in Flash.

Chapter 11: Ballistics simulation builds on the previous chapter for a more complex simulation. The concepts addressed include the equations of motion and collisions. The application is the simulation of a cannonball shooting out of the mouth of a cannon, tilted up at an angle, and at a specified speed. The implementation is done using Flash. The exposition demonstrates a way to do the implementation in steps.

Chapter 12: Discrete state simulation shows how to build a program to simulate a phenomenon with timed, deterministic and random factors. The motivating application is a [virtual] dog that can be petted and fed. The implementation is done in HTML with JavaScript.

Chapter 13: Recursion demonstrates the critical programming technique in which a procedure includes calls to itself. The chapter also features manipulation of a two-dimensional grid. The motivating application is a simplified version of the computer game minesweeper. It is implemented using Flash.

Chapter 14: Multiple events, the final chapter, brings together most of the previous material, including management of multiple events, manipulation of arrays and computed animation. The application is a shooter-type game done in Flash.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download