100% found this document useful (2 votes)
17 views48 pages

(Ebook) Mac game programming by Mark Szymczyk ISBN 1931841187 - The complete ebook is available for download with one click

The document provides information about the ebook 'Mac Game Programming' by Mark Szymczyk and includes links to download various related ebooks and textbooks. It features a foreword encouraging aspiring Mac game programmers and outlines the book's contents, which cover essential topics in game development. Additionally, it acknowledges contributors and provides details about the accompanying CD-ROM with development tools and resources.

Uploaded by

shavabadsa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
17 views48 pages

(Ebook) Mac game programming by Mark Szymczyk ISBN 1931841187 - The complete ebook is available for download with one click

The document provides information about the ebook 'Mac Game Programming' by Mark Szymczyk and includes links to download various related ebooks and textbooks. It features a foreword encouraging aspiring Mac game programmers and outlines the book's contents, which cover essential topics in game development. Additionally, it acknowledges contributors and provides details about the accompanying CD-ROM with development tools and resources.

Uploaded by

shavabadsa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 48

Visit ebooknice.

com to download the full version and


explore more ebooks or textbooks

(Ebook) Mac game programming by Mark Szymczyk ISBN


1931841187

_____ Click the link below to download _____


https://ebooknice.com/product/mac-game-programming-2124602

Explore and download more ebooks or textbooks at ebooknice.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

(Ebook) Game Programming Gems 2 (Game Programming Gems Series) (Vol 2)


by Mark DeLoura ISBN 9781584500544, 1584500549

https://ebooknice.com/product/game-programming-gems-2-game-
programming-gems-series-vol-2-1469990

(Ebook) Game Programming with Code Angel by Mark Cunningham ISBN


9781484253045, 1484253043

https://ebooknice.com/product/game-programming-with-code-
angel-50195610

