Beginning Java Game Programming 2nd Edition Jonathan S. Harbour instant download
Beginning Java Game Programming 2nd Edition Jonathan S. Harbour instant download
https://ebookultra.com/download/beginning-java-game-
programming-2nd-edition-jonathan-s-harbour/
https://ebookultra.com/download/multi-threaded-game-engine-design-1st-
edition-jonathan-s-jonathan-s-harbour-harbour/
https://ebookultra.com/download/beginning-c-game-programming-2nd-ed-
edition-john-horton/
https://ebookultra.com/download/xna-game-studio-4-0-for-
xbox-360-developers-1st-edition-jonathan-s-harbour/
https://ebookultra.com/download/advanced-java-game-programming-
wallace-croft/
Beginning Direct3D Game Programming Prima Tech s Game
Development 1st Edition Wolfgang Engel
https://ebookultra.com/download/beginning-direct3d-game-programming-
prima-tech-s-game-development-1st-edition-wolfgang-engel/
https://ebookultra.com/download/killer-game-programming-in-java-1st-
edition-andrew-davison/
https://ebookultra.com/download/beginning-programming-with-java-for-
dummies-4th-edition-barry-burd/
https://ebookultra.com/download/beginning-programming-with-java-for-
dummies-5th-edition-barry-burd/
https://ebookultra.com/download/beginning-opengl-game-programming-
second-edition-luke-luke-benstead-benstead/
Beginning Java Game Programming 2nd Edition
Jonathan S. Harbour Digital Instant Download
Author(s): Jonathan S. Harbour
ISBN(s): 9781598636499, 1598636499
Edition: 2
File Details: PDF, 3.26 MB
Year: 2007
Language: english
Beginning
JavaTM Game
Programming
Second Edition
Jonathan S. Harbour
ß 2008 Thomson Course Technology, a division of Thomson Learning Publisher and General Manager,
Inc. All rights reserved. No part of this book may be reproduced or Thomson Course Technology PTR:
transmitted in any form or by any means, electronic or mechanical, Stacy L. Hiquet
including photocopying, recording, or by any information storage or
retrieval system without written permission from Thomson Course Associate Director of Marketing:
Technology PTR, except for the inclusion of brief quotations in a review. Sarah O’Donnell
The Thomson Course Technology PTR logo and related trade dress are Manager of Editorial Services:
trademarks of Thomson Course Technology, a division of Thomson Heather Talbot
Learning Inc., and may not be used without written permission.
Marketing Manager:
Java is a trademark of Sun Microsystems, Inc. in the United States and
Jordan Casey
other countries. All other trademarks are the property of their
respective owners. Senior Acquisitions Editor:
Important: Thomson Course Technology PTR cannot provide software Emi Smith
support. Please contact the appropriate software manufacturer’s
technical support line or Web site for assistance. Project Editor/Copy Editor:
Cathleen D. Small
Thomson Course Technology PTR and the author have attempted
throughout this book to distinguish proprietary trademarks from Technical Reviewer:
descriptive terms by following the capitalization style used by the Dustin Clingman
manufacturer.
PTR Editorial Services Coordinator:
Information contained in this book has been obtained by Thomson Erin Johnson
Course Technology PTR from sources believed to be reliable. However,
because of the possibility of human or mechanical error by our sources, Interior Layout Tech:
Thomson Course Technology PTR, or others, the Publisher does not ICC Macmillan Inc.
guarantee the accuracy, adequacy, or completeness of any information
and is not responsible for any errors or omissions or the results Cover Designer:
obtained from use of such information. Readers should be particularly Mike Tanamachi
aware of the fact that the Internet is an ever-changing entity. Some facts
may have changed since this book went to press. CD-ROM Producer:
Brandon Penticuff
Educational facilities, companies, and organizations interested in
multiple copies or licensing of this book should contact the Publisher Indexer:
for quantity discount information. Training manuals, CD-ROMs, and Katherine Stimson
portions of this book are also available individually or can be tailored
for specific needs. Proofreader:
Kate Shoup
ISBN-10: 1-59863-476-3
ISBN-13: 978-1-59863-476-1
eISBN-10: 1-59863-649-9
Library of Congress Catalog Card Number: 2007938236
Printed in the United States of America
08 09 10 11 12 TW 10 9 8 7 6 5 4 3 2 1
I thank God for the many opportunities that have come my way this year, such as
the chance to write this book, and for the apparent talent needed to make
something tangible of these opportunities. I am grateful to my family for their
ongoing encouragement: Jennifer, Jeremiah, Kayleigh, Kaitlyn, Kourtney, Mom
and Dad, Grandma Cremeen, Dave and Barbara, my extended family at Vision
Baptist Church, and Pastor Michael Perham and his family–Jennifer, Ashley,
Bryce, and Sage–who have been such a blessing this past year.
Thank you to the students, faculty, and staff at UAT for contributing to such a
wonderfully creative environment for learning. I would like to thank the Alpha
Squad team, who had some influence on this book (and even helped to solve a few
coding problems with Galactic War): Roy Evans, Stewart Johnston, Peter Pascoal,
Travis Eddlemon, Daniel Muller, Daniel Stirk, Patrick Cissarz, David Coddington,
Marc Kirschner, Jeffrey Woodard, Jonathan Allmen, Levi Bath, Douglas Cannon,
Joshua Gertz, Justin Hair, Adam Knight, Eric Lacerna, Daryl Lynch, and Kevin
McCusker; and the faculty sponsors: Rebecca Whitehead, Michael Eilers, and
Arnaud Ehgner. I also owe my thanks to students Mark Walker and Andrew
Hawken for introducing me to the angular velocity code used in Galactic War.
I am also very thankful for the artwork featured in this book, provided by Ari Feldman
(www.flyingyogi.com) and Reiner Prokein (www.reinerstileset.de). Without their
wonderful graphics, Galactic War would have featured programmer art (cringe!).
I offer my sincere thanks to the editors at Course Technology PTR and the
freelance editors who put this book together: Emi Smith, Cathleen Small, Dustin
Clingman, and Kate Shoup.
About the Author
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
vi
Contents vii
This book will teach you how to write Java games that will run as applets in a web
browser. The goal is to develop games for the casual game market. Game pro-
gramming is a challenging subject that is not just difficult to master—it is
difficult just to get started. This book takes away some of the mystery of game
programming by explaining each step along the way, from one chapter to the
next. I assume that you have a little Java programming experience, but even if you
have never used Java before, you should be able to keep up.
This book reads like a hobby book, with no pressure and limited goals, because the
primary purpose of this book is to help you have fun learning how to program web-
based games. Typing in long source code listings out of a book is not fun, so I don’t
ask you to do that in every single chapter in this book. Instead, you will learn to write
short programs to demonstrate the major topics, and over time you will get the hang
of it. There is no memorization required here, because I’m a firm believer that
repetition—practice—is the best way to learn, not theory and memorization.
Note
Java is a programming language invented by Sun Microsystems. The primary goal of Java’s
developers was to be able to compile a program once and have it run on many different computer
systems. The Java compiler creates a ‘‘bytecode’’ file containing virtual machine instructions that
the JRE (Java Runtime Environment ) can execute on any computer system upon which it is
installed.
You will learn how to write a simple Java program in the first chapter. From
there, you will learn the details of how to write games that will run in a web
xiii
xiv Introduction
browser. We cover source code at a pace that will not leave you behind. After you
have learned enough, you will write your first web-based game, and you will then
learn new subjects in each chapter to increase your game programming skills. By
the end of this book, you will have learned to create a complete web-based game
called Galactic War, and you will be able to deploy it to your website in a Java
Archive (JAR) file. And I’m not talking about some half-baked simulation posing
as a game; I’m talking about a real game that is retail quality, suitable for pub-
lishing in the casual game market. There are thousands of casual gamers who are
paying to download games of this type from the many casual game sites on the
web today—such as Real Arcade (www.realarcade.com). By learning how to
create a casual game, you may even be preparing for a career in the game
industry, developing games for Microsoft Xbox Live Arcade and other com-
mercial endeavors.
Note
Web-based games are video games that are installed on a website and run in a web browser, so
that end users do not need to install the game. Some games are able to store high-score lists and
player data on the web server. The most popular type of web game is a ‘‘casual game.’’
While we’re on the subject of casual games, you can even program your own
Xbox 360 games, distributed on Xbox Live Arcade, using Microsoft’s free XNA
Game Studio Express software. Although this subject is beyond the scope of this
book, I bring it up because Microsoft’s C# language is unabashedly similar to
Java. Thomson published a book on this subject by Joseph Hall, titled XNA Game
Studio Express: Developing Games for Windows and the Xbox 360 (Thomson
Course Technology PTR, 2007).
It all begins here! Are you serious about this subject and willing to learn? As a
senior instructor of game development, I am scrutinized daily by students who
eat, drink, and breathe video games. I cannot create something that stinks, or I’ll
never hear the end of it! So I am as motivated to teach you cutting-edge game
development techniques here as I am in a real classroom setting, by students who
are paying a lot more than the retail cost of this book to learn these concepts. I
have used this book in several Java courses already, so you are guaranteed high-
quality material in these pages that will not be a waste of your time.
NOTE BY O. J. L.
On 16 July 1915, Raymond came home on leave, and he had a great
reception. On 20 July he went back.
"Sunday, 25 July 1915, 7.30 p.m.
"I have got quite a nice dug-out, with a chair and table in it.
The table was away from the door and got no light, so I have
spent about two hours to-day turning things round. I went to
bed about three this morning (just after 'stand-to') and slept till
nearly twelve. Then I had breakfast (bacon and eggs). As my
former platoon Sergeant remarked: 'It is a great thing to have a
few comforts, it makes you forget there is a war,'
"So it does until a whizz-bang comes over.
"I have just seen an aeroplane brought down (German luckily).
I missed the first part, where one of ours went up to it and a
flame shot across between them (machine gun, I expect). I ran
out just in time to see the machine descending on fire. It came
down quite steadily inside our lines (about a mile or more
away), but the flames were quite clearly visible,"
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.
ebookultra.com