PDF Learning C by Developing Games With Unity 2020 An Enjoyable and Intuitive Approach To Getting Started With C Programming and Unity Fifth Edition Harrison Ferrone Ebook Full Chapter
PDF Learning C by Developing Games With Unity 2020 An Enjoyable and Intuitive Approach To Getting Started With C Programming and Unity Fifth Edition Harrison Ferrone Ebook Full Chapter
PDF Learning C by Developing Games With Unity 2020 An Enjoyable and Intuitive Approach To Getting Started With C Programming and Unity Fifth Edition Harrison Ferrone Ebook Full Chapter
https://textbookfull.com/product/learning-c-7-by-developing-
games-with-unity-2017-learn-c-programming-by-building-fun-and-
interactive-games-with-unity-third-edition-micael-dagraca/
https://textbookfull.com/product/developing-2d-games-with-unity-
independent-game-programming-with-c-1st-edition-jared-halpern/
https://textbookfull.com/product/developing-2d-games-with-unity-
independent-game-programming-with-c-1st-edition-jared-halpern-2/
https://textbookfull.com/product/learning-c-programming-with-
unity-3d-alex-okita/
Learning C by Developing Games with Unity 5 x Develop
your first interactive 2D platformer game by learning
the fundamentals of C Second Edition Greg Lukosek
https://textbookfull.com/product/learning-c-by-developing-games-
with-unity-5-x-develop-your-first-interactive-2d-platformer-game-
by-learning-the-fundamentals-of-c-second-edition-greg-lukosek/
https://textbookfull.com/product/learning-c-by-developing-games-
with-unity-5-x-develop-your-first-interactive-2d-platformer-game-
by-learning-the-fundamentals-of-c-second-edition-greg-lukosek-2/
https://textbookfull.com/product/programming-with-stm32-getting-
started-with-the-nucleo-board-and-c-c-donald-norris/
https://textbookfull.com/product/getting-started-with-
unity-2018-a-beginner-s-guide-to-2d-and-3d-game-development-with-
unity-3rd-edition-edward-lavieri/
https://textbookfull.com/product/mastering-ui-development-with-
unity-an-in-depth-guide-to-developing-engaging-user-interfaces-
with-unity-5-unity-2017-and-unity-2018-1st-edition-ashley-
Learning C# by Developing
Games with Unity 2020
Fifth Edition
Harrison Ferrone
BIRMINGHAM - MUMBAI
Learning C# by Developing Games with
Unity 2020
Fifth Edition
Copyright © 2020 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form
or by any means, without the prior written permission of the publisher, except in the case of brief quotations
embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented.
However, the information contained in this book is sold without warranty, either express or implied. Neither the
author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to
have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products
mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy
of this information.
ISBN 978-1-80020-780-6
www.packt.com
"If people reach perfection they vanish, you know."
Subscribe to our online digital library for full access to over 7,000 books and videos, as well
as industry leading tools to help you plan your personal development and advance your
career. For more information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks and Videos
from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Did you know that Packt offers eBook versions of every book published, with PDF and
ePub files available? You can upgrade to the eBook version at www.packt.com and as a print
book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
[email protected] for more details.
At www.packt.com, you can also read a collection of free technical articles, sign up for a
range of free newsletters, and receive exclusive discounts and offers on Packt books and
eBooks.
Contributors
He holds various fancy looking pieces of paper from the University of Colorado at Boulder
and Columbia College, Chicago. Despite being a proud alumnus, most of these are stored
in a basement somewhere.
After a few years as an iOS developer at small start-ups, and one Fortune 500 company, he
fell into a teaching career and never looked back. Throughout all this, he's bought many
books, acquired a few cats, worked abroad, and continually wondered why Neuromancer
isn't on more course syllabi.
Completing this book wouldn't have been possible without the support of Kelsey, my
partner in crime on this journey, and Wilbur, Merlin, Walter, and Evey for their
courageous spirits and gracious hearts.
About the reviewers
Andrew Edmonds is an experienced programmer, game developer, and educator. He has a
Bachelor of Science degree in Computer Science from Washburn University and is a Unity
Certified Programmer and Instructor. After college, he worked as a software engineer for
the Kansas State Legislature for three years before spending the next five years teaching
high school kids how to write code and make video games. As a teacher, he helped many
young aspiring game developers achieve beyond what they ever thought possible,
including winning the SkillsUSA National Championship for video game development in
2019 with a virtual reality game made in Unity. Andrew lives in Washington with his wife,
Jessica, and daughters, Alice and Ada.
Adam Brzozowski is an experienced software engineer who develops games and client
applications. Working with Unity, Unreal Engine, C++, Swift, and Java, he finds the right
solution for each project.
[ ii ]
Table of Contents
Summary 78
Pop quiz – variables and methods 78
Chapter 4: Control Flow and Collection Types 79
Selection statements 80
The if-else statement 80
Basic syntax 80
Time for action – thieving prospects 83
Using the NOT operator 85
Nesting statements 86
Evaluating multiple conditions 87
Time for action – reaching the treasure 88
The switch statement 90
Basic syntax 90
Pattern matching 91
Time for action – choosing an action 91
Fall-through cases 92
Time for action – rolling the dice 92
Pop quiz 1 – if, and, or but 94
Collections at a glance 94
Arrays 94
Basic syntax 95
Indexing and subscripts 96
Range exceptions 96
Lists 97
Basic syntax 97
Time for action – party members 98
Common methods 99
Dictionaries 100
Basic syntax 100
Time for action – setting up an inventory 101
Working with dictionary pairs 102
Pop quiz 2 – all about collections 103
Iteration statements 103
For loops 104
Time for action – finding an element 105
foreach loops 107
Looping through key-value pairs 108
Hero's trial – finding affordable items 109
while loops 109
Time for action – tracking player lives 110
To infinity and beyond 111
Summary 112
Chapter 5: Working with Classes, Structs, and OOP 113
Defining a class 114
Basic syntax 114
Time for action – creating a character class 114
Instantiating class objects 115
[ iii ]
Table of Contents
[ iv ]
Table of Contents
[v]
Table of Contents
[ vi ]
Table of Contents
[ vii ]
Table of Contents
[ viii ]
Preface
Unity is one of the most popular game engines in the world, catering to amateur hobbyists,
professional AAA studios, and cinematic production houses. While mainly considered a 3D
tool, Unity has a host of dedicated features that support everything from 2D games and
virtual reality to post-production and cross-platform publishing.
Developers love its drag-and-drop interface and built-in features, but it's the ability to write
custom C# scripts for behaviors and game mechanics that really take Unity the extra mile.
Learning to write C# code might not be a huge obstacle to a seasoned programmer with
other languages under their belt, but it can be daunting for those of you who have no
programming experience. That's where this book comes in, as I'll be taking you through the
building blocks of programming and the C# language from scratch, all while building a fun
and playable game in Unity.
Chapter 2, The Building Blocks of Programming, begins by laying out the atomic-level
concepts of programming, giving you the opportunity to relate variables, methods, and
classes to situations in everyday life. From there, we move on to simple debugging
techniques, proper formatting and commenting, and a look at how Unity turns C# scripts
into components.
Preface
Chapter 3, Diving into Variables, Types, and Methods, takes a deeper look at variables. This
includes C# data types, naming conventions, access modifiers, and everything else
you'll need for the foundation of a program. We'll also go over how to write methods,
incorporate parameters, and use return types effectively, ending with an overview of
standard Unity methods belonging to the MonoBehavior class.
Chapter 4, Control Flow and Collection Types, introduces the common approaches to making
decisions in code, consisting of the if...else and switch statements. From there, we
move on to working with arrays, lists, and dictionaries, and incorporating iteration
statements for looping through collection types. We end the chapter with a look at
conditional looping statements and a special C# data type called enumerations.
Chapter 5, Working with Classes, Structs, and OOP, details our first contact with constructing
and instantiating classes and structs. We'll go through the basic steps of creating
constructors, adding variables and methods, and the fundamentals of subclassing and
inheritance. The chapter will end with a comprehensive explanation of object-oriented
programming and how it applies to C#.
Chapter 6, Getting Your Hands Dirty with Unity, marks our departure from C# syntax into
the world of game design, level building, and Unity's featured tools. We'll start by going
over the basics of a game design document and then move on to blocking out our level
geometry and adding lighting and a simple particle system.
Chapter 8, Scripting Game Mechanics, introduces the concept of game mechanics and how to
effectively implement them. We'll start by adding a simple jump action, create a shooting
mechanic, and build on the previous chapters' code by adding logic to handle item
collection.
Chapter 9, Basic AI and Enemy Behavior, starts with a brief overview of artificial intelligence
in games and the concepts we will be applying to Hero Born. Topics covered in this chapter
will include navigation in Unity, using the level geometry and a navigation mesh, smart
agents, and automated enemy movement.
Chapter 10, Revisiting Types, Methods, and Classes, takes a more in-depth look at data types,
intermediate method features, and additional behaviors that can be used for more complex
classes. This chapter will give you a deeper understanding of the versatility and breadth of
the C# language.
[2]
Preface
Chapter 11, Introducing Stacks, Queues, and HashSets, dives into intermediate collection
types and their features. Topics covered in this chapter include using Stacks, Queues, and
HashSets and the different development scenarios that each is uniquely suited for.
Chapter 12, Exploring Generics, Delegates, and Beyond, details intermediate features of the C#
language and how to apply them in practical, real-world scenarios. We'll start with an
overview of generic programming and progress to concepts such as delegation, events, and
exception handling. The chapter will end with a brief discussion of common design
patterns and set you up for further study.
Chapter 13, The Journey Continues, reviews the main topics you've learned throughout the
book and leaves you with resources for further study in both C# and Unity. Included in
these resources will be online reading material, certification information, and a host of my
favorite video tutorial channels.
You'll also need a current version of Unity installed on your computer – 2020 or later is
recommended. All code examples have been tested with Unity 2020.1 and should work
with future versions without issues.
Before starting, check that your computer setup meets the Unity system requirements
at https://docs.unity3d.com/2019.1/Documentation/Manual/system-requirements.
html. These are for Unity 2019 but hold true for 2020 and above.
[3]
Preface
Once the file is downloaded, please make sure that you unzip or extract the folder using the
latest version of:
The code bundle for the book is also hosted on GitHub at https://github.com/
PacktPublishing/Learning-C-8-by-Developing-Games-with-Unity-2020. In case there's
an update to the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available
at https://github.com/PacktPublishing/. Check them out!
Conventions used
There are a number of text conventions used throughout this book.
CodeInText: Indicates code words in the text, database table names, folder names,
filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here
is an example: "Select the Materials folder."
[4]
Preface
When we wish to draw your attention to a particular part of a code block, the relevant lines
or items are set in bold:
accessModifier returnType UniqueName(parameterType parameterName) {
method body
}
Bold: Indicates a new term, an important word, or words that you see on screen. For
example, words in menus or dialog boxes appear in the text like this. Here is an example:
"Click on Create | 3D Object | Capsule from the Hierarchy panel."
Get in touch
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, mention the book
title in the subject of your message and email us at [email protected].
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you have found a mistake in this book, we would be grateful if you would
report this to us. Please visit www.packtpub.com/support/errata, selecting your book,
clicking on the Errata Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the internet, we
would be grateful if you would provide us with the location address or website name.
Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in,
and you are interested in either writing or contributing to a book, please visit
authors.packtpub.com.
[5]
Preface
Reviews
Please leave a review. Once you have read and used this book, why not leave a review on
the site that you purchased it from? Potential readers can then see and use your unbiased
opinion to make purchase decisions, we at Packt can understand what you think about our
products, and our authors can see your feedback on their book. Thank you!
[6]
1
Getting to Know Your
Environment
Pop culture has taught us that computer programmers are often outsiders, lone wolves, or
geeky hackers who possess extraordinary mental gifts for algorithmic thought, little social
IQ, and the odd anarchic bent. While this is not the case, there is something to the idea that
learning to code fundamentally changes the way you look at the world. The good news is
that your naturally curious mind will quickly adapt to this new way of thinking and may
even come to enjoy it.
You already use analytical skills in your everyday life that translate to programming –
you're just missing the right language and syntax to map those life skills into code. You
know your age, right? That's a variable. When you cross the street, I presume you look
down the road in both directions before stepping off the curb like the rest of us. That's
evaluating different conditions, or what we call control flow in programming parlance.
When you look at a can of pop, you instinctively identify that it has certain properties such
as shape, weight, and contents. That's a class object! You get the idea.
Getting to Know Your Environment Chapter 1
With all that real-world experience at your fingertips, you're more than ready to cross over
into the realm of programming. You'll need to know how to set up your development
environment, work with the applications involved, and know exactly where to go when
you need help. To that end, we're going to begin our adventure delving into C# by covering
the following topics:
Technical requirements
Sometimes, it's easier to start with what a thing isn't, rather than what it is. The main goal
of this book isn't to learn the vast ins and outs of the Unity game engine or all of game
development. By necessity, we'll cover these topics at a basic level here at the beginning of
our journey, and in more detail in Chapter 6, Getting Your Hands Dirty with
Unity. However, these topics are simply to provide a fun, accessible way for us to learn the
C# programming language from the ground up.
Since this book is aimed at complete beginners to programming, if you have no previous
experience with either C# or Unity, you're in the right place! If you've had some experience
with the Unity Editor but not with programming, guess what? This is still the place to be.
Even if you've dabbled in a bit of C# mixed with Unity, but want to explore some more
intermediate or advanced topics, the later chapters of this book can provide you with what
you're looking for.
[8]
Getting to Know Your Environment Chapter 1
If the Unity home page looks different for you than what you can see in
the preceding screenshot, you can go directly to https://store.unity.
com.
Don't feel overwhelmed by this – you can get Unity completely free!
[9]
Getting to Know Your Environment Chapter 1
3. Click the Individual tab and select the Personal option on the left. The other paid
options offer more advanced functionality and services subscribers, but you can
check these out on your own:
After selecting the personal plan, you'll be asked if you're a first-time or returning user.
[ 10 ]
Getting to Know Your Environment Chapter 1
[ 11 ]
Getting to Know Your Environment Chapter 1
The newest version of Unity Hub has a wizard or getting started path
when you first open the application. If you'd like to follow that, feel free.
The following steps show you how to start a new project without any help
from the application since that's only available on the first launch.
4. With Unity Hub open, switch to the Installs tab from the left-hand menu and
select ADD:
[ 12 ]
Getting to Know Your Environment Chapter 1
At the time of writing, Unity 2020 is still in its Alpha phase, but you should be able to select
a 2020 version from the Latest Official Releases list:
[ 13 ]
Getting to Know Your Environment Chapter 1
You won't need any specific platform modules to follow along with future examples, so go
ahead and leave this as-is. If you do want to add them at any time, you can click the
More button (three-dot icon) at the upper right of any version in the Installs window:
When the installation is complete, you'll see a new version in your Installs panel, as
follows:
[ 14 ]
Another random document with
no related content on Scribd:
a pair of sharp eyes protrude, and short legs carry his wobbly body
about. Is it not only natural that everyone of the household will make
much over him, if they are normal human beings? It will be noted
that even though this bit of dog flesh is still less than twelve weeks
old, how readily he will make up with them. A young puppy, still
unaccustomed to the rebuffs of the world and the “slings and arrows”
of canine fortune has confidence in all whom he encounters. His
perceptions are keen, however, and he will soon learn that there are
some or at least one in the family to whom he may attach himself as
his real master or mistress, and therefore this should be the person
to teach him his early knowledge of household etiquette. It should be
this person, also, who imposes upon himself or herself the duty of
feeding the puppy. Of course this is not entirely essential, but if it is
left to one person, it may be generally taken for granted that the
youngster will be fed regularly and not too much. When the entire
household looks after the feeding, the chances are that he will be too
well cared for, and too frequent feeding is one of the banes of dog-
keeping. An overabundance of food is more dangerous than too
little, although I am no advocate of the starvation plan.
The matter of feeding will be taken up in the next chapter, so let us
pass on to the puppy’s early education. In the first place, if a
secluded nook has been decided upon where he is to sleep nights,
he should be introduced to this the very first night. To begin by
pampering him is only deferring a duty that must be done sooner or
later. Assuming that he has a basket or box in the kitchen, the last
thing before he is put to bed, it is well to feed him. At this early stage
the last feed in the evening may consist of milk and bread, or any of
the puppy meals with milk poured over. Put him in his bed, turn out
the lights and leave him. The chances are that he will not remain in
his bed, but come out and go near the door communicating with the
other apartments of the house, and whine. Go to him, chide him and
put him back in his bed, commanding him to lie down. This, of
course, he will not understand at once and it is quite likely that for
the first three or four nights he will make life hideous by his howling.
However, it is surprising how soon he will learn that he must make
the best of a new condition, for to him it is an entirely new situation in
life. Coming from his litter mates in a home where he has been
accustomed to the association of his mother, his brothers and
sisters, it is quite natural that the nostalgia, or homesickness, should
oppress him. Be firm, however, and make him “stay put” not only the
first night, but every night and he will soon be broken of the night
howling.
All dogs are naturally cleanly in their habits and it will be noticed that
even very young puppies will go some distance away from their
nests to obey the call of nature, consequently when the puppy is
brought into the home, correct habits may soon be taught. The
principal care is to catch him in the act and then remove him
summarily from the house. If he persists, a very slight tap or two and
a word of reprimand as he is being banished may assist quite
materially in making him understand. Some breeds are more easily
broken than others. I have found Airedales and cocker spaniels very
easy to break of uncleanly habits. Pointers and setters require more
time, but on the whole, most of the medium-sized breeds can be
broken very readily. The new owner should not lose sight of the fact,
however, that he must not be too severe. Firmness and prompt
action are the principal requisites that must be kept in mind in
breaking a puppy, but brutality never succeeds.
One of the earliest lessons that any young dog should be taught is
his name. This should be chosen as early as possible and whenever
the attention of the puppy is to be attracted, he should be called by
his name. All puppies will come to most anyone who will play with
them. On such occasions it is well to give the youngster his first
lessons. Call him to you, using the name you have selected. If he
comes to you, pet and fondle him, repeating the name meanwhile,
and reward him with a choice morsel to eat. Thus, in a very short
time the dog will learn to come promptly when called. Teaching to
whistle may be done in much the same manner, either in a large
room or in a yard. Blow the whistle when he is some distance from
you and call his name immediately after. He will be attracted, but will
come at the sound of his name and not the whistle. By frequent
repetition, however, he will soon learn to associate the blast of the
whistle with the verbal command and come to you promptly,
especially if at first he is rewarded with the ever-present choice
morsel.
If your dog happens to be a spaniel or one to be used as a sporting
companion, retrieving is an accomplishment which is a very excellent
one. Any dog will run after a ball if it is thrown from him after his
attention is first attracted. If one begins when the pupil is still quite
young he may be taught to become a perfect retriever through the
“Play Method,” as described in my book, “The Working Dog and His
Education.” When the ball is thrown the command should be given to
“Fetch!” The puppy will get the ball nine times out of ten, but he is
likely to run away with it and toss it about in play. He should be
induced to bring it to you or you must go to him, bring him to where
you were standing when the ball was thrown and gently take it out of
his mouth, repeating the word “Fetch!” As in the other lessons,
reward him with a bite to eat. A little of this play every day will make
him enjoy this pastime and in the end he will become a retriever. He
may also be taught to retrieve from water in the same manner,
although at first the ball should be thrown into the water only far
enough so that the puppy need but get his feet wet in retrieving it. It
may be thrown out farther and farther as the pupil progresses and in
the end he will enjoy this as much as land retrieving, especially if he
is a dog of the spaniel varieties. Airedales are also easily taught to
become perfect retrievers.
Another lesson which all dogs should learn is to remain at heel. First
it is necessary to teach them to lead. Put a collar on the puppy and
allow it to remain a day or two before going further. When he is
accustomed to this, attach the lead and call him to you. He will likely
pull back or buck jump a few times; keep a tight line and allow him to
go as far as he likes. When he becomes passive, call him to you and
draw in the lead. He may pull back or he may be frightened, but pull
him to you and then pet him and reward him with a bit to eat. He will
soon learn to lead.
After he once leads well then take him out with you on the street or
in the park. If he pulls ahead of you draw him back and give the
command “Heel!” He may remain behind for a moment, but dart
ahead again in a moment when he thinks you off guard. Check him
up and put him back of you once more with the same command to
“Heel!” If he goes along in this manner, fairly well after a few lessons,
you have accomplished the first step. Later it may be necessary to
carry a light switch which should be used on every occasion when
the dog attempts to forge ahead. Only a light tap on the nose is
necessary, but as it is given the command to heel should also be
uttered. In a short time the dog should be taken out without the cord
and kept at heel, but if he becomes unruly and does not remain in
his position the lead should be immediately snapped into the ring of
the collar and he should be given a few more lessons of the earlier
kind. Eventually he will understand that he must remain behind his
master until the command is given to “Go!” or “Hie on!” and this latter
command he will obey without much teaching, for it is the natural
inclination of all dogs to run on ahead of their masters, and they will
be prompt to take advantage of the permission to do so.
For fuller lessons on breaking, I would suggest that the reader
procure a copy of my former book, “The Working Dog and His
Education.”
CHAPTER VI.
The Food Question—When to Feed—Frequency
of Feeding—Water.
With but one dog in the household or on the premises, the question
of food is not a serious one. The scraps from the table of a family of
four should be sufficient to supply the entire ration of the dog,
although occasionally it is advisable to give him a change in the way
of scraps of raw beef, large, soft bones to gnaw upon, and by variety
it might also be well, say once a week, to procure the meat or
trimmings at your butcher’s out of which a broth may be made. This
is always a wholesome diet, especially if it is poured over stale
bread, dog biscuits or any of the bread stuffs that cannot be used on
the table.
First of all let me disabuse the reader of the old theory that meat is
injurious for the dog. Taking the race as a whole, meat should form
the principal diet. The dog is a naturally carnivorous animal and even
though he has been under domestication for thousands of years his
organs of mastication and digestion have undergone only a very
slight, if indeed, any change. With this in mind, the dog owner is
enabled to feed intelligently. Naturally, change of environment from
his wild state has made conditions different; he does not obtain the
amount of exercise that his wild ancestors did, ranging and roaming
about the country in search of their daily sustenance, consequently
he cannot be fed entirely the same, but nevertheless the idea which
through some unknown way became prevalent years ago that meat
is injurious to dogs and likely to cause disease is entirely erroneous.
The principal point to keep before one is the quantity of food and the
frequency of feeding. A dog which obtains considerable exercise in
the way of hunting, must have more meat than one that is exercised
only an hour or two each day. This is but natural; the man whose
profession keeps him indoors does not require the same substantial
food of the one who labors in the fields all day, and so it is with the
dog. Ordinary intelligence should teach proper discretion in this
respect.
Table scraps usually consist of all the necessary concomitants to a
good ration. Bits of meat, bread crusts, gravies, vegetables, etc., all
go to make up the waste from the table in any ordinary family.
Bones, if they are large ones, may be fed, but bones from fish,
poultry or small game should be eliminated if for no other reason but
the possibility of their causing trouble in the intestinal canal. If one
does not believe what trouble this may produce let him take the leg
bone of a chicken or lamb, place them on a stone and strike them a
sharp blow with a hammer. He will see at once that they are crushed
into a hundred tiny splinters. One can readily imagine what havoc
this may do if they should lodge in the stomach or intestines of a
dog. Perhaps one might feed these bones to a dog throughout his
entire life without ill results, but on the other hand, trouble might
ensue, hence to be on the safe side, it is better to take no chances.
Vegetables make a good bulk food, but they should be fed very
sparingly, and then only in connection with the other food. There is
little nutriment in vegetables for a dog; potatoes are of no value and
are more harmful than beneficial and the idea that dogs must be fed
garlic, tomatoes, onions and the like has been exploded long ago. A
very little of these in the regular food is passable, but do not attempt
to make a vegetarian of your dog. Corn meal, in its place, is well
enough fed occasionally, but as a regular food it is harmful,
especially in summer, as it causes skin irritations, because it is too
heating. Oat meal is some better, and rice, perhaps, the best of all,
but any of these foods should be fed only occasionally. Some
breeds, such as Yorkshire terriers, Maltese and the like do very well
with little meat and some say they should not have it at all, but even
this is questionable.
In large kennels it is well to cook one’s own food or make a bread
composed of unbolted wheat, a little rice, meat and a few well
cooked vegetables, the whole to be thoroughly cooked and then
baked into a bread in a slow oven which will cook it through and
through so that it will keep for a long time, but the owner of one dog
may as well dismiss this as unnecessary. To summarize: feed what
the family table offers, procure meat from your butcher occasionally,
for the broth and bones previously referred to, and do not overlook
the raw meat, which should be shredded or chopped finely and fed
three or four times a week in small quantities, for young dogs, but in
larger portions for grown ones. It is also well to obtain large bones
with the meat still clinging to them. Dogs love to tear the meat from
the bones and they also obtain considerable satisfaction in gnawing
the bones. Even puppies three months old and under may be fed
raw meat in small quantities to good advantage, and from personal
experience I have found that puppies thus fed will thrive better than
those who obtain little or none of this kind of diet.
For very young puppies the natural diet is milk, hence when you
obtain your new dog, assuming that he is three months old or under,
see that he obtains an abundance of this, but do not compel him to
live on a milk and bread diet entirely. Feed him a dish of this in the
morning; and it might be well to give him another small feed of this
about ten o’clock, then again at two and so on, until he is fed about
five times during the day, but some of the meals should consist of
broth and cooked meat, with an occasional feed of raw flesh.
Puppies, as they grow older, should be fed less often, and at four
months, three meals a day are sufficient. At this stage, the first meal
in the morning may consist of milk and stale bread, but the following
ones may be of table scraps or the broth made from the meat
obtained from the butcher, poured over stale bread of biscuits, giving
with the liquid also a sufficient quantity of the meat. At a year old the
dog may be fed as any older dog is fed.
The question of frequency of feeding matured dogs has been much
discussed. Many kennels feed but once daily and that meal is given
in the evening. This should consist of as much in quantity as the dog
will eat. The more humane method for grown dogs, however, is to
feed a light meal in the morning and the heavy one in the evening.
Most dogs thrive well on this, provided they obtain a sufficient
amount of meat to keep their natural desire for flesh food satisfied.
The dog owner will soon learn how to use discretion in feeding and
obtain best results, but those who wish to go further into this food
question are cited to my previous book, “Practical Dog Keeping For
the Amateur.”
As to water, it must be borne in mind that the dog requires water at
all times of the day or night and a vessel containing pure, fresh water
should always be accessible.
CHAPTER VII
Exercise—Grooming—Washing.
Where but one dog, or even two or three are kept in a home, the
danger of sickness is very small, especially if the behests as laid
down in the preceding chapters are followed. Dogs in the home are
not exposed like those which are kept in a kennel where new ones
are constantly coming in and going out. Nor is the danger of
contagious or infectious disease as great as when the dogs are
exhibited at bench shows. Nevertheless, the highly bred dog is a
fine-spun piece of mechanism and it is therefore best to know what
to do as first aid in case sickness does come. To the novice,
however, my advice is, send for the veterinarian, if a good one lives
in your vicinity, as soon as you notice something seriously wrong
with your dog. If no qualified canine practitioner is available, then
seek the advice of some dog expert, but do not resort to all manner
of dosing for dosing’s sake, as so many do, for in many cases too
much medicine has led to more serious consequences than the
illness itself.
The principal disorders that the one-dog owner is likely to encounter,
are probably distemper, worms, skin diseases, fits and other various
temporary stomach and intestinal ailments, most of which right
themselves by the administration of a dose of castor oil or some
other purgative.
Very frequently a dog will go off form due to overeating or perhaps
because of devouring something that was harmful, or possibly
because of lack of exercise. In most cases this is only temporary and
the animal will doctor himself, provided he has access to grass. Do
not be alarmed if your dog eats grass upon occasion, even though
he partakes of it copiously. He is simply finding in this green element
a nature remedy that will act as a conditioner. Fortunate is the canine
that has the opportunity to do this, for he is thus finding a home
remedy which is perhaps more effective than the most skilled
veterinarian might be able to prescribe.
Sometimes old dogs suffer from constipation and it is well,
occasionally, to put a little olive oil in their food, or even resort to a
purgative. One of the best ever-ready remedies I know of is equal
parts olive oil, cascara sagrada and castor oil. This may be mixed up
and kept on hand indefinitely as there is nothing in it that will spoil. If
your dog should go off his feed without showing any symptoms of
something more serious coming on, give him, if he is a dog of from
thirty to forty-five pounds, a tablespoonful of this night and morning
for four or five days, and he will soon come back to his natural form.
For smaller or larger dogs the dosage should be graded accordingly.
All dog owners, however, should know when a dog is coming down
with something serious. One of the most dreaded ailments is
distemper, a contagious disease which may be communicated either
by direct contact with a dog which has distemper, by being put in a
place that was recently occupied by a distempered animal, or by
associating with a dog which might be himself immune, but which
had recently come from a place where he was exposed. In this
manner such a dog is able to carry the disease even to some distant
locality. Thus many dogs have been subjected to disease through
their companions which were exhibited at bench shows, and which,
though immune themselves, carried it home to their kennel
companions.
First of all it should be said that the normal temperature of the dog is
from 100 to 100 1/2 degrees when taken under the forearm or inside
of the thigh. Taken per rectum it is one degree higher. This
temperature may vary some in the larger and the smaller breeds, but
it is the general average. If the dog appears listless, apathetic,
refuses to eat and possibly begins to sneeze or water at the eyes, if
his temperature has gone three or four degrees above normal, then
it may be taken for granted that he is in the first stages of distemper.
On the other hand, he may only show the dullness and the high
temperature; there may be no discharge from the eyes or nose, but a
dry, husky tell-tale cough may be noted. Any of these forms are the
symptoms of distemper and the victim should be isolated at once
and the first act should be to administer a liberal dose of castor oil. At
this stage I have found it very efficacious to give quinine and
hyposulphite of soda, each in two-grain doses, either together or one
following the other within half an hour, four times a day. The dog
must be placed in a warm and dry room and should not be allowed
to go out for anything. The room should be kept at a temperature of
seventy degrees, but must be ventilated by windows opening from
above so that there can be no draughts with which the victim will
come in contact. The disinfectant used should also be some dry
form, such as the various sanitary sawdust preparations that are on
the market. Any dampness in the room is detrimental to the patient.
The principal thing to remember in distemper is good care, for it will
be found more effective than medicine, whether given in serum form
or by mouth. The dog’s strength must be kept up and to this end
eggs, broth, and even finely chopped up raw beef in small quantities
will be beneficial. Some kennel men object to the beef, but
nevertheless many a dog will eat this where he refuses everything
else and certainly nothing is more nutritious than beef. Every
symptom must be combated as it arises and many complications are
likely to set in. One thing must always be kept in mind, and that is, to
make the dog take nourishment, for once he refuses to eat, then the
case is practically hopeless.
Those who prefer the serum treatment should begin giving it, as per
directions, subcutaneously, with hypodermic syringe. There are
several good serums or vaccines on the market, but the one that I
have had the most experience with is that put up by a Detroit
laboratory. This firm makes not only a curative vaccine, but one
known as a preventative. It is useless to give the prophylactic or
preventative after the dog has once been exposed. Rather await the
earliest developments and then begin with the curative and give the
six doses as per direction. Begin with bulb number one and follow up
at the intervals indicated until all have been given. In the meantime,
however, exercise the usual care in the way of even temperature in
the place where the patient is confined and in the matter of diet. This
is imperative, no matter what treatment is being used. The
prophylactic or curative treatment consists of three doses. It is also
given with hypodermic syringe, subcutaneously. It is well to keep this
serum on hand to use if one expects to show his dog or run him in
field trials, but the treatment should be given at least a month before
the time he is to appear in public. The success of this serum
treatment seems to be general, although many breeders have no
faith in it. This may be due to the fact that they begin too late or
failed to follow instructions. The treatment is supposed to combat all
symptoms that arise in the most virulent cases of distemper.
The worst complication of all distempers is that affecting the nervous
system; the brain and its membrane may become inflamed and fits
follow, or the spinal cord and its membranes are attacked, in which
event paralysis or chorea, or sometimes both occur. These can be
overcome, but it is a long drawn out and a very uncertain thing.
Generally, chorea occurs after the virulent phase of the disease is
passed and it is mostly due to too early exposure. The patient should
not be allowed to go out of doors or get excited in any way until the
temperature has been normal for at least ten days.
Common sense and good nursing win out more times than all the
medicine, but the complications as they arise must be combated. For
instance, the eyes must be looked after. The discharge should be
washed away frequently during the day with a warm boracic acid
solution by dissolving one teaspoonful of the boracic acid in half a
pint of warm water. The following lotion should be used afterward as
it will help keep the eyes clear:
Chinosol 3 grains
Water 6 ounces
As the dog recovers from the distemper and the eyes have that
opaque appearance so often noted, use an ointment made of 1 grain
yellow oxide of mercury mixed with one dram of vaseline. Drop a bit
about the size of a pea into the corner and rub well under the lids.
Sometimes red pustules will appear all over the underbody and
occasionally on all parts of the body. This should be treated with the
ordinary mange remedies. At other times the disease attacks the
bowels, which must then be looked after. Try bismuth in ten grain
doses for medium-sized dogs. If this does not stop the diarrhea, then
the following mixture might be effective:
Powdered Extract of Kino 1 dram
Powdered Ipecacuanha 8 grains
Powdered Opium 6 grains
Mix and divide into twelve pills.
Dose, from one-half to two pills, according to the size of the dog, four
times a day. After the acute stage is passed, then a good tonic is
desirable and for this purpose either Le Roy’s Condition Pills,
Sergeant’s or Glover’s are useful.
Another serious complication that frequently arrives is when it
attacks the lungs, and this is not at all uncommon; pneumonia being
one of the situations to guard against. Where there is a sudden rise
in temperature and the dog is inclined to sit on his haunches, bracing
himself on his forelegs, which are spread far apart, and his breathing
comes fast and sharp, it may be taken for granted that pneumonia is
the cause. By placing the ear to the chest one can hear the labored
breathing which sounds very much like someone walking over frozen
snow.
If the dog is not already wearing a chest jacket make one for him at
once. Sometimes strong liniments are effective. But one of the
simplest things to use is hot lard and turpentine. Grease the chest
well with this, wrap flannels around him and put the jacket over all.
Apply fresh turpentine and lard every two hours, until the breathing is
easier. The following is a very good formula to use internally:
Extract of Belladonna 1/2 grain
James’ Powder 4 grains
Nitrate of Potash 8 grains
Extract of Gentian, enough to make one pill
For medium-sized dogs make up twelve pills with the above
ingredients and give 1 three times daily. If the fever does not subside
readily it might be well to give them drops of aconite in a
tablespoonful of water, every three hours. Perpetual vigilance is
necessary in the successful combating of pneumonia and as in every
other phase of distemper, care and good nursing are most important.
For a more extended treatise on distemper, “Dogcraft,” third edition,
will be of great benefit to all dog owners.
Few dogs go through life without having Worms at some time in their
career and in the case of puppies, we doubt if any ever escape these
intestinal pests. Usually the kennel owner or dealer, worms the
puppies before he sells them, hence the future owner has little to
fear, although it must not be supposed that when a vermifuge is
given to a puppy once or even two or three times during his young
life, that he will be forever free from worms. On the other hand, he is
likely to have them at any time, though the danger of fatal results is
far less.
There are numerous remedies that may be used very effectively for
the various kinds of worms, such as areca nut, santonin, pink and
senna, kamala, etc., but I believe the safest plan for the novice is to
procure any one of the reliable proprietary remedies that are on the
market, for it will be less trouble to give these and there is little
danger of going wrong, which might be the case were the neophyte
to dabble with unknown drugs.
For Tape Worm—and many more dogs suffer from this than one
might suppose—kamala and areca nut in equal parts is very
effective. That is, for large dogs give two grains (one grain of each
drug) to the pound weight of the dog after fasting twenty-four to
thirty-six hours. One hour after giving the vermifuge the dog should
have a liberal dose of castor oil. The symptoms of tape worm are
varied. The dog may have a capricious appetite, his coat becomes
harsh and stary, he looks thin and emaciated and he has a habit of
rubbing his sides and back up along fences or buildings. His breath
is usually offensive and his eyes lack luster and frequently form pus
in the corners.
In the South the Hook Worm is the bane of all dog owners and it is
becoming more prevalent every year. Indeed, of late years it has
been invading the North also, which is probably due to field trials and
bench shows, as dogs from the North are taken South where they
become infested and thus bring the pests back to their homes.
Recently a very good specific for hook worms has been discovered
and from all accounts it is giving excellent results. The drug is carbon
tetrachloride. The dose is one drop for each pound weight of the dog
after fasting twenty-four hours. The drug should be placed in hard
capsules and administered in that manner. It is not necessary to
follow with a purgative as is the case with most other vermifuges.
This new remedy has been given to very young puppies with the
best results. It should always be remembered, however, that the
dosage should be one drop to the pound weight of the dog, no
matter how large or how small he is.
A dog affected with hook worms usually grows very thin, is dull and
apathetic, his coat is harsh and unnatural, his eyes lack fire and he
has little or no ambition, but the greatest tell-tale sign of all is his
gums and the mucous membrane of his eyes. Instead of being a
healthy pink, they become white and waxy. When the gums and
mouth are in this condition, then it is time to begin treatment for hook
worms.
One of the common disturbances that house dogs are subject to is
Fits. It is rather disheartening to the novice to see his dog roll over
suddenly and become stiff and rigid, for in most cases he is at a loss
what to do. Fits arise from various causes; through worms,
constitutional nervous disorders, the aftermath of distemper, but in
most cases with house dogs, because of constipation or indigestion.
If the trouble is due to the two latter causes, then they may be easily
overcome by a change of diet and more exercise, for there is where
the trouble generally lies. The dog is fed heartily, frequently of
indigestible food, he obtains little or no exercise and the inevitable
result is a disarrangement of bowels, stomach or liver. If the fits are
the aftermath of distemper, the dog may outgrow them, but if they
are constitutional, then little or nothing can be done. However, it is
fits of the first order—that is, due to derangement of the digestive
organs—which are the commonest among house dogs. The victim
may suddenly fall over, or he may remain on his feet, and if he does,
the toe nails will dig into the rug or carpet in a way that once seen
will always be recognized. These seizures are generally easily
overcome by applying warm applications to the abdomen, or hand
massage. The victim, however, should be given a purgative once a