(Ebook) Linux Game Programming w/CD (Prima Tech's Game Development) by


Mark Collins, Martin Donlin, Steve Baker, Ben Campbell ISBN
9780761532552, 0761532552

https://ebooknice.com/product/linux-game-programming-w-cd-prima-tech-
s-game-development-1469930

(Ebook) Game Programming Gems 3 (Game Programming Gems Series) (v. 3)


by Dante Treglia ISBN 9781584502333, 1584502339

https://ebooknice.com/product/game-programming-gems-3-game-
programming-gems-series-v-3-1469934
(Ebook) Learn Game Programming with Ruby: Bring Your Ideas to Life
with Gosu by Mark Sobkowicz ISBN 9781680500738, 1680500732

https://ebooknice.com/product/learn-game-programming-with-ruby-bring-
your-ideas-to-life-with-gosu-11238022

(Ebook) Journal 29 Revelation: Interactive Book Game by Dimitris


Chassapakis ISBN 9780692183052, 0692183051

https://ebooknice.com/product/journal-29-revelation-interactive-book-
game-36505882

(Ebook) Mac OS X Programming by Dan Sydow ISBN 9780735711686,


0735711682

https://ebooknice.com/product/mac-os-x-programming-983170

(Ebook) C# Game Programming: For Serious Game Creation by Daniel


Schuller ISBN 9781435455566, 1435455568

https://ebooknice.com/product/c-game-programming-for-serious-game-
creation-2269740

(Ebook) Game Programming Golden Rules (Game Development Series) by


Martin Brownlow ISBN 9781584503064, 1584503068

https://ebooknice.com/product/game-programming-golden-rules-game-
development-series-1684980
00 Macgame_FM.qxd 2/21/03 5:02 PM Page i

Mac Game
Programming
00 Macgame_FM.qxd 2/21/03 5:02 PM Page ii

This page intentionally left blank


00 Macgame_FM.qxd 2/21/03 5:02 PM Page iii

Mac Game
Programming

Mark Szymczyk
00 Macgame_FM.qxd 2/21/03 5:02 PM Page iv

© 2002 by Premier Press, Inc. All rights reserved. No part of this book may be reproduced or trans-
mitted in any form or by any means, electronic or mechanical, including photocopying, recording, or
by any information storage or retrieval system without written permission from Premier Press, except
for the inclusion of brief quotations in a review.
The Premier Press logo, top edge printing, and related trade dress are trademarks of Premier
Press, Inc. and may not be used without written permission. All other trademarks are the
property of their respective owners.

Publisher: Stacy L. Hiquet


Marketing Manager: Heather Buzzingham
Managing Editor: Sandy Doell
Acquisitions Editor: Emi Smith
Series Editor: André LaMothe
Editorial Assistant: Margaret Bauer
Marketing Coordinator: Kelly Poffenbarger
Technical Reviewer: Darrell Walisser
Copy Editor: Alice Martina Smith
Interior Layout: LJ Graphics
Cover Design: Mike Tanamachi
CD Producer: Darrell Walisser
Indexer: Johnna VanHoose Dinse
Proofreader: Kim Benbow
Microsoft, Windows, Internet Explorer, Notepad, VBScript, ActiveX, and FrontPage are trademarks or
registered trademarks of Microsoft Corporation. Netscape is a registered trademark of Netscape
Communications Corporation. Macintosh is a registered trademark of Apple Computer, Inc.
Premier Press and the author have attempted throughout this book to distinguish proprietary trade-
marks from descriptive terms by following the capitalization style used by the manufacturer.
Important: Premier Press cannot provide software support. Please contact the appropriate software
manufacturer’s technical support line or Web site for assistance.
Information contained in this book has been obtained by Premier Press from sources believed to be
reliable. However, because of the possibility of human or mechanical error by our sources, Premier
Press, or others, the Publisher does not guarantee the accuracy, adequacy, or completeness of any
information and is not responsible for any errors or omissions or the results obtained from use of
such information. Readers should be particularly aware of the fact that the Internet is an ever-chang-
ing entity. Some facts may have changed since this book went to press.
ISBN: 1-931841-18-7
Library of Congress Catalog Card Number: 2001096218
Printed in the United States of America
02 03 04 05 RI 10 9 8 7 6 5 4 3 2 1
00 Macgame_FM.qxd 2/21/03 5:02 PM Page v

This book is dedicated to the memory of Jeff Bilicki.


00 Macgame_FM.qxd 2/21/03 5:02 PM Page vi

Foreword

S o you want to be a Mac game programmer? This book is a great place to start.
Whether you are interested in how games work, want to learn to write share-
ware games, or want to become the next great commercial game developer, this
book will show you some of the key technologies and techniques required to make
your dream game.
Through the years, I’ve worked on many Mac games, from Duke Nukem 3D to Tomb
Raider and Unreal Tournament. When I began writing Mac games in 1985, I would
have loved to have access to a reference like this one. In those early years, Mac
game developers learned tricks from anywhere they could find them—late nights
pouring over Apple documentation, swapping ideas with other developers, and a
lot of trial and error.
As president of Westlake Interactive, I’m often asked by people how to break into
the Mac game business. My first answer is to get experience any way you can.
Anything from writing simple 2D games to working on flashy demos will show
potential employers that you have the drive and knowledge to make it in the game
business. Mac game programmers are incredibly difficult to find these days, so the
market for people with the interest and talent to work in the industry is very
strong.
Writing Macintosh games can be some of the most exciting, challenging, and
rewarding work a programmer can tackle. You have in your hands the perfect start-
ing point to enter the world of game programming; with hard work and determina-
tion, you’ll be well on your way to writing that next great Mac game!

Glenda Adams
President, Westlake Interactive
May 2002
00 Macgame_FM.qxd 2/21/03 5:02 PM Page vii

Acknowledgments

I t pains me to admit it, but I did not single-handedly create this book. Many people
helped make this book a reality, and I’d like to thank them here.

First, I’d like to thank my editors at Premier Press—and I worked with many editors
on this book. I would like to thank my original acquisitions editor, Jody Kennen, for
discovering me and for putting the book deal together. I would also like to thank my
original project editor, Brian Thomasson, for his help as I wrote the first chapters of
this book. He helped me get up to speed quickly on writing the chapters.

While I was writing this book, both Jody and Brian left to take other positions. Emi
Smith became my new acquisitions editor. I need to thank Emi for gathering all the
permissions necessary to include all the programs on the CD-ROM and for putting
up with delays in the project. Thanks to my copy editor, Alice Martina Smith, for
cleaning up some of my grammar and for bringing up questions that made the text
of this book easier for you to understand. I would also like to thank my Tech Editor,
Darrell Walisser, for reviewing all the source code in this book and making sure it all
runs well.

Next, I owe a huge Thank You to Carlos Camacho, the editor of the Mac game pro-
gramming site iDevGames, for two reasons. First, he let me write some articles for his
site, which is how Premier Press found me. Without his Web site, I wouldn’t be writ-
ing this book. Second, he donated artwork, music, and sound effects for the CD-
ROM that accompanies this book. His donation will make it easier for you to make
your own games, improving the book in the process.

I had many programming questions as I wrote the code for the book. I would like to
thank everyone who answered my questions on various mailing lists and message
boards. I don’t have a list of individuals who helped, but you know who you are.
00 Macgame_FM.qxd 2/21/03 5:02 PM Page viii

The CD-ROM that is with this book comes packed with development tools, games,
source code, and game assets. I would like to thank everyone who graciously let me
include their programs on the CD-ROM. You have helped make this book as good as
it can possibly be.

Finally, I want to thank my family for helping keep me sane while I wrote the book.
To my parents Stan and Mary, my brothers Dave and Steve, my sister Kathy, her hus-
band John, and my nephews Zachary and Christian, thank you.
00 Macgame_FM.qxd 2/21/03 5:02 PM Page ix

About the Author


When he graduated with a computer science degree from John Carroll University,
Mark Szymczyk set out on a career in software development. After bouncing
around among various corporate programming positions, he decided to go into
game development, starting his own shareware game company, Black Apple
Software. While working on his first game, he wrote some game development arti-
cles for the iDevGames Web site, which led to a request to write this book. Now that
the book is completed, he can finish up work on his first game.
Mark currently lives in the Cleveland, Ohio area. When he’s away from his Mac, he
enjoys playing basketball, listening to underground music from the 80s and 90s,
and hanging out with his nephews.
00 Macgame_FM.qxd 2/21/03 5:02 PM Page x

Contents at a Glance

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . xxviii
Chapter 1
Introduction to the Mac and to
Game Programming . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 2
Project Builder . . . . . . . . . . . . . . . . . . . . . . . . 27
Chapter 3
C++ for C Programmers. . . . . . . . . . . . . . . . . . . 59
Chapter 4
Introduction to
Macintosh Graphics . . . . . . . . . . . . . . . . . . . . . . 77
Chapter 5
Tiles and Scrolling. . . . . . . . . . . . . . . . . . . . . . 113
Chapter 6
Animation. . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Chapter 7
InputSprocket. . . . . . . . . . . . . . . . . . . . . . . . . 197
Chapter 8
HID Manager . . . . . . . . . . . . . . . . . . . . . . . . . 233
Chapter 9
Reading the Keyboard and Mouse
Plus Event Handling . . . . . . . . . . . . . . . . . . . . 297
00 Macgame_FM.qxd 2/21/03 5:02 PM Page xi

Contents at a Glance xi

Chapter 10
Sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
Chapter 11
Physics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
Chapter 12
Beginning Artificial Intelligence . . . . . . . . . . . . 455
Chapter 13
Pathfinding . . . . . . . . . . . . . . . . . . . . . . . . . . 491
Chapter 14
DrawSprocket . . . . . . . . . . . . . . . . . . . . . . . . 545
Chapter 15
Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585
Chapter 16
Putting It All Together . . . . . . . . . . . . . . . . . . 639
Chapter 17
Understanding the Game’s Source Code . . . . . . . 675
Chapter 18
Optimization . . . . . . . . . . . . . . . . . . . . . . . 717

Chapter 19
Game Development Tips . . . . . . . . . . . . . . . . . . 763
Appendix A
Installing Programs from the CD-ROM . . . . . . . . 797
Appendix B
Game Development Resources . . . . . . . . . . . . . . 801
Appendix C
CD-ROM Contents . . . . . . . . . . . . . . . . . . . . . . 813
00 Macgame_FM.qxd 2/21/03 5:02 PM Page xii

xii

Contents

Foreword . . . . . . . . . . . . . . . . . . . . . . . vi
Letter from the Series Editor. . . . . . . . xxxi
Introduction . . . . . . . . . . . . . . . . . . . xxxiii

Chapter 1
Introduction to the Mac and to
Game Programming . . . . . . . . . . . . 1
A Brief History of the Mac OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Mac Programming Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Mac Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Carbon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Cocoa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Programming with Carbon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
What to Place in Your System Folder. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
What to Place in Your Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
A Description of the Game We Will Develop . . . . . . . . . . . . . . . . . . . 12
Elements of a Computer Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Player Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Physics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Game Event Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
00 Macgame_FM.qxd 2/21/03 5:02 PM Page xiii

Contents xiii

I Want to Be a Professional Game Developer . . . . . . . . . . . . . . . . . . 16


Landing a Job as a Game Programmer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Making Your Own Games . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Advice for New Game Developers . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Pick a Project You Can Handle. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Choose a Project You Enjoy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Use Placeholder Assets at First . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Design First . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Know the Lingo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

Chapter 2
Project Builder . . . . . . . . . . . . . 27
Creating Your First Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Your First Real Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Creating Source Code Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Adding Files to a Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Adding Frameworks to a Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Contents List Tabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Files Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Classes Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Bookmarks Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Targets Tab. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Breakpoints Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Action Panel Tabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Find Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Build Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Run Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Debug Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
00 Macgame_FM.qxd 2/21/03 5:02 PM Page xiv

xiv Contents

Compiling a Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Debugging a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Setting Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
A Debugging Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

Chapter 3
C++ for C Programmers . . . . . . . 59
Structured vs. Object-Oriented Programming . . . . . . . . . . . . . . . . . . 61
Structured Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Object-Oriented Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Data Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Member Functions: Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Member Functions: Destructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Member Functions: Accessors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Member Functions: General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Inheritance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Virtual Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Private, Protected, and Public Keywords . . . . . . . . . . . . . . . . . . . . . . 71
Dynamic Memory Allocation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Converting the Book Code to C from C++ . . . . . . . . . . . . . . . . . . . . 75
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

Chapter 4
Introduction to
Macintosh Graphics. . . . . . . . . . . 77
Macintosh Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
8-Bit Color Pixels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
00 Macgame_FM.qxd 2/21/03 5:02 PM Page xv

Contents xv

16-Bit Color Pixels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81


32-Bit Color Pixels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
QuickDraw Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Pixel Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Graphics Ports. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
QuickDraw Coordinate System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Graphics Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Offscreen GWorlds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
The GameOffscreenBuffer Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Creating Offscreen GWorlds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Updating Offscreen GWorlds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Drawing a Picture into an Offscreen GWorld . . . . . . . . . . . . . . . . . . . . . . . 98
Disposing of Offscreen GWorlds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Using OS X’s Built-In Double Buffering . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Drawing to the Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
The CopyBits() Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Boolean Transfer Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Arithmetic Transfer Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Steps to Take . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Making CopyBits() Run at Its Best . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

Chapter 5
Tiles and Scrolling. . . . . . . . . . . 113
Introduction to Tiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Storing Tiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Storing Levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Finding a Tile’s Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Drawing Tiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
00 Macgame_FM.qxd 2/21/03 5:02 PM Page xvi

xvi Contents

Scrolling Backgrounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133


The GameContext Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Scrolling Right . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Scrolling Left . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Scrolling Down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Scrolling Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Tile Layering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Storing the Foreground Tiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Adding Foreground Tiles to a Level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Drawing Foreground Tiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

Chapter 6
Animation . . . . . . . . . . . . . . . . 155
Introduction to Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Generating Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Storing Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Creating Transparency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Drawing Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Sprite Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Creating the AnimationController Class . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Updating the Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Handling Movement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Handling Attacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
Handling Standing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
Maneuvering the Sprite through the Game World. . . . . . . . . . . . . . 176
Moving Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Moving Down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
00 Macgame_FM.qxd 2/21/03 5:02 PM Page xvii

Contents xvii

Moving Left . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181


Moving Right . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Moving Diagonally . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Dirty Rectangle Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
QuickDraw’s Dirty Rectangle Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Creating a Dirty Rectangle Animation System . . . . . . . . . . . . . . . . . . . . . . 192
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

Chapter 7
InputSprocket. . . . . . . . . . . . . . 197
Introduction to InputSprocket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
Setting Up Your Game to Use InputSprocket. . . . . . . . . . . . . . . . . . 200
What to Place in Your System Extensions Folder . . . . . . . . . . . . . . . . . . . . 200
What to Place in Your Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
InputSprocket Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
InputSprocket Programming. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
InputSprocket Terminology. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
The InputController Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Starting InputSprocket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Determining the Version of InputSprocket the Player Has . . . . . . . . . . . . . 210
Initializing InputSprocket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
Letting the User Configure the Controls . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Reading Button Presses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
Reading Player Movement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
Pausing and Resuming InputSprocket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Quitting InputSprocket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
00 Macgame_FM.qxd 2/21/03 5:02 PM Page xviii

xviii Contents

Chapter 8
HID Manager . . . . . . . . . . . . . . 233
Introduction to the HID Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
Setting Up Your Game to Use the HID Manager . . . . . . . . . . . . . . . 236
Programming with the HID Manager . . . . . . . . . . . . . . . . . . . . . . . . 236
HID Manager Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
HID Manager Version of the InputController Class . . . . . . . . . . . . . . . . . . 245
Finding the Player’s HID-Capable Devices . . . . . . . . . . . . . . . . . . . . . . . . . 247
Creating Device Interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Opening a Connection to the Input Device . . . . . . . . . . . . . . . . . . . . . . . . 252
Reading Button Presses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Reading Digital Movement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Reading Analog Movement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
Configuring Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
Setting Default Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
Pausing and Resuming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Cleaning Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296

Chapter 9
Reading the Keyboard and Mouse
Plus Event Handling . . . . . . . . . 297
Reading the Keyboard Directly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
Reading the Mouse Directly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
Reading the Mouse Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
Reading the Mouse Button. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
Using the Classic Event Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
00 Macgame_FM.qxd 2/21/03 5:02 PM Page xix

Contents xix

Looking for Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305


Handling Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
Using Carbon Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
Installing the Standard Window Event Handler. . . . . . . . . . . . . . . . . . . . . . 329
Installing the Standard Application Event Handler . . . . . . . . . . . . . . . . . . . 329
Defining Menu Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
Breaking Out of the Carbon Event Loop . . . . . . . . . . . . . . . . . . . . . . . . . . 332
Creating Your Own Carbon Event Handlers . . . . . . . . . . . . . . . . . . . . . . . 332
Event Loop Timers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344

Chapter 10
Sound. . . . . . . . . . . . . . . . . . . 345
A Sound Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Sound Formats. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Sampled Sounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Programming Sound with the Sound Manager. . . . . . . . . . . . . . . . . 355
The GameSound Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
Playing a Sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
Sound Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Callback Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
Looping a Sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
Setting a Sound’s Volume . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366
Pausing a Sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
Resuming a Sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
Stopping a Sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
Cleaning Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
Low-Level Sound Playing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
Random documents with unrelated
content Scribd suggests to you:
Note 12, p. 4. Mean quantities are such as are intermediate
between others that are greater and less. The mean of any number
of unequal quantities is equal to their sum divided by their number.
For instance, the mean between two unequal quantities is equal to
half their sum.

Note 13, p. 4. A certain mean latitude. The attraction of a sphere


on an external body is the same as if its mass were collected into
one heavy particle in its centre of gravity, and the intensity of its
attraction diminishes as the square of its distance from the external
body increases. But the attraction of a spheroid, fig. 1, on an
external body at m in the plane of its equator, E Q, is greater, and its
attraction on the same body when at mʹ in the axis N S less, than if
it were a sphere. Therefore, in both cases, the force deviates from
the exact law of gravity. This deviation arises from the protuberant
matter at the equator; and, as it diminishes towards the poles, so
does the attractive force of the spheroid. But there is one mean
latitude, where the attraction of a spheroid is the same as if it were
a sphere. It is a part of the spheroid intermediate between the
equator and the pole. In that latitude the square of the sine is equal
to 1⁄3 of the equatorial radius.

Note 14, p. 4. Mean distance. The mean distance of a planet from


the centre of the sun, or of a satellite from the centre of its planet, is
equal to half the sum of its greatest and least distances, and,
consequently, is equal to half the major axis of its orbit. For
example, let P Q A D, fig. 6, be the orbit or path of the moon or of a
planet; then P A is the major axis, C the centre, and C S is equal to
C F. Now, since the earth or the sun is supposed to be in the point S
according as P D A Q is regarded as the orbit of the moon or that of
a planet, S A, S P are the greatest and least distances. But half the
sum of S A and S P is equal to half of A P, the major axis of the
orbit. When the body is at Q or D, it is at its mean distance from S,
for S Q, S D, are each equal to C P, half the major axis by the nature
of the curve.

Note 15, p. 4. Mean radius of the earth. The distance from the
centre to the surface of the earth, regarded as a sphere. It is
intermediate between the distances of the centre of the earth from
the pole and from the equator.

Note 16, p. 5. Ratio. The relation which one quantity bears to


another.

Note 17, p. 5. Square of moon’s distance. In order to avoid large


numbers, the mean radius of the earth is taken for unity: then the
mean distance of the moon is expressed by 60; and the square of
that number is 3600, or 60 times 60.

Fig. 4
Note 18, p. 5. Centrifugal force. The force with which a revolving
body tends to fly from the centre of motion: a sling tends to fly from
the hand in consequence of the centrifugal force. A tangent is a
straight line touching a curved line in one point without cutting it, as
m T, fig. 4. The direction of the centrifugal force is in the tangent to
the curved line or path in which the body revolves, and its intensity
increases with the angular swing of the body, and with its distance
from the centre of motion. As the orbit of the moon does not differ
much from a circle, let it be represented by m d g h, fig. 4, the earth
being in C. The centrifugal force arising from the velocity of the
moon in her orbit balances the attraction of the earth. By their joint
action, the moon moves through the arc m n during the time that
she would fly off in the tangent m T by the action of the centrifugal
force alone, or fall through m p by the earth’s attraction alone. T n,
the deflection from the tangent, is parallel and equal to m p, the
versed sine of the arc m n, supposed to be moved over by the moon
in a second, and therefore so very small that it may be regarded as
a straight line. T n, or m p, is the space the moon would fall through
in the first second of her descent to the earth, were she not retained
in her orbit by her centrifugal force.

Note 19, p. 5. Action and reaction. When motion is communicated


by collision or pressure, the action of the body which strikes is
returned with equal force by the body which receives the blow. The
pressure of a hand on a table is resisted with an equal and contrary
force. This necessarily follows from the impenetrability of matter, a
property by which no two particles of matter can occupy the same
identical portion of space at the same time. When motion is
communicated without apparent contact, as in gravitation,
attraction, and repulsion, the quantity of motion gained by the one
body is exactly equal to that lost by the other, but in a contrary
direction; a circumstance known by experience only.
Note 20, p. 5. Projected. A body is projected when it is thrown: a
ball fired from a gun is projected; it is therefore called a projectile.
But the word has also another meaning. A line, surface, or solid
body, is said to be projected upon a plane, when parallel straight
lines are drawn from every point of it to the plane. The figure so
traced upon a plane is a projection. The projection of a terrestrial
object is therefore its daylight shadow, since the sun’s rays are
sensibly parallel.

Note 21, p. 5. Space. The boundless region which contains all


creation.

Fig. 5.
Fig. 6.

Note 22, pp. 5, 11. Conic sections. Lines formed by any plane
cutting a cone. A cone is a solid figure, like a sugar-loaf, fig. 5, of
which A is the apex, A D the axis, and the plane B E C F the base.
The axis may or may not be perpendicular to the base, and the base
may be a circle, or any other curved line. When the axis is
perpendicular to the base, the solid is a right cone. If a right cone
with a circular base be cut at right angles to the base by a plane
passing through the apex, the section will be a triangle. If the cone
be cut through both sides by a plane parallel to the base, the section
will be a circle. If the cone be cut slanting quite through both sides,
the section will be an ellipse, fig. 6. If the cone be cut parallel to one
of the sloping sides as A B, the section will be a parabola, fig. 7. And
if the plane cut only one side of the cone, and be not parallel to the
other, the section will be a hyperbola, fig. 8. Thus there are five
conic sections.
Fig. 7.
Fig. 8.

Note 23, p. 5. Inverse square of distance. The attraction of one


body for another at the distance of two miles is four times less than
at the distance of one mile; at three miles, it is nine times less than
at one; at four miles, it is sixteen times less, and so on. That is, the
gravitating force decreases in intensity as the squares of the
distance increase.

Note 24, p. 5. Ellipse. One of the conic sections, fig. 6. An ellipse


may be drawn by fixing the ends of a string to two points, S and F,
in a sheet of paper, and then carrying the point of a pencil round in
the loop of the string kept stretched, the length of the string being
greater than the distance between the two points. The points S and
F are called the foci, C the centre, S C or C F the excentricity, A P the
major axis, Q D the minor axis, and P S the focal distance. It is
evident that, the less the excentricity C S, the nearer does the ellipse
approach to a circle; and from the construction it is clear that the
length of the string S m F is equal to the major axis P A. If T t be a
tangent to the ellipse at m, then the angle T m S is equal to the
angle t m F; and, as this is true for every point in the ellipse, it
follows that, in an elliptical reflecting surface, rays of light or sound
coming from one focus S will be reflected by the surface to the other
focus F, since the angle of incidence is equal to the angle of
reflection by the theories of light and sound.

Note 25, p. 5. Periodic time. The time in which a planet or comet


performs a revolution round the sun, or a satellite about its planet.

Note 26, p. 5. Kepler discovered three laws in the planetary


motions by which the principle of gravitation is established:—1st law,
That the radii vectores of the planets and comets describe areas
proportional to the time.—Let fig. 9 be the orbit of a planet; then,
supposing the spaces or areas P S p, p S a, a S b, &c., equal to one
another, the radius vector S P, which is the line joining the centres of
the sun and planet, passes over these equal spaces in equal times;
that is, if the line S P passes to S p in one day, it will come to S a in
two days, to S b in three days, and so on. 2nd law, That the orbits
or paths of the planets and comets are conic sections, having the
sun in one of their foci. The orbits of the planets and satellites are
curves like fig. 6 or 9, called ellipses, having the sun in the focus S.
Several comets are known to move in ellipses; but the greater part
seem to move in parabolas, fig. 7, having the sun in S, though it is
probable that they really move in very long flat ellipses; others
appear to move in hyperbolas, like fig. 8. The third law is, that the
squares of the periodic times of the planets are proportional to the
cubes of their mean distances from the sun. The square of a number
is that number multiplied by itself, and the cube of a number is that
number twice multiplied by itself. For example, the squares of the
numbers 2, 3, 4, &c., are 4, 9, 16, &c., but their cubes are 8, 27, 64,
&c. Then the squares of the numbers representing the periodic times
of two planets are to one another as the cubes of the numbers
representing their mean distances from the sun. So that, three of
these quantities being known, the other may be found by the rule of
three. The mean distances are measured in miles or terrestrial radii,
and the periodic times are estimated in years, days, and parts of a
day. Kepler’s laws extend to the satellites.

Fig. 9.

Note 27, p. 5. Mass. The quantity of matter in a given bulk. It is


proportional to the density and volume or bulk conjointly.

Note 28, p. 5. Gravitation proportional to mass. But for the


resistance of the air, all bodies would fall to the ground in equal
times. In fact, a hundred equal particles of matter at equal distances
from the surface of the earth would fall to the ground in parallel
straight lines with equal rapidity, and no change whatever would
take place in the circumstances of their descent, if 99 of them were
united in one solid mass; for the solid mass and the single particle
would touch the ground at the same instant, were it not for the
resistance of the air.

Note 29, p. 5. Primary signifies, in astronomy, the planet about


which a satellite revolves. The earth is primary to the moon.

Note 30, p. 6. Rotation. Motion round an axis, real or imaginary.

Note 31, p. 7. Compression of a spheroid. The flattening at the


poles. It is equal to the difference between the greatest and least
diameters, divided by the greatest, these quantities being expressed
in some standard measure, as miles.

Note 32, p. 7. Satellites. Small bodies revolving about some of the


planets. The moon is a satellite to the earth.

Note 33, p. 7. Nutation. A nodding motion in the earth’s axis while


in rotation, similar to that observed in the spinning of a top. It is
produced by the attraction of the sun and moon on the protuberant
matter at the terrestrial equator.

Note 34, p. 7. Axis of rotation. The line, real or imaginary, about


which a body revolves. The axis of the earth’s rotation is that
diameter, or imaginary line, passing through the centre and both
poles. Fig. 1 being the earth, N S is the axis of rotation.

Note 35, p. 7. Nutation of lunar orbit. The action of the bulging


matter at the earth’s equator on the moon occasions a variation in
the inclination of the lunar orbit to the plane of the ecliptic. Suppose
the plane N p n, fig. 13, to be the orbit of the moon, and N m n the
plane of the ecliptic, the earth’s action on the moon causes the angle
p N m to become less or greater than its mean state. The nutation in
the lunar orbit is the reaction of the nutation in the earth’s axis.

Note 36, p. 7. Translated. Carried forward in space.

Note 37, p. 7. Force proportional to velocity. Since a force is


measured by its effect, the motions of the bodies of the solar system
among themselves would be the same whether the system be at
rest or not. The real motion of a person walking the deck of a ship at
sea is compounded of his own motion and that of the ship, yet each
takes place independently of the other. We walk about as if the earth
were at rest, though it has the double motion of rotation on its axis
and revolution round the sun.

Note 38, p. 8. Tangent. A straight line which touches a curved line


in one point without cutting it. In fig. 4, m T is tangent to the curve
in the point m. In a circle the tangent is at right angles to the radius,
C m.

Note 39, p. 8. Motion in an elliptical orbit. A planet m, fig. 6,


moves round the sun at S in an ellipse P D A Q, in consequence of
two forces, one urging it in the direction of the tangent m T, and
another pulling it towards the sun in the direction m S. Its velocity,
which is greatest at P, decreases throughout the arc to P D A to A,
where it is least, and increases continually as it moves along the arc
A Q P till it comes to P again. The whole force producing the
elliptical motion varies inversely as the square of the distance. See
note 23.

Note 40, p. 8. Radii vectores. Imaginary lines adjoining the centre


of the sun and the centre of a planet or comet, or the centres of a
planet and its satellite. In the circle, the radii are all equal; but in an
ellipse, fig. 6, the radius vector S A is greater, and S P less than all
the others. The radii vectores S Q, S D, are equal to C A or C P, half
the major axis P A, and consequently equal to the mean distance. A
planet is at its mean distance from the sun when in the points Q and
D.

Note 41, p. 8. Equal areas in equal times. See Kepler’s 1st law, in
note 26, p. 5.

Note 42, p. 8. Major axis. The line P A, fig. 6 or 10.

Note 43, p. 8. If the planet described a circle, &c. The motion of a


planet about the sun, in a circle A B P, fig. 10, whose radius C A is
equal to the planet’s mean distance from him, would be equable,
that is, its velocity, or speed, would always be the same. Whereas, if
it moved in the ellipse A Q P, its speed would be continually varying,
by note 39; but its motion is such, that the time elapsing between its
departure from P and its return to that point again would be the
same whether it moved in the circle or in the ellipse; for these
curves coincide in the points P and A.

Note 44, p. 8. True motion. The motion of a body in its real orbit P
D A Q, fig. 10.
Fig. 10.

Note 45, p. 9. Mean motion. Equable motion in a circle P E A B,


fig. 10, at the mean distance C P or C m, in the time that the body
would accomplish a revolution in its elliptical orbit P D A Q.

Note 46, p. 9. The equinox. Fig. 11 represents the celestial sphere,


and C its centre, where the earth is supposed to be. q ♈ Q ♎ is
the equinoctial or great circle, traced in the starry heavens by an
imaginary extension of the plane of the terrestrial equator, and E ♈
e ♎ is the ecliptic, or apparent path of the sun round the earth. ♈
♎ , the intersection of these two planes, is the line of the
equinoxes; ♈ is the vernal equinox, and ♎ the autumnal. When
the sun is in these points, the days and nights are equal. They are
distant from one another by a semicircle, or two right angles. The
points E and e are the solstices, where the sun is at his greatest
distance from the equinoctial. The equinoctial is everywhere ninety
degrees distant from its poles N and S, which are two points
diametrically opposite to one another, where the axis of the earth’s
rotation, if prolonged, would meet the heavens. The northern
celestial pole N is within 1° 24ʹ of the pole star. As the latitude of
any place on the surface of the earth is equal to the height of the
pole above the horizon, it is easily determined by observation. The
ecliptic E ♈ e ♎ is also everywhere ninety degrees distant from its
poles P and p. The angle P C N, between the poles P and N of the
equinoctial and ecliptic, is equal to the angle e C Q, called the
obliquity of the ecliptic.

Fig. 11.

Note 47, p. 9. Longitude. The vernal equinox, ♈ , fig. 11, is the


zero point in the heavens whence celestial longitudes, or the angular
motions of the celestial bodies, are estimated from west to east, the
direction in which they all revolve. The vernal equinox is generally
called the first point of Aries, though these two points have not
coincided since the early ages of astronomy, about 2233 years ago,
on account of a motion in the equinoctial points, to be explained
hereafter. If S ♈ , fig. 10, be the line of the equinoxes, and ♈ the
vernal equinox, the true longitude of a planet p is the angle ♈ S p,
and its mean longitude is the angle ♈ C m, the sun being in S.
Celestial longitude is the angular distance of a heavenly body from
the vernal equinox; whereas terrestrial longitude is the angular
distance of a place on the surface of the earth from a meridian
arbitrarily chosen, as that of Greenwich.

Note 48, pp. 9, 58. Equation of the centre. The difference between
♈ C m and ♈ S p, fig. 10; that is, the difference between the true
and mean longitudes of a planet or satellite. The true and mean
places only coincide in the points P and A; in every other point of the
orbit, the true place is either before or behind the mean place. In
moving from A through the arc A Q P, the true place p is behind the
mean place m; and through the arc P D A the true place is before
the mean place. At its maximum, the equation of the centre
measures C S, the excentricity of the orbit, since it is the difference
between the motion of a body in an ellipse and in a circle whose
diameter A P is the major axis of the ellipse.

Note 49, p. 9. Apsides. The points P and A, fig. 10, at the


extremities of the major axis of an orbit. P is commonly called the
perihelion, a Greek term signifying round the sun; and the point A is
called the aphelion, a Greek term signifying at a distance from the
sun.

Note 50, p. 9. Ninety degrees. A circle is divided into 360 equal


parts, or degrees; each degree into 60 equal parts, called minutes;
and each minute into 60 equal parts, called seconds. It is usual to
write these quantities thus, 15° 16ʹ 10ʺ, which means fifteen
degrees, sixteen minutes, and ten seconds. It is clear that an arc m
n, fig. 4, measures the angle m C n; hence we may say, an arc of so
many degrees, or an angle of so many degrees; for, if there be ten
degrees in the angle m C n, there will be ten degrees in the arc m n.
It is evident that there are 90° in a right angle, m C d, or quadrant,
since it is the fourth part of 360°.
Note 51, p. 9. Quadratures. A celestial body is said to be in
quadrature when it is 90 degrees distant from the sun. For example,
in fig. 14, if d be the sun, S the earth, and p the moon, then the
moon is said to be in quadrature when she is in either of the points
Q or D, because the angles Q S d and D S d, which measure her
apparent distance from the sun, are right angles.

Note 52, p. 9. Excentricity. Deviation from circular form. In fig. 6, C


S is the excentricity of the orbit P Q A D. The less C S, the more
nearly does the orbit or ellipse approach the circular form; and,
when C S is zero, the ellipse becomes a circle.

Note 53, p. 9. Inclination of an orbit. Let S, fig. 12, be the centre


of the sun, P N A n the orbit of a planet moving from west to east in
the direction N p. Let E N m e n be the shadow or projection of the
orbit on the plane of the ecliptic, then N S n is the intersection of
these two planes, for the orbit rises above the plane of the ecliptic
towards N p, and sinks below it at N P. The angle p N m, which
these two planes make with one another, is the inclination of the
orbit P N p A to the plane of the ecliptic.

Note 54, p. 9. Latitude of a planet. The angle p S m, fig. 12, or the


height of the planet p above the ecliptic E N m. In this case the
latitude is north. Thus, celestial latitude is the angular distance of a
celestial body from the plane of the ecliptic, whereas terrestrial
latitude is the angular distance of a place on the surface of the earth
from the equator.
Fig. 12.

Note 55, p. 9. Nodes. The two points N and n, fig. 12, in which the
orbit N A n P of a planet or comet intersects the plane of the ecliptic
e N E n. The part N A n of the orbit lies above the plane of the
ecliptic, and the part n P N below it. The ascending node N is the
point through which the body passes in rising above the plane of the
ecliptic, and the descending node n is the point in which the body
sinks below it. The nodes of a satellite’s orbit are the points in which
it intersects the plane of the orbit of the planet.

Note 56, p. 10. Distance from the sun. S p in fig. 12. If ♈ be the
vernal equinox, then ♈ S p is the longitude of the planet p, m S p
is its latitude, and S p its distance from the sun. When these three
quantities are known, the place of the planet p is determined in
space.

Note 57, pp. 10, 59. Elements of an orbit. Of these there are
seven. Let P N A n, fig. 12, be the elliptical orbit of a planet, C its
centre, S the sun in one of the foci, ♈ the point of Aries, and E N e
n the plane of the ecliptic. The elements are—the major axis A P;
the excentricity C S; the periodic time, that is, the time of a
complete revolution of the body in its orbit; and the fourth is the
longitude of the body at any given instant—for example, that at
which it passes through the perihelion P, the point of its orbit nearest
to the sun. That instant is assumed as the origin of time, whence all
preceding and succeeding periods are estimated. These four
quantities are sufficient to determine the form of the orbit, and the
motion of the body in it. Three other elements are requisite for
determining the position of the orbit in space. These are, the angle
♈ S P, the longitude of the perihelion; the angle A N e, which is the
inclination of the orbit to the plane of the ecliptic; and, lastly, the
angle ♈ S N, the longitude of N the ascending node.

Note 58, p. 10. Whose planes, &c. The planes of the orbits, as P N
A n, fig. 12, in which the planets move, are inclined or make small
angles e N A with the plane of the ecliptic E N e n, and cut it in
straight lines, N S n passing through S, the centre of the sun.

Note 59, p. 11. Momentum. Force measured by the weight of a


body and its speed, or simple velocity, conjointly. The primitive
momentum of the planets is, therefore, the quantity of motion which
was impressed upon them when they were first thrown into space.

Note 60, p. 11. Unstable equilibrium. A body is said to be in


equilibrium when it is so balanced as to remain at rest. But there are
two kinds of equilibrium, stable and unstable. If a body balanced in
stable equilibrium be slightly disturbed, it will endeavour to return to
rest by a number of movements to and fro, which will continually
decrease till they cease altogether, and then the body will be
restored to its original state of repose. But, if the equilibrium be
unstable, these movements to and fro, or oscillations, will become
greater and greater till the equilibrium is destroyed.

Note 61, p. 14. Retrograde. Going backwards, as from east to


west, contrary to the motion of the planets.
Note 62, p. 14. Parallel directions. Such as never meet, though
prolonged ever so far.

Fig. 13.
Fig. 14.

Note 63, pp. 14, 16. The whole force, &c. Let S, fig. 13, be the
sun, N m n the plane of the ecliptic, p the disturbed planet moving in
its orbit n p N, and d the disturbing planet. Now, d attracts the sun
and the planet p with different intensities in the directions d S, d p:
the difference only of these forces disturbs the motion of p; it is
therefore called the disturbing force. But this whole disturbing force
may be regarded as equivalent to three forces, acting in the
directions p S, p T, and p m. The force acting in the radius vector p
S, joining the centres of the sun and planet, is called the radial force.
It sometimes draws the disturbed planet p from the sun, and
sometimes brings it nearer to him. The force which acts in the
direction of the tangent p T is called the tangential force. It disturbs
the motion of p in longitude, that is, it accelerates its motion in some
parts of its orbit and retards it in others, so that the radius vector S
p does not move over equal areas in equal times. (See note 26.) For
example, in the position of the bodies in fig. 14, it is evident that, in
consequence of the attraction of d, the planet p will have its motion
accelerated from Q to C, retarded from C to D, again accelerated
from D to O, and lastly retarded from O to Q. The disturbing body is
here supposed to be at rest, and the orbit circular; but, as both
bodies are perpetually moving with different velocities in ellipses, the
perturbations or changes in the motions of p are very numerous.
Lastly, that part of the disturbing force which acts in the direction of
a line p m, fig. 13, at right angles to the plane of the orbit N p n,
may be called the perpendicular force. It sometimes causes the body
to approach nearer, and sometimes to recede farther from, the plane
of the ecliptic N m n, than it would otherwise do. The action of the
disturbing forces is admirably explained in a work on gravitation, by
Mr. Airy, the Astronomer Royal.

Note 64, pp. 16, 74. Perihelion. Fig. 10, P, the point of an orbit
nearest the sun.

Note 65, p. 16. Aphelion. Fig. 10, A, the point of an orbit farthest
from the sun.

Note 66, pp. 16, 17. In fig. 15 the central force is greater than the
exact law of gravity; therefore the curvature P p a is greater than P
p A the real ellipse; hence the planet p comes to the point a, called
the aphelion, sooner than if it moved in the orbit P p A, which makes
the line P S A advance to a. In fig. 16, on the contrary, the curvature
P p a is less than in the true ellipse, so that the planet p must move
through more than the arc P p A, or 180°, before it comes to the
aphelion a, which causes the greater axis P S A to recede to a.
Fig. 15.

Fig. 16.

Note 67, pp. 16, 17. Motion of apsides. Let P S A, fig. 17, be the
position of the elliptical orbit of a planet, at any time; then, by the
action of the disturbing forces, it successively takes the position Pʹ S
Aʹ, Pʺ S Aʺ, &c., till by this direct motion it has accomplished a
revolution, and then it begins again; so that the motion is perpetual.

Fig. 17.

Note 68, p. 17. Sidereal revolution. The consecutive return of an


object to the same star.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like