2D graphics programming for games 1st Edition John Pile Jr. 2024 scribd download
2D graphics programming for games 1st Edition John Pile Jr. 2024 scribd download
com
https://ebookname.com/product/2d-graphics-programming-for-
games-1st-edition-john-pile-jr/
OR CLICK BUTTON
DOWNLOAD EBOOK
https://ebookname.com/product/mathematics-for-3d-game-programming-
computer-graphics-1st-edition-eric-lengyel/
ebookname.com
https://ebookname.com/product/game-graphics-programming-1st-edition-
allen-allen-sherrod-sherrod/
ebookname.com
https://ebookname.com/product/fundamental-2d-game-programming-with-
java-1st-edition-timothy-m-wright/
ebookname.com
https://ebookname.com/product/cash-games-how-to-win-at-no-limit-hold-
em-money-games-vol-1-1st-edition-dan-harrington/
ebookname.com
Introduction to VLSI Circuits and Systems 1st Edition John
P. Uyemura
https://ebookname.com/product/introduction-to-vlsi-circuits-and-
systems-1st-edition-john-p-uyemura/
ebookname.com
https://ebookname.com/product/god-fearing-and-free-1st-edition-jason-
w-stevens/
ebookname.com
https://ebookname.com/product/a-first-course-in-general-
relativity-2nd-edition-bernard-f-schutz/
ebookname.com
https://ebookname.com/product/becoming-evil-how-ordinary-people-
commit-genocide-and-mass-killing-2nd-edition-james-e-waller/
ebookname.com
https://ebookname.com/product/un-tied-nations-the-united-nations-
peacekeeping-and-global-governance-kate-seaman/
ebookname.com
The Geography of the Internet Industry Venture Capital Dot
coms and Local Knowledge Information Age Series 1st
Edition Matthew Zook
https://ebookname.com/product/the-geography-of-the-internet-industry-
venture-capital-dot-coms-and-local-knowledge-information-age-
series-1st-edition-matthew-zook/
ebookname.com
Pile
Computer Graphics
2D Graphics
for Games
author presents examples not only from video games but also from art and
animated film.
The book helps you learn the concepts and techniques used to produce
appealing 2D graphics. It starts with the basics and then covers topics
pertaining to motion and depth, such as cel animation, tiling, and layering. The
text also describes advanced graphics, including the use of particle systems,
shaders, and splines. Code samples in the text and online allow you to see
a particular line of code in action or as it relates to the code around it. In
addition, challenges and suggested projects encourage you to work through
problems, experiment with solutions, and tinker with code.
Full of practical tools and tricks, this color book gives you in-depth guidance
on making professional, high-quality graphics for games. It also improves
your relationship with game artists by explaining how certain art and design
challenges can be solved with a programmatic solution.
Features
• Shows how the core concepts of graphics programming are the
same regardless of platform
• Helps you communicate effectively with game artists and designers
• Provides code samples in C# and XNA, with more samples in C++,
OpenGL, DirectX, and Flash available on a supporting website
K14405
John Pile Jr
ISBN: 978-1-4665-0189-8
90000
9 781466 501898
for PC, Mac, iPhone / iPad,
Android, and Xbox 360
John Pile Jr
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742
This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to publish reliable data and information, but
the author and publisher cannot assume responsibility for the validity of all materials or the consequences of their use. The authors and publishers have attempted to
trace the copyright holders of all material reproduced in this publication and apologize to copyright holders if permission to publish in this form has not been obtained.
If any copyright material has not been acknowledged please write and let us know so we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in any form by any electronic, mechanical,
or other means, now known or hereafter invented, including photocopying, microfilming, and recording, or in any information storage or retrieval system, without
written permission from the publishers.
For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://www.copyright.com/) or contact the Copyright
Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a
variety of users. For organizations that have been granted a photocopy license by the CCC, a separate system of payment has been arranged.
Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for identification and explanation without intent to
infringe.
Preface xi
Acknowledgments xiii
I Getting Started in 2D 1
1 Introduction 3
1.1 About This Book . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Why C# and XNA? . . . . . . . . . . . . . . . . . . . . . 5
1.3 Game Development 101 . . . . . . . . . . . . . . . . . . . 8
1.4 Game Developer Platforms . . . . . . . . . . . . . . . . . 9
1.5 Book Organization . . . . . . . . . . . . . . . . . . . . . . 12
3 Sprites! 37
3.1 What Is a Sprite? . . . . . . . . . . . . . . . . . . . . . . . 37
3.2 Layering with Depth . . . . . . . . . . . . . . . . . . . . . 45
3.3 The Sprite Sheet and the GPU . . . . . . . . . . . . . . . 47
3.4 Scaling Sprites . . . . . . . . . . . . . . . . . . . . . . . . 49
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
vii
viii Contents
4 Animation 57
4.1 Historical Animation . . . . . . . . . . . . . . . . . . . . . 57
4.2 Cel Animation . . . . . . . . . . . . . . . . . . . . . . . . 59
4.3 A Few Principles of Animation . . . . . . . . . . . . . . . 62
4.4 Animation Cycles . . . . . . . . . . . . . . . . . . . . . . . 69
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
IV Appendices 199
Bibliography 217
Glossary 219
Index 223
Preface
xi
Acknowledgments
xiii
xiv Acknowledgments
1. Let everything used for the purpose be delicately clean and dry;
bottles especially so.
2. Never place a preserving-pan flat upon the fire, as this will
render the preserve liable to burn to, as it is called; that is to say, to
adhere closely to the metal, and then to burn; it should rest always
on a trivet (that shown with the French furnace is very convenient
even for a common grate), or on the lowered bar of a kitchen range
when there is no regular preserving stove in a house.
3. After the sugar is added to them, stir the preserves gently at
first, and more quickly towards the end, without quitting them until
they are done: this precaution will always prevent the chance of their
being spoiled.
4. All preserves should be perfectly cleared from the scum as it
rises.
5. Fruit which is to be preserved in syrup must first be blanched or
boiled gently, until it is sufficiently softened to absorb the sugar; and
a thin syrup must be poured on it at first, or it will shrivel instead of
remaining plump, and becoming clear. Thus, if its weight of sugar is
to be allowed, and boiled to a syrup with a pint of water to the pound,
only half the weight must be taken at first, and this must not be
boiled with the water more than fifteen or twenty minutes at the
commencement of the process; a part of the remaining sugar must
be added every time the syrup is reboiled, unless it should be
otherwise directed in the receipt.
6. To preserve both the true flavour and the colour of fruit in jams
and jellies, boil them rapidly until they are well reduced, before the
sugar is added, and quickly afterwards, but do not allow them to
become so much thickened that the sugar will not dissolve in them
easily, and throw up its scum. In some seasons, the juice is so much
richer than in others, that this effect takes place almost before one is
aware of it; but the drop which adheres to the skimmer when it is
held up, will show the state it has reached.
7. Never use tin, iron, or pewter spoons, or skimmers, for
preserves, as they will convert the colour of red fruit into a dingy
purple, and impart, besides, a very unpleasant flavour.
8. When cheap jams or jellies are required, make them at once
with Lisbon sugar, but use that which is well refined always, for
preserves in general; it is a false economy, as we have elsewhere
observed, to purchase an inferior kind, as there is great waste from it
in the quantity of scum which it throws up. The best has been used
for all the receipts given here.
9. Let fruit for preserving be gathered always in perfectly dry
weather, and be free both from the morning and evening dew, and as
much so as possible from dust. When bottled, it must be steamed or
baked during the day on which it is gathered, or there will be a great
loss from the bursting of the bottles; and for jams and jellies it cannot
be too soon boiled down after it is taken from the trees.
TO EXTRACT THE JUICE OF PLUMS FOR JELLY.
Take the stalks from the fruit, and throw aside all that is not
perfectly sound: put it into very clean, large stone jars, and give part
of the harder kinds, such as bullaces and damson, a gash with a
knife as they are thrown in; do this especially in filling the upper part
of the jars. Tie one or two folds of thick paper over them, and set
them for the night into an oven from which the bread has been drawn
four or five hours; or cover them with bladder, instead of paper, place
them in pans, or in a copper[166] with water which will reach to quite
two-thirds of their height, and boil them gently from two to three
hours, or until the fruit is quite soft, and has yielded all the juice it will
afford: this last is the safer and better mode for jellies of delicate
colour.
166. The fruit steams perfectly in this, if the cover be placed over.
TO WEIGH THE JUICE OF FRUIT.
Put a basin into one scale, and its weight into the other; add to this
last the weight which is required of the juice, and pour into the basin
as much as will balance the scales. It is always better to weigh than
to measure the juice for preserving, as it can generally be done with
more exactness.
RHUBARB JAM.
The small rough red gooseberry, when fully ripe, is the best for this
preserve, which may, however, be made of the larger kinds. When
the tops and stalks have been taken carefully from the fruit, weigh,
and boil it quickly for three-quarters of an hour, keeping it well stirred;
then for six pounds of the gooseberries, add two and a half of good
roughly-powdered sugar; boil these together briskly, from twenty to
twenty-five minutes and stir the jam well from the bottom of the pan,
as it is liable to burn if this be neglected.
Small red gooseberries, 6 lbs.: 3/4 hour. Pounded sugar, 2-1/2
lbs.: 20 to 25 minutes.
VERY FINE GOOSEBERRY JAM.
Seed the fruit, which for this jam may be of the larger kind of rough
red gooseberry: those which are smooth skinned are generally of far
inferior flavour. Add the pulp which has been scooped from the
prepared fruit to some whole gooseberries, and stir them over a
moderate fire for some minutes to extract the juice; strain and weigh
this; pour two pounds of it to four of the seeded gooseberries, boil
them rather gently for twenty-five minutes, add fourteen ounces of
good pounded sugar to each pound of fruit and juice, and when it is
dissolved boil the preserve from twelve to fifteen minutes longer, and
skim it well during the time.
Seeded gooseberries, 4 lbs.; juice of gooseberries, 2 lbs.: 25
minutes. Sugar, 5-1/4 lbs. (or 14 oz. to each pound of fruit and juice):
12 to 15 minutes.
JELLY OF RIPE GOOSEBERRIES.
(Excellent.)
Take the tops and stalks from a gallon or more of any kind of well-
flavoured ripe red gooseberries, and keep them stirred gently over a
clear fire until they have yielded all their juice, which should then be
poured off without pressing the fruit, and passed first through a fine
sieve, and afterwards through a double muslin-strainer, or a jelly-
bag. Next weigh it, and to every three pounds add one of white
currant juice, which has previously been prepared in the same way;
boil these quickly for a quarter of an hour, then draw them from the
fire and stir to them half their weight of good sugar; when this is
dissolved, boil the jelly for six minutes longer, skim it thoroughly, and
pour it into jars or moulds. If a very large quantity be made, a few
minutes of additional boiling must be given to it before the sugar is
added.
Juice of red gooseberries, 3 lbs.; juice of white currants, 1 lb.: 15
minutes. Sugar, 2 lbs.: 6 minutes.
Obs.—The same proportion of red currant juice, mixed with that of
the gooseberries, makes an exceedingly nice jelly.
UNMIXED GOOSEBERRY JELLY.
Boil rapidly for ten minutes four pounds of the juice of red
gooseberries, prepared as in the preceding receipt; take it from the
fire, and stir in it until dissolved three pounds of sugar beaten to
powder; boil it again for five minutes, keeping it constantly stirred
and thoroughly skimmed.
Juice of red gooseberries, 4 lbs.: 10 minutes. Sugar, 3 lbs.: 5
minutes.
GOOSEBERRY PASTE.
Press through a sieve the gooseberries from which the juice has
been taken for jelly, without having been drained very closely from
them; weigh and then boil the pulp for upwards of an hour and a
quarter, or until it forms a dry paste in the pan; stir to it, off the fire,
six ounces of good pounded sugar for each pound of the fruit, and
when this is nearly dissolved boil the preserve from twenty to twenty-
five minutes, keeping it stirred without cessation, as it will be liable to
burn should this be neglected. Put it into moulds, or shallow pans,
and turn it out when wanted for table.
Pulp of gooseberries, 4 lbs.: 1-1/4 to 1-3/4 hour. Sugar, 1-1/2 lb.:
20 to 25 minutes.
TO DRY RIPE GOOSEBERRIES WITH SUGAR.
Cut the tops, but not the stalks, from some ripe gooseberries of
the largest size, either red or green ones, and after having taken out
the seeds as directed for unripe gooseberries, boil the fruit until clear
and tender, in syrup made with a pound of sugar to the pint of water,
boiled until rather thick.
Seeded gooseberries, 2 lbs.; sugar, 1-1/2 lb.; water, 1 pint: boiled
to syrup. Gooseberries, simmered 8 to 12 minutes, or more.
Obs.—Large ripe gooseberries freed from the blossoms, and put
into cold syrup in which cherries or any other fruit has been boiled for
drying, then heated very gradually, and kept at the point of boiling for
a few minutes before they are set by for a couple of days, answer
extremely well as a dry preserve. On the third day the syrup should
be drained from them, simmered, skimmed, and poured on them the
instant it is taken from the fire; in forty-eight hours after, they may be
drained from it and laid singly upon plates or dishes, and placed in a
gentle stove.
JAM OF KENTISH OR FLEMISH CHERRIES.
(Superior Receipt.)
To each pound of cherries weighed after they are stoned, add
eight ounces of good sugar, and boil them very softly for ten minutes:
pour them into a large bowl or pan, and leave them for two days in
the syrup; then simmer them again for ten minutes, and set them by
in it for two or three days; drain them slightly, and dry them very
slowly, as directed in the previous receipts. Keep them in jars or tin
canisters, when done. These cherries are generally preferred to such
as are dried with a larger proportion of sugar; but when the taste is in
favour of the latter, from twelve to sixteen ounces can be allowed to
the pound of fruit, which may then be potted in the syrup and dried at
any time; though we think the flavour of the cherries is better
preserved when this is done within a fortnight of their being boiled.
Cherries, stoned, 8 lbs.; sugar, 4 lbs.: 10 minutes. Left two or three
days. Boiled again, 10 minutes; left two days; drained and dried.
CHERRIES DRIED WITHOUT SUGAR.
Take off the stalks but do not stone the fruit; weigh and add to it an
equal quantity of the best sugar reduced quite to powder, strew it
over the cherries and let them stand for half an hour; then turn them
gently into a preserving-pan, and simmer them softly from five to
seven minutes. Drain them from the syrup, and dry them like the
Kentish cherries. They make a very fine confection.