Preface for readers
The book is an introduction to programming, focusing on logic, event handling, and application development. Programming logic involves the coding that implements things such as the rules of a game. Events for computers include a player pressing on a key, moving the mouse to move the cursor to a different area on the screen, clicking a mouse button, and the passage of a set interval of time. Application development is the name of the actions required to build an application.
It is assumed that the reader has basic computer experience, including
- using the mouse to control an on-screen cursor
- naming and saving files in directories
- using a browser program to visit a Web site and to open a local file
- playing computer games
The last experience is important because most of the motivating examples are simple computer games. Games are used because they provide challenging but understandable examples and the users, the players, are easy to keep in mind when doing the work. The games are practically all one-player games. With the exception of rock-paper-scissors, in which the computer's moves are defined by a calculation using a pseudo-random facility, the computer program does not play the game, but provides the environment and enforces the rules.
The book takes a spiral approach: concepts are introduced and then revisited to reinforce understanding. See the Introduction for an overview of the chapters.
Each chapter contains discussion of concepts that apply to a variety of programming languages and then description of the implementation of applications in specific languages. HyperText Markup Language (HTML) with JavaScript and Flash with ActionScript are the most common choices. The tools you will need to create and test applications are addressed in Chapter 1.
All chapters are organized into the following sections:
Statement of objectives: what you will know and what you will have done in the chapter
Motivating Example: description of the game or games, with rules and screen shots. Some chapters have more than one Motivating Example.
Introduction of concepts: high level description of concepts
Descriptionof concepts: more detailed, mainly programming language independent exposition with discussion of how the concepts vary in different languages as needed
Reading checks: a short set of questions on the conceptual material
Application(s):
Review of previous examples: for the features or concepts that are the focus of this chapter (omitted in some chapters)
Plan of attack: overview of implementation, pseudo-code, outlines, flow-charts, diagrams as appropriate. In many chapters, the implementation is shown in steps.
Use of concepts in implementation: details, including code sections. Note some applications are described in steps.
Reading checks: a short set of questions on the implementation details
What can go wrong: description of common problems
Chapter summary and Reflection: summary and then stepping back from the details to reflect on the concepts in a wider context
If you were a programmer: discussion of issues and experiences that would arise for people working in industry related to the content of the chapter
What's next
Exercises
Projects
The text also includes side comments denoted as TECHNICAL NOTE, TIP, REAL-LIFE NOTE, HISTORICAL NOTE and so on. These can be read in place or skipped for later.
Many chapters contain code presented in tables: the first column holds the code statements and the second column holds descriptions. Chapters contain screen shots, diagrams (including flowcharts) and tables describing the calling and called-by relationship among functions.
The book is not for advanced programmers in gaming. For example, it does not include material on 3D modeling, use of video, and peer-to-peer networking. However, the intermediate programmer may benefit from study of the more advanced examples. Similarly, the person with experience in Web page design and the use of Flash chiefly for animation would benefit from the attention to programming logic.
Extra note for teachers
There is a Tips for Teachers section for each chapter available along with working code for the games.
This text is for a course or self-study in programming. Games are chosen because games make use of fundamental programming concepts.
Students may need to be told explicitly that the course is not playing games, but building games. Students with experience (and talents) in the use of drawing programs should be cautioned that programming is different. They will be able to make use of their artistic skills but they will need to acquire new skills to construct working programs. Many students will need reminders that they are building the projects for other users. However, since the projects are games, and they can insert their own creative ideas, most will enjoy showing their work to their friends and family members. Lastly, all students will need guidance to work in steps.
The main programming environments used are HTML with JavaScript and Flash with ActionScript. The text does include examples in Java, and brief mention of vb.net, php, xml and Python. The author has the view that it is good strategy to mention and compare different languages, even with beginners. It helps avoid being totally immersed in details. Some students may ignore the discussion, but others will benefit. Another factor is that courses such as the ones likely to choose this book often attract a variety of students, with some having experience in traditional programming languages and interest in Web languages. Therefore, it is suggested that instructors mention these and other languages, especially as a way to connect this course with others offered by the institution. For example, at PurchaseCollege, we have courses in Creating Databases for Web Applications (php, server-side JavaScript with asp, and use of SQL) and Creating User Interfaces (xml, xsl, VoiceXML, and XHTML-MP). However, if you want to keep the course at an introductory level only, consider omitting some or all of the non-JavaScript material. Keep in mind, however, that students do appreciate the power of Flash and ActionScript, even though the development environment is complex.