Perfect the art of game development – read this book today!. No member of the game development team should work in isolation.. Whether you’re a producer, designer, artist or programmer t
Trang 1Julian Gold is a software engineer at Microsoft Research
in Cambridge investigating advanced machine learning for
videogames As Senior Programmer for Sony Computer
Entertainment Europe he developed the visually stunning
Colony Wars: Red Sun (BAFTA Nominee) At Six By Nine
he worked on the best-selling soccer management game
LMA Manager 2002 and his experience also includes
time with Sega and Argonaut.
Perfect the art of game development – read this book today!
No member of the game development team should work in isolation.
Whether you’re a producer, designer, artist or programmer this book will
help you develop today’s ever more complex entertainment software
within the constraints of deadlines, budgets and changing technologies.
If you’re a student taking a games degree or module, the balance of
best practice meets real-world know-how will give you the
understanding you need to begin your career with confidence.
‘I love this book’
Liam Hislop, Full Sail Real World Education, Florida, USA
‘Game developers can learn a lot from this book’
Eric Le, Ubisoft, Canada
‘I would wholeheartedly recommend it to my students’
Paul Parry, Sheffield Hallam University, UK
• Practical OO design methodologies with examples from real commercial code.
• Design patterns that work in practice.
• Write reusable code that will be reused.
• Write games using component technology.
• Develop multi-platform games efficiently.
• Use iterative techniques in program and schedule development.
Julian Gold
Gold
"LMA Manager"™ 2002/2003/2004 is a trademark of Codemasters © The Codemasters
Software Company All other copyrights or trademarks appearing in the game are the property of
their respective owners.
Colony Wars Red Sun is the copyright of Sony Computer Entertainment Europe Limited.
Trang 2Object-oriented Game Development
Trang 3We work with leading authors to develop thestrongest educational materials in computing,bringing cutting-edge thinking and bestlearning practice to a global market.
Under a range of well-known imprints, includingAddison Wesley, we craft high-quality print andelectronic publications which help readers to understandand apply their content, whether studying or at work
To find out more about the complete range of ourpublishing, please visit us on the World Wide Web at:www.pearsoned.co.uk
Trang 4Julian Gold
Object-oriented
Game Development
Trang 5Pearson Education Limited Edinburgh Gate
Harlow Essex CM20 2JE England
and Associated Companies throughout the world
Visit us on the World Wide Web at:
www.pearsoned.co.uk
First published 2004
© Pearson Education Limited 2004
The right of Julian Gold to be identified as author of this work has been asserted
by him in accordance with the Copyright, Designs and Patents Act 1988.
All rights reserved; no part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise without either the prior written permission of the publisher or a licence permitting restricted copying in the United Kingdom issued by the Copyright Licensing Agency Ltd, 90 Tottenham Court Road, London W1T 4LP
The programs in this book have been included for their instructional value They have been tested with care but are not guaranteed for any particular purpose The publisher does not offer any warranties or representations nor does it accept any liabilities with respect to the programs.
All trademarks used herein are the property of their respective owners The use of any trademark in this text does not vest in the author or publisher any trademark ownership rights
in such trademarks, nor does the use of such trademarks imply any affiliation with or endorsement of this book by such owners.
ISBN 0 321 17660 X
British Library Cataloguing-in-Publication Data
A catalogue record for this book is available from the British Library.
Library of Congress Cataloging-in-Publication Data Gold, Julian.
Object-oriented game development / Julian Gold.
Trang 6To Sienna
Trang 93 Software engineering for games 23
3.3.2 Working practices for programmers 26
3.3.7 Dependencies: the curse of Hades 38
3.4.1 The four elements of object orientation 52
4.2.3 Phase 3: draw the bubbles and lines 73 4.2.4 Phase 4: validate the design 75
Trang 104.3.7 Prototype 108
5 The component model for game development 135
5.3.2 Keep data and their visual representations
logically and physically apart 140 5.3.3 Keep static and dynamic data separate 143 5.3.4 Avoid illogical dependencies 148
6.1.3 Same capability, different methodology 235 6.1.4 Platforms of different capability 251 6.1.5 Cross-platform component architecture 254
Trang 119.2.2 Internal and external milestones 353 9.2.3 The breaking wheel of progress 354
9.3.2 Ordering using priorities and levels 361 9.3.3 Scheduling with an iterated delivery system 365
Object-oriented game development
x
Trang 1210 Game development roles 367
10.2.3 Programming production phases 373
Trang 14Acknowledgements
The following bright and kind souls are implicated in the writing of this book.Sam Brown, Peter Bratcher, Adrian Hirst, Graeme Baird and Beverley Shaw
at Six By Nine Ltd – I pestered you with my ideas until you either agreed with
me, shot them down, or lost the will to argue back What else are friends for?Emma: you proofread this stuff and didn’t have a clue what you were read-
ing You corrected my overenthusiastic, dodgy English (sic), and fear of your
incorrect apostrophe wrath kept me on the straight and narrow Well, mostlyanyway! Thanks also for putting up with my antisocial hours of typing wheneating, drinking and not being grumpy were in order
Trang 161.1 What is this book?
There’s a better than 50% chance that you have picked this title off the shelf in
a bookshop and are wondering if it’s going to be another one of those ‘secrets of
the inner circle’ type of titles You know, the ones that promise to tell you
unspoken truths on how to write really cool games but in reality offer up a
rehash of a manual you may already have for free anyway I should know, I’ve
bought a few of them in the past, and if you haven’t experienced the
disap-pointment getting to the end and thinking ‘Is that it?’ I don’t recommend it I
certainly hope that this isn’t such a book, that it offers some useful insights that
you can’t really get from anywhere else, and that when you finish it you’re a
little wiser than you were
The goal of this book is to discuss a pragmatic approach to computer gamedevelopment It borrows some of the traditional philosophy of developers and
adds a smattering of software engineering principles, team-oriented processes,
project management and a dash of what passes for common sense around this
business Although there have been many fine books written on each of these
topics – some used as references for this title – to my knowledge this hasn’t been
done in the context of games before, certainly not in any great detail and with
any non-trivial technical content relating to a broad set of disciplines, so it is
my hope that this book has something unique to offer
I would hope to persuade and enlighten some of my audience to do things
as I would do them However, I also expect some or even all of you to take issue
with some of the things I discuss and solutions I present in the book I can’t put
forward hard and fast answers to either technical or management issues,
because if it was that easy to come up with them, we would all be doing it,
wouldn’t we? Rather, I intend to establish a few simple broad principles and
then present some solutions to the related problems which are ‘good enough’,
in that doing them is better than not doing them
1
Trang 17Object-oriented game development
2
1.2 But why?
Currently, as we begin the twenty-first century, commercial game development
is at a crossroads As I type this, three new game platforms are launching orqueuing up for launch in Europe: Sony’s PlayStation™2, Nintendo’sGameCube™ and Microsoft’s X-Box™ These consoles represent another quan-tum leap in gaming technology; irrespective of their actual abilities, both theexpectations of the public and the corporate hype that will fuel them will leavethe world asking for ever prettier, ever more complex, ever more involved andsubtle or realistic gaming experiences
This would be manageable if the timescales of projects could grow to matchtheir scope In an industry where working overtime is already normal hours,there soon will be a need to redefine the day as thirty hours if games are to bedelivered on time and on budget without disappointing the increasingly partic-ular public
How can we square this circle? Clearly adding more hours to the day isn’tgoing to happen, so we shall need to fall back on the usual management consul-tant cliché of working smarter, not harder
This book describes, in short, ways of working smarter so that we can continue
to excel, push our technological envelopes and manage the growing complexity ofdeveloping gobsmacking entertainment titles for the next-generation platforms
1.3 Who am I?
I have spent the past ten years working in the games industry for both smalland big players Prior to that, I have a strong academic mathematical back-ground with a BSc in astronomy I spent a few years writing image-processingsoftware in FORTRAN for the Royal Greenwich Observatory in England, beforestarting in the video games business in 1993 Having experienced developmentfor PC and a plethora of consoles as a programmer and then a lead programmer,
it is my somewhat counterintuitive experience that the same – or at least similar– mistakes are made, irrespective of company size or financial security This
strongly suggests that it is the process that needs attention rather than the
acqui-sition of staff or other resources
1.4 Who are you?
This book is intended for game programmers, though it is not exclusively aboutprogramming This is simply because game development today is a synthesis ofseveral disciplines:
Trang 18● programming
● art
● design
● music
Not to mention the management of all of these
It’s a programmer’s daily job to liaise not only with other programmers butalso with those in the other disciplines In short, very little that any one indi-
vidual does in the course of development happens in isolation, so it would be a
mistake to consider programming without specific reference to the other
prac-tices For brevity, but with little loss of generality, I’ll stick to the holy trinity of
programming, art and design in this book
So, you’re a programmer Or you manage programmers Or you simply workwith programmers on a day-to-day basis: a producer, perhaps You are probably
working in a team and almost certainly in a commercial environment Whilst
it’s great fun to develop software in leisure time with your friends – and this
book will still hopefully prove of some use if you are doing so – many of the
philosophies and practices that we’ll examine arise because of the way that
commercial pressures affect the development process Similarly, if you are the
sole programmer/artist/designer/musician/teaperson, then you are not the
direct target but you may still gain benefit from a read through the book
1.5 So what will you read about?
This book’s content can be divided into two main areas The first will concern
the major issues (as I see them) involved in the commercial game development
process This will be done at a level that is abstract enough to be generally
useful but pragmatic enough to be applicable to a real-world situation In fact, it
is intended that the content remains as abstract as possible, since there is no
way I can know the specific technical problems you will need to solve
The second area is game programming, or rather game software engineering
I’ll talk about choice of language for development and the implications of this
choice I’ll also look at the high-level design process and how it translates to source
code I’ll discuss a way to analyse and approach cross-platform development And
finally we’ll start applying the results to develop some specific game systems
If you’re a lead programmer or a technical producer, you’ll probably want toconcentrate on the process sections If you’re a programmer aspiring to senior or
lead roles, you’ll probably find the other sections focusing on development
more useful But feel free to pick and choose, as they can be read in isolation
with a minimal amount of cross-referencing
So without further ado, let’s start
Trang 191.6 A brief history of games
Though it is beyond the scope of this book to provide a detailed history of puter games, it is well worth looking back to review some of their evolution,and particularly to look at how development methodologies have changed overtime and who is developing them
com-1.6.1 The time that land forgotComputer games are older than many people may think Indeed, games such aschess and checkers have occupied (and continue to occupy) the efforts of manyacademic and corporate researchers worldwide (In fact, if there is a game played
by humans, then there is almost certainly a computer equivalent.) The ment of such gaming technology probably goes back to the 1950s, whenelectronic computers – more often than not the playthings of the military, whowanted them for ballistics calculations and such like – were becoming available
develop-to civilian educational establishments and commercial enterprises SamuelJackson’s checkers algorithm is a prime example of the progress of softwaretechnology driven by games Written around 1956, it is optimal in that if it canwin from a given situation, then it will Checkers is one of the few games that isconsidered ‘solved’
More surprisingly, the first graphical video game appeared in 1958, whenWilliam Higinbotham, a researcher at the Brookhaven National Laboratory inNew York, used a vacuum tube system to produce a very simple tennis gamewith a small blob for a ball and an inverted ‘T’ for a net Being entirely hard-ware-based, the game was lost for ever when the system was dismantled a fewyears later
Typically, the development of gaming technology remained a broadly emic discipline, since hardware was grotesquely large and just as expensive andunreliable Indeed, it would remain so until the 1970s, when the mass produc-tion of semiconductors became feasibly cheap
acad-If the hardware was impractical and unreliable, then the accompanyingsoftware was equally so Computer languages have evolved from literally settingbinary switches or wiring plug boards, to punched cards, to having a program –
be it a compiler, assembler or interpreter – that can translate near-English textinto the required binary instructions Until relatively recently, programmingwas done at a binary or near-binary level, which made the development of com-plex algorithms and systems painstaking, time-consuming and error-prone
In 1962, Steve Russell, a researcher at the Hingham Institute in Cambridge,Massachusetts, came up with Spacewar, a two-player game featuring missile-firing spaceships (see Figure 1.1)
Object-oriented game development
4