Java 1.4 Game Programming

Andrew Mulholland and Glenn Murphy

Library of Congress Cataloging-in-Publication Data

Mulholland, Andrew.
     Java 1.4 game programming / by Andrew Mulholland and Glenn Murphy.
         p. cm.
     ISBN 1-55622-963-1

     1.   Java (Computer program language) 2.  Computer games—Programming.
     I.  Murphy, Glenn, 1908- II.  Title.
     QA76.73.J38 M849 2003

     794.8'152762—dc21                                                2002155485
                                                                                             CIP

© 2003, Wordware Publishing, Inc.

All Rights Reserved
2320 Los Rios Boulevard
Plano, Texas 75074

No part of this book may be reproduced in any form or by any means without permission in writing from Wordware Publishing, Inc.

ISBN 1-55622-963-1

10  9  8  7  6  5  4  3  2  1
0301

Java is a trademark of Sun Microsystems, Inc.
All brand names and product names mentioned in this book are trademarks or service marks of their respective companies. Any omission or misuse (of any kind) of service marks or trademarks should not be regarded as intent to infringe on the property of others. The publisher recognizes and respects all marks used by companies, manufacturers, and developers as a means to distinguish their products.

All inquiries for volume purchases of this book should be addressed to Wordware Publishing, Inc., at the above address. Telephone inquiries may be made by calling:

(972) 423-0090

About the Authors

This for me is probably the easiest part of the book to write. I really have a liking for writing about myself as I always feel it will sound boastful and conceited, which I am.

Well, I started life as a baby and I'm afraid that's where it all began. I started programming at around 16 years of age while attending college in my hometown of Manchester, England. I use the term "attended" loosely, however, because as soon as the programming began, I was hooked, and ducked out of many a lecture to create a variety of games, albeit on an 80x25 ASCII character resolution and a useful gotoxy(x, y) method. In the second year of college, a friend and programming buddy, Nick Kitson, and I co-wrote a 16,000-line soccer management game in Pascal called ESM European Soccer Manager, where you could actually watch the matches in an overhead view. Working on this taught me more than anything about programming. My advice—pick a goal and go for it.

After college, I made it into the Computer Games Technology program at the University of Abertay Dundee and am now midway through the (honours) 4th year. While "attending" university I have furthered my knowledge from Pascal to C/C++ and then on to Java. The ability to make web games playable in a browser (applets) was what originally made Java so appealing to me, and had been a mystery to me for long enough. There began my introduction to Java. Before Java, I was mainly a procedural programmer, and not that well tuned to object-oriented programming (OOP). The good thing about Java, in this sense, is that it is completely OOP, so there was no choice but to program in this style. For this I think learning Java is the best guide to OOP you can get. And then came the book.

After working on a Java game over the summer of 2000, I teamed up with my now co-author Andrew, who has been my flatmate and friend since the first year of university. The university's random accommodation allocation for freshers can take the credit for us meeting in the student halls. We began work on the book in late 2001, while both juggling our honours degree courses at the same time. Besides losing my virginity and trying to complete Jet Set Willy, this book has been the most grueling experience of my life, but it was all worth it in the end. (I hope this last sentence makes it to publication.)

My primary hope for this book is that it makes me as much money as possible. My secondary hope, besides programming games in Java, is that the book indicates the difficulties that we came across when researching Java for games programming in a clear manner, especially those surrounding threads, input, and graphics that we put a lot of work into. I think to become a good programmer you have to enjoy it; otherwise it's little use. Most of the enjoyment I find is in showing off what I have done, which there is no harm in now and again (and again and again J). One thing I am aware of is that in actually challenging yourself to do something, and believing that you can do it, there seems to be a fear factor where you often do not even attempt to code something, because you have never done it before. In buying this book, you have made a solid move in conquering this fear.

My interests mostly revolve around playing pool, watching films, and occasionally programming the night away, and there is still no better feeling than "7-balling" someone in a crowded club. I also collect Star Wars costumes and wear them out clubbing regularly.

As a final word, I hope this book is as useful to you as it was for me in writing it, and wish you luck in your quest of knowledge.

Glenn Murphy
glenn@chopsewage.com

This for me is probably one of the hardest parts of the book to write. I really have a dislike for writing about myself as I always feel it will sound boastful or conceited. Nevertheless, here goes…

Well, I am currently 21 years old and halfway through my 4th (honours) year of university studying BSc (Hons) Computer Games Technology at the University of Abertay in Dundee, Scotland. I would say I have been coding for around six years now and have obtained quite a broad range of skills within this time.

My first real stab at game programming was about a year and a half before I left home to go to university when I downloaded the DJGPP DOS compiler (http://www.delorie.com/djgpp) and the Allegro game library (http://www.talula.demon.co.uk/allegro) originally started by Shawn Hargreaves. After starting and never finishing a few projects, the next logical step was to move onto looking at OpenGL and DirectX. As well as looking at the 3D side of games programming however, I also invested time in learning Perl and MySQL, although I have recently switched to using PHP4 as it is sooo much nicer than Perl. ;)

From there, I then progressed onto Java and to be honest it is probably the best thing I have ever done. Java really is such a great language. Don't get me wrong—it does have some issues, but the structure of the language and also the documentation is really excellent (ever tried using MSDN? Urgh.).

One thing that deceived me, however, when I started to use Java was the simplicity. When you start looking into Java properly, you think—ah great, all the libraries have been written for me. However, as you will see as you progress through the book, these libraries are excellent for business application development, but there are some pitfalls and serious issues to consider when looking at the language and libraries (packages) from a game development point of view.

Probably now is a good time for a plug. Previously to this book, I coauthored Developer's Guide to Multiplayer Games, which focuses in detail on using sockets in C/C++ to create client-server games. That book has a large tutorial section that takes you through the process of writing a reusable network library and a multiplayer game, which also includes a signup/login and lobby system. What the book does not cover, however, is DirectPlay as we remain platform independent throughout the book, so your game server will compile as easily on the Linux platform as it will on the Windows platform. If you are interested, you can find out more information (and buy it J) at the following Amazon.com link: http://www.amazon.com/exec/obidos/tg/detail/-/1556228686

On a final note, I hope you enjoy reading this book and find the information within it useful. If you have any questions or problems with anything in the book, do not hesitate to e-mail either myself or Glenn and we will try to help you as best we can!

Andrew Mulholland
andrew@hfplimited.com



Java 1.4 Game Programming
Java 1.4 Game Programming (Wordware Game and Graphics Library)
ISBN: 1556229631
EAN: 2147483647
Year: 2003
Pages: 237

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